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