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) 5.28 kB
"use strict"; /* globals module */ /** * @module filesBatchClient * @description Files Batch Client provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Files 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 FilesBatchClient = /** @class */ (function () { function FilesBatchClient(filesBatchRoute, apiClient) { this.filesBatchRoute = filesBatchRoute; this.apiClient = apiClient; } Object.defineProperty(FilesBatchClient.prototype, "routeDefinition", { get: function () { return this.filesBatchRoute; }, enumerable: true, configurable: true }); /** * Returns a promise that is resolved once the update action has been performed; this action updates specified file resources. * @method * @param data A collection of file objects used to update specified file resources. * @returns A promise that is resolved once the update action has been performed. * @example filesClient.update(files) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ FilesBatchClient.prototype.update = function (data) { return this.apiClient.put(this.routeDefinition.update(), this.routeDefinition.updateParams(data)); }; /** * Returns a promise that is resolved once the link action has been performed; this action links file resources from other modules into the Files module (For example: file resources from the Media Vault module can be linked directly into the Files module). * @method * @param data A collection of file objects that need to be inserted into the system. * @returns A promise that is resolved once the link action has been performed. * @example filesBatchClient.link(files) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ FilesBatchClient.prototype.link = function (data) { return this.apiClient.post(this.routeDefinition.link(), this.routeDefinition.createParams(data)); }; /** * Returns a promise that is resolved once the unlink action has been performed. This action will remove file resources from the system if successfully completed. If derived resource's format is passed, such as `width` and `height` for the image type of file resource, the operation will remove just derived resource. Otherwise, specified file and all its accompanying derived resources will be removed from the system. * @method * @param data Collection of file delete requests which uniquely identifies file resources that need to be deleted. * @returns A promise that is resolved once the unlink action has been performed. * @example // Remove original file resources filesBatchClient.unlink([{ id: '<file-id>' }]) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); // Remove derived file resources filesBatchClient.unlink([{ id: '<file-id>', fileFormat: { width: <width>, height: <height> } }]) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ FilesBatchClient.prototype.unlink = function (data) { return this.apiClient.delete(this.filesBatchRoute.unlink(), undefined, data); }; FilesBatchClient = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(_1.TYPES.FilesBatchRoute)), tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)), tslib_1.__metadata("design:paramtypes", [_1.FilesBatchRoute, httpApi_1.ApiClient]) ], FilesBatchClient); return FilesBatchClient; }()); exports.FilesBatchClient = FilesBatchClient; /** * @overview ***Notes:** - Refer to the [REST API documentation](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. */