UNPKG

baasic-sdk-javascript

Version:

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

98 lines (97 loc) 4.88 kB
"use strict"; /* globals module */ /** * @module meteringCategoryBatchClient * @description Metering Category Batch Client provides an easy way to consume Metering REST API end-points. In order to obtain a needed routes `meteringCategoryBatchClient` uses `meteringCategoryBatchRoute`. */ 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 MeteringCategoryBatchClient = /** @class */ (function () { function MeteringCategoryBatchClient(meteringCategoryBatchRoute, apiClient) { this.meteringCategoryBatchRoute = meteringCategoryBatchRoute; this.apiClient = apiClient; } Object.defineProperty(MeteringCategoryBatchClient.prototype, "routeDefinition", { get: function () { return this.meteringCategoryBatchRoute; }, enumerable: true, configurable: true }); /** * Returns a promise that is resolved once the create category action has been performed; this action creates new category resources. * @method * @param data An MeteringCategory objects that need to be inserted into the system. * @returns A promise that is resolved once the create category action has been performed. * @example meteringCategoryBatchClient.create([{ aggregateFunction : '<aggregateFunction>', category : '<name>', defaultSamplingRate: '<defaultSamplingRate>', slug: '<slug>', unitFactor: '<unitFactor>', unitName: '<unitName>' }]) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ MeteringCategoryBatchClient.prototype.create = function (data) { return this.apiClient.post(this.routeDefinition.create(), this.routeDefinition.createParams(data)); }; /** * Returns a promise that is resolved once the update category action has been performed; this action updates specified category resources. * @method * @param data An MeteringCategory objects used to update specified MeteringCategory resources. * @returns A promise that is resolved once the update category action has been performed. * @example meteringCategoryClient.update(companies) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ MeteringCategoryBatchClient.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 category resources from the system if successfully completed. * @method * @param ids MeteringCategory ids which uniquely identify MeteringCategory resources that need to be deleted. * @returns A promise that is resolved once the remove action has been performed. * @example companyClient.remove(companyIds) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ MeteringCategoryBatchClient.prototype.delete = function (ids) { return this.apiClient.delete(this.routeDefinition.delete(), undefined, this.routeDefinition.deleteParams(ids)); }; MeteringCategoryBatchClient = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(_1.TYPES.MeteringCategoryBatchRoute)), tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)), tslib_1.__metadata("design:paramtypes", [_1.MeteringCategoryBatchRoute, httpApi_1.ApiClient]) ], MeteringCategoryBatchClient); return MeteringCategoryBatchClient; }()); exports.MeteringCategoryBatchClient = MeteringCategoryBatchClient; /** * @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. - All end-point objects are transformed by the associated route service. */