UNPKG

baasic-sdk-javascript

Version:

JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).

107 lines (106 loc) 5.23 kB
"use strict"; /* globals module */ /** * @module roleBatchClient * @description Role Batch Client provides an easy way to consume Role REST API end-points. In order to obtain needed routes `roleBatchClient` uses `roleBatchRoute`. */ Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var inversify_1 = require("inversify"); ; var httpApi_1 = require("../../httpApi"); var _1 = require("./"); var RoleBatchClient = /** @class */ (function () { function RoleBatchClient(roleBatchRoute, apiClient) { this.roleBatchRoute = roleBatchRoute; this.apiClient = apiClient; } Object.defineProperty(RoleBatchClient.prototype, "routeDefinition", { /** * Provides direct access to `roleRoute`. * @method * @example roleBatchClient.routeDefinition.get().expand(expandObject); **/ get: function () { return this.roleBatchRoute; }, enumerable: true, configurable: true }); /** * Returns a promise that is resolved once the create action has been performed; this action creates a role. * @method * @param data A role object that needs to be inserted into the system. * @returns A promise that is resolved once the create action has beend performed. * @example roleBatchClient.create({ description : '<description>', name : '<name>' }) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ RoleBatchClient.prototype.create = function (data) { return this.apiClient.post(this.routeDefinition.create(), this.routeDefinition.createParams(data)); }; /** * Returns a promise that is resolved once the update role action has been performed; this action updates a role. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `roleClient` route template. Here is an example of how a route can be obtained from HAL enabled objects: * ``` * let params = modelMapper.removeParams(role); * let uri = params['model'].links('put').href; * ``` * @method * @param data A role object used to update specified role resource. * @returns A promise that is resolved once the update role action has been performed. * @example // role is a resource previously fetched using get action. role.name = '<new-name>'; roleBatchClient.update(role) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ RoleBatchClient.prototype.update = function (data) { return this.apiClient.put(this.routeDefinition.update(), this.routeDefinition.updateParams(data)); }; /** * Returns a promise that is resolved once the remove role action has been performed. This action will remove a role from the system, if completed successfully. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `roleClient` route template. Here is an example of how a route can be obtained from HAL enabled objects: * ``` * let params = modelMapper.removeParams(role); * let uri = params['model'].links('delete').href; ``` * @param data A role object used to delete specified role resource. * @returns A promise that is resolved once the remove action has been performed. * @method * @example // Role is a resource previously fetched using get action. roleBatchClient.remove(role) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ RoleBatchClient.prototype.remove = function (data) { return this.apiClient.delete(this.routeDefinition.delete(), undefined, this.routeDefinition.deleteBatchParams(data)); }; RoleBatchClient = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(_1.TYPES.RoleBatchRoute)), tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)), tslib_1.__metadata("design:paramtypes", [_1.RoleBatchRoute, httpApi_1.ApiClient]) ], RoleBatchClient); return RoleBatchClient; }()); exports.RoleBatchClient = RoleBatchClient; /** * @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. - All end-point objects are transformed by the associated route definition. */