baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
119 lines (118 loc) • 5.81 kB
JavaScript
"use strict";
/* globals module */
/**
* @module dynamicResourceBatchClient
* @description DynamicResourceBatchClient provides an easy way to consume DynamicResourceBatchBatch REST API end-points. In order to obtain needed routes `dynamicResourceBatchClient` uses `dynamicResourceBatchRoute`.
*/
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 DynamicResourceBatchClient = /** @class */ (function () {
function DynamicResourceBatchClient(dynamicResourceBatchRoute, apiClient) {
this.dynamicResourceBatchRoute = dynamicResourceBatchRoute;
this.apiClient = apiClient;
}
Object.defineProperty(DynamicResourceBatchClient.prototype, "routeDefinition", {
get: function () {
return this.dynamicResourceBatchRoute;
},
enumerable: true,
configurable: true
});
/**
* Returns a promise that is resolved once the create JSON object action has been performed; this action creates new JSON object resources.
* @method
* @param data JSON object objects that need to be inserted into the system.
* @returns A promise that is resolved once the create JSON object action has been performed.
* @example dynamicResourceBatchClient.create([{
name: '<name>'
}])
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
*/
DynamicResourceBatchClient.prototype.create = function (data) {
return this.apiClient.post(this.routeDefinition.create(), this.routeDefinition.createParams(data));
};
/**
* Returns a promise that is resolved once the update JSON object action has been performed; this action updates JSON object resources.
* @method
* @param data JSON object objects used to update specified JSON object resources.
* @returns A promise that is resolved once the update JSON object action has been performed.
* @example JSON object are resources previously fetched using get action.
dynamicResourceBatchClient.update([{
id: '<id>',
name: '<name>'
}])
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
*/
DynamicResourceBatchClient.prototype.update = function (data) {
return this.apiClient.put(this.routeDefinition.update(), this.routeDefinition.updateParams(data));
};
/**
* Returns a promise that is resolved once the patch JSON object action has been performed; this action patches JSON object resources.
* @method
* @param data JSON object objects used to patch specified JSON object resources.
* @returns A promise that is resolved once the patch JSON object action has been performed.
* @example JSON object are resources previously fetched using get action.
dynamicResourceBatchClient.patch([{
id: '<id>',
name: '<name>'
}])
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
*/
DynamicResourceBatchClient.prototype.patch = function (data) {
return this.apiClient.put(this.routeDefinition.patch(), this.routeDefinition.updateParams(data));
};
/**
* Returns a promise that is resolved once the remove action has been performed. This action will remove JSON object resources from the system if successfully completed.
* @method
* @param data JSON object Ids which uniquely identify JSON object resources to be deleted.
* @returns A promise that is resolved once the remove action has been performed.
* @example JSON object Ids are identifiers which uniquely identify JSON object resources.
dynamicResourceBatchClient.remove(['<id1>', '<id2>']])
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
*/
DynamicResourceBatchClient.prototype.remove = function (data) {
return this.apiClient.delete(this.routeDefinition.delete(), this.routeDefinition.deleteParams(data));
};
DynamicResourceBatchClient = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(_1.TYPES.DynamicResourceBatchRoute)),
tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)),
tslib_1.__metadata("design:paramtypes", [_1.DynamicResourceBatchRoute,
httpApi_1.ApiClient])
], DynamicResourceBatchClient);
return DynamicResourceBatchClient;
}());
exports.DynamicResourceBatchClient = DynamicResourceBatchClient;
/**
* @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 definition.
*/