UNPKG

baasic-sdk-javascript

Version:

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

81 lines (80 loc) 4.49 kB
"use strict"; /* globals module */ /** * @module mediaVaultBatchClient * @description Media Vault Batch Client provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Media Vault Batch 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 MediaVaultBatchClient = /** @class */ (function () { function MediaVaultBatchClient(mediaVaultBatchRoute, apiClient) { this.mediaVaultBatchRoute = mediaVaultBatchRoute; this.apiClient = apiClient; } Object.defineProperty(MediaVaultBatchClient.prototype, "routeDefinition", { get: function () { return this.mediaVaultBatchRoute; }, enumerable: true, configurable: true }); /** * Returns a promise that is resolved once the update action has been performed; this action updates specified media vault resources. * @method * @param data A collection of media vault objects used to update specified media vault resources. * @returns A promise that is resolved once the update action has been performed. * @example mediaVaultStreamsClient.update(files) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ MediaVaultBatchClient.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 media vault resources from the system if successfully completed. If derived resource's format is passed, such as `width` and `height` for the image type of media vault resource, the operation will remove just derived resource. Otherwise, specified media vault and all its accompanying derived resources will be removed from the system. * @method * @param data Collection of media vault delete requests which uniquely identifies media vault resources that need to be deleted. * @example // Remove original media vault resources mediaVaultBatchClient.remove([{ id: '<media-vault-id>' }]) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); // Remove derived media vault resources mediaVaultBatchClient.remove([{ id: '<media-vault-id>', fileFormat: { width: <width>, height: <height> } }]) .then(function (data) { // perform success action here }, function (response, status, headers, config) { // perform error handling here }); **/ MediaVaultBatchClient.prototype.remove = function (data) { return this.apiClient.delete(this.mediaVaultBatchRoute.delete(), undefined, data); }; MediaVaultBatchClient = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(_1.TYPES.MediaVaultBatchRoute)), tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)), tslib_1.__metadata("design:paramtypes", [_1.MediaVaultBatchRoute, httpApi_1.ApiClient]) ], MediaVaultBatchClient); return MediaVaultBatchClient; }()); exports.MediaVaultBatchClient = MediaVaultBatchClient; /** * @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. */