baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
58 lines (57 loc) • 2.61 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
var contracts_1 = require("../core/contracts");
var core_1 = require("../core");
var __1 = require("../");
var httpApi_1 = require("../httpApi");
var modules = require("./modules");
var BaasicPlatform = /** @class */ (function () {
function BaasicPlatform(options) {
this.options = options;
this.utility = new common_1.Utility();
var opt = {};
if (options) {
opt = options;
}
this.settings = this.utility.extendAs({}, BaasicPlatform.defaultSettings, opt);
this.diModule = new __1.DIModule();
this.diModule.init(this, [common_1.commonDIModule, core_1.coreDIModule, httpApi_1.httpDIModule, modules]);
this.tokenHandler = this.diModule.kernel.get(contracts_1.TYPES.ITokenHandler);
this.userHandler = this.diModule.kernel.get(contracts_1.TYPES.IUserHandler);
this.eventHandler = this.diModule.kernel.get(contracts_1.TYPES.IEventHandler);
this.apiClient = this.diModule.kernel.get(httpApi_1.httpTYPES.ApiClient);
this.membershipModule = this.diModule.kernel.get(modules.Membership.TYPES.Root);
//Modules
this.applicationSettingModule = this.diModule.kernel.get(modules.ApplicationSettings.TYPES.ApplicationSettingsClient);
this.userProfileModule = this.diModule.kernel.get(modules.UserProfile.TYPES.Root);
this.notificationModule = this.diModule.kernel.get(modules.Notifications.TYPES.NotificationsClient);
this.maintenanceModule = this.diModule.kernel.get(modules.Maintenance.TYPES.Root);
}
BaasicPlatform.prototype.getAccessToken = function () {
return this.tokenHandler.get(contracts_1.TokenTypes.Access);
};
BaasicPlatform.prototype.updateAccessToken = function (value) {
this.tokenHandler.store(value);
};
BaasicPlatform.prototype.getApiKey = function () {
return 'platform';
};
BaasicPlatform.prototype.getApiUrl = function () {
return this.settings.apiUrl;
};
BaasicPlatform.prototype.getUser = function () {
return this.userHandler.getUser();
};
BaasicPlatform.prototype.setUser = function (userInfo) {
this.userHandler.setUser(userInfo);
};
BaasicPlatform.defaultSettings = {
useSSL: true,
apiRootUrl: 'api.baasic.com',
apiVersion: 'v1',
enableHALJSON: false
};
return BaasicPlatform;
}());
exports.BaasicPlatform = BaasicPlatform;