mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-13 21:24:58 +08:00
33 lines
799 B
Text
33 lines
799 B
Text
|
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(this, options);
|
||
|
return req.run();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default new N1CloudAPI();
|