baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
97 lines (96 loc) • 4.52 kB
JavaScript
;
/* globals module */
/**
* @module meteringBatchClient
* @description Metering Batch Client provides an easy way to consume Metering REST API end-points. In order to obtain a needed routes `meteringBatchClient` uses `meteringBatchRoute`.
*/
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 MeteringBatchClient = /** @class */ (function () {
function MeteringBatchClient(meteringBatchRoute, apiClient) {
this.meteringBatchRoute = meteringBatchRoute;
this.apiClient = apiClient;
}
Object.defineProperty(MeteringBatchClient.prototype, "routeDefinition", {
get: function () {
return this.meteringBatchRoute;
},
enumerable: true,
configurable: true
});
/**
* Returns a promise that is resolved once the create data action has been performed; this action creates new data resources.
* @method
* @param data An MeteringData objects that need to be inserted into the system.
* @returns A promise that is resolved once the create data action has been performed.
* @example meteringBatchClient.create([{
applicationId : '<applicationId>',
category : '<category>',
name: '<name>',
value: '<value>'
}])
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
MeteringBatchClient.prototype.create = function (data) {
return this.apiClient.post(this.routeDefinition.create(), this.routeDefinition.createParams(data));
};
/**
* Returns a promise that is resolved once the update data action has been performed; this action updates specified data resources.
* @method
* @param data An MeteringData objects used to update specified MeteringData resources.
* @returns A promise that is resolved once the update data action has been performed.
* @example meteringBatchClient.update(companies)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
MeteringBatchClient.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 data resources from the system if successfully completed.
* @method
* @param ids MeteringData ids which uniquely identify MeteringData resources that need to be deleted.
* @returns A promise that is resolved once the remove action has been performed.
* @example meteringClient.remove(companyIds)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
MeteringBatchClient.prototype.remove = function (ids) {
return this.apiClient.delete(this.meteringBatchRoute.delete(), undefined, ids);
};
MeteringBatchClient = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(_1.TYPES.MeteringBatchRoute)),
tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)),
tslib_1.__metadata("design:paramtypes", [_1.MeteringBatchRoute,
httpApi_1.ApiClient])
], MeteringBatchClient);
return MeteringBatchClient;
}());
exports.MeteringBatchClient = MeteringBatchClient;
/**
* @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.
*/