Mailspring/src/n1-cloud-api.es6

36 lines
825 B
Text
Raw Normal View History

2016-11-29 07:38:53 +08:00
import NylasAPIRequest from './flux/nylas-api-request';
import IdentityStore from './flux/stores/identity-store'
class N1CloudAPI {
constructor() {
NylasEnv.config.onDidChange('env', this._onConfigChanged);
this._onConfigChanged();
}
_onConfigChanged = () => {
const env = NylasEnv.config.get('env')
if (['development', 'local'].includes(env)) {
this.APIRoot = "http://localhost:5100";
} else {
this.APIRoot = "https://n1.nylas.com";
}
}
makeRequest(options = {}) {
if (NylasEnv.getLoadSettings().isSpec) return Promise.resolve();
options.auth = options.auth || {
user: IdentityStore.identityId(),
pass: '',
}
const req = new NylasAPIRequest({
api: this,
options,
});
2016-11-29 07:38:53 +08:00
return req.run();
}
}
export default new N1CloudAPI();