UNPKG

baasic-sdk-javascript

Version:

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

90 lines (89 loc) 4.56 kB
"use strict"; /* globals module */ /** * @module organizationBatchClient * @description Organization Batch Client provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Organization Batch Route Definition 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 httpApi_1 = require("../../httpApi"); var _1 = require("./"); var OrganizationBatchClient = /** @class */ (function () { function OrganizationBatchClient(organizationBatchRoute, apiClient) { this.organizationBatchRoute = organizationBatchRoute; this.apiClient = apiClient; } Object.defineProperty(OrganizationBatchClient.prototype, "routeDefinition", { get: function () { return this.organizationBatchRoute; }, enumerable: true, configurable: true }); /** * Returns a promise that is resolved once the create organization action has been performed; this action creates new organization resources. * @method * @param data A collection of organization objects that need to be inserted into the system. * @returns A promise that is resolved once the create organization action has been performed. * @example organizationBatchClient.create([{ description : '<description>', name : '<name>', slug: '<slug>' }]) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ OrganizationBatchClient.prototype.create = function (data) { return this.apiClient.post(this.routeDefinition.create(), this.routeDefinition.createParams(data)); }; /** * Returns a promise that is resolved once the update organization action has been performed; this action updates specified organization resources. * @method * @param data A collection of organization objects used to update specified organization resources. * @returns A promise that is resolved once the update organization action has been performed. * @example organizationBatchClient.update(organizations) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ OrganizationBatchClient.prototype.update = function (data) { return this.apiClient.put(this.routeDefinition.update(), this.routeDefinition.updateParams(data)); }; /** * Returns a promise that is resolved once the remove action has been performed. This action will remove organization resources from the system if successfully completed. * @method * @example organizationBatchClient.remove(organizationIds) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ OrganizationBatchClient.prototype.remove = function (ids) { return this.apiClient.delete(this.organizationBatchRoute.delete(), undefined, ids); }; OrganizationBatchClient = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(_1.TYPES.OrganizationBatchRoute)), tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)), tslib_1.__metadata("design:paramtypes", [_1.OrganizationBatchRoute, httpApi_1.ApiClient]) ], OrganizationBatchClient); return OrganizationBatchClient; }()); exports.OrganizationBatchClient = OrganizationBatchClient; /** * @overview ***Notes:** - Refer to the [REST API documentation](https://github.com/Baasic/baasic-rest-api/wiki) for detailed information about available Baasic REST API end-points. - All end-point objects are transformed by the associated route service. */