baasic-sdk-nodejs
Version:
NodeJS SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
66 lines (65 loc) • 2.87 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var baasic_sdk_javascript_1 = require("baasic-sdk-javascript");
var http_client_1 = require("./infrastructure/httpApi/http-client");
var store_1 = require("./infrastructure/store");
var event_handler_1 = require("./infrastructure/event.handler");
var clients = require("./clients");
var urlUtil = require("url");
var BaasicApp = (function () {
function BaasicApp(apiKey, options) {
this.app = new baasic_sdk_javascript_1.BaasicApp(apiKey, getOptions(options));
this.membershipClient = new clients.MembershipClient(this.app);
//Modules
this.applicationSettingClient = new clients.ApplicationSettingsClient(this.app);
this.keyValueClient = new clients.KeyValueClient(this.app);
this.valueSetClient = new clients.ValueSetClient(this.app);
this.userProfileClient = new clients.UserProfileClient(this.app);
this.templatingClient = new clients.TemplatingClient(this.app);
this.meteringClient = new clients.MeteringClient(this.app);
this.mediaVaultClient = new clients.MediaVaultClient(this.app);
this.fileClient = new clients.FilesClient(this.app);
this.dynamicResourceClient = new clients.DynamicResourceClient(this.app);
this.notificationClient = new clients.NotificationsClient(this.app);
this.articleClient = new clients.ArticleClient(this.app);
this.commerceClient = new clients.CommerceClient(this.app);
}
BaasicApp.prototype.getAccessToken = function () {
return this.app.getAccessToken();
};
BaasicApp.prototype.updateAccessToken = function (value) {
this.app.updateAccessToken(value);
};
BaasicApp.prototype.getApiKey = function () {
return this.app.getApiKey();
};
BaasicApp.prototype.getApiUrl = function () {
return this.app.getApiUrl();
};
BaasicApp.prototype.getUser = function () {
return this.app.getUser();
};
BaasicApp.prototype.setUser = function (userInfo) {
this.app.setUser(userInfo);
};
return BaasicApp;
}());
exports.BaasicApp = BaasicApp;
;
function getOptions(options) {
var defaults = {
httpClient: function () { return new http_client_1.HttpClient(); },
storageHandler: function () { return new store_1.InMemoryStorageHandler(); },
eventHandler: function () { return new event_handler_1.EventHandler(); },
urlFactory: function (url, base) {
if (base) {
url = base + url;
}
var urlObject = urlUtil.parse(url);
urlObject.toString = function () { return urlUtil.format(urlObject); };
return urlObject;
}
};
return Object.assign({}, defaults, options);
}
;