baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
132 lines (131 loc) • 6.4 kB
JavaScript
"use strict";
/* globals module */
/**
* @module applicationSettingsRoute
* @description Baasic Application Settings Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Application Settings Route Service to obtain needed routes while other routes will be obtained through HAL. By convention, all route services use the same function names as their corresponding services.
*/
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var inversify_1 = require("inversify");
var common_1 = require("../../../common");
var contracts_1 = require("../../../core/contracts");
var ApplicationSettingsRoute = /** @class */ (function (_super) {
tslib_1.__extends(ApplicationSettingsRoute, _super);
function ApplicationSettingsRoute(appOptions) {
var _this = _super.call(this, appOptions) || this;
_this.appOptions = appOptions;
/**
* Application activate route with route and query parameters.
**/
_this.activateRoute = 'applications/{id}/activate';
/**
* Application activate route with route and query parameters.
**/
_this.deactivateRoute = 'applications/{id}/deactivate';
/**
* Application delete route with route and query parameters.
**/
_this.deleteRoute = 'applications/{id}';
/**
* Application find route with route and query parameters.
**/
_this.findRoute = 'applications/{?searchQuery,page,rpp,sort,embed,fields}';
/**
* Get route with route and query parameters.
**/
_this.getRoute = 'applications/{id}';
/**
* Create route with route and query parameters.
**/
_this.createRoute = 'applications';
/**
* Update route with route and query parameters.
**/
_this.updateRoute = 'applications/{id}';
return _this;
}
/**
* Parses activation route; route should be expanded with the `id` which uniquely identifies the application that needs to be activated.
* @method
* @param data Id which uniquely identifies application that needs to be activated.
* @example applicationRoute.activate({id: '<identifier>'});
**/
ApplicationSettingsRoute.prototype.activate = function (data) {
var params = this.modelMapper.getParams(data, undefined, 'id');
return _super.prototype.baseCreate.call(this, this.activateRoute, params);
};
/**
* Parses deactivation route; route should be expanded with the `id` which uniquely identifies the application that needs to be deactivated.
* @method
* @param data Id which uniquely identifies application that needs to be deactivated.
* @example applicationRoute.deactivate({id: '<identifier>'});
**/
ApplicationSettingsRoute.prototype.deactivate = function (data) {
var params = this.modelMapper.getParams(data, undefined, 'id');
return _super.prototype.baseCreate.call(this, this.deactivateRoute, params);
};
/**
* Parses get application route which must be expanded with the identifier of the previously created application resource in the system.
* @method
* @example applicationRoute.get(id)
**/
ApplicationSettingsRoute.prototype.get = function (id) {
return _super.prototype.baseGet.call(this, this.getRoute, id, {});
};
/**
* Parses delete application route.
* @method
* @param data A application object used to delete specified application resource.
* @example applicationRoute.delete(data);
*/
ApplicationSettingsRoute.prototype.delete = function (data) {
return _super.prototype.baseDelete.call(this, this.deleteRoute, data);
};
/**
* Parses find application route which can be expanded with additional options. Supported items are:
* - `searchQuery` - A string referencing application properties using the phrase or BQL (Baasic Query Language) search.
* - `page` - A value used to set the page number, i.e. to retrieve certain application subset from the storage.
* - `rpp` - A value used to limit the size of result set per page.
* - `sort` - A string used to set the application property to sort the result collection by.
* - `embed` - Comma separated list of resources to be contained within the current representation.
* @method
* @example applicationRoute.find({searchQuery: '<search-phrase>'});
**/
ApplicationSettingsRoute.prototype.find = function (options) {
return _super.prototype.baseFind.call(this, this.findRoute, options);
};
/**
* Parses create application route, this URI template does not expose any additional options.
* @method
* @example applicationRoute.create();
**/
ApplicationSettingsRoute.prototype.create = function () {
return _super.prototype.baseCreate.call(this, this.createRoute, {});
};
/**
* Parses update application route.
* @method
* @param data A application object used to update specified application resource.
* @example applicationRoute.update(data);
*/
ApplicationSettingsRoute.prototype.update = function (data) {
return _super.prototype.baseUpdate.call(this, this.updateRoute, data);
};
ApplicationSettingsRoute = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)),
tslib_1.__metadata("design:paramtypes", [Object])
], ApplicationSettingsRoute);
return ApplicationSettingsRoute;
}(common_1.BaseRoute));
exports.ApplicationSettingsRoute = ApplicationSettingsRoute;
/**
* @copyright (c) 2017 Mono Ltd
* @license MIT
* @author Mono Ltd
* @overview
***Notes:**
- Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) for detailed information about available Baasic REST API end-points.
- [URI Template](https://github.com/Baasic/uritemplate-js) syntax enables expanding the Baasic route templates to Baasic REST URIs providing it with an object that contains URI parameters.
- All end-point objects are transformed by the associated route service.
*/