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) • 6.07 kB
JavaScript
;
/* globals module */
/**
* @module articleInstanceFilesBatchClient
* @description Article Instance Files Batch Client provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Files Route Service 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 ArticleInstanceFilesBatchClient = /** @class */ (function () {
function ArticleInstanceFilesBatchClient(articleInstanceFilesBatchRoute, apiClient) {
this.articleInstanceFilesBatchRoute = articleInstanceFilesBatchRoute;
this.apiClient = apiClient;
}
Object.defineProperty(ArticleInstanceFilesBatchClient.prototype, "routeDefinition", {
get: function () {
return this.articleInstanceFilesBatchRoute;
},
enumerable: true,
configurable: true
});
/**
* 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 articleId Article file id of the original article file used to identify article files on which delete action should be performed.
* @param data Collection of article delete requests which uniquely identifies article files that need to be deleted.
* @returns A promise that is resolved once the unlink action has been performed.
* @example // Remove original file resources
articleInstanceFilesBatchClient.unlink([{ id: '<file-id>' }])
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
// Remove derived file resources
articleInstanceFilesBatchClient.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
});
**/
ArticleInstanceFilesBatchClient.prototype.unlink = function (articleId, data) {
return this.apiClient.delete(this.articleInstanceFilesBatchRoute.unlink(articleId), undefined, data);
};
/**
* Returns a promise that is resolved once the update action has been performed; this action updates specified file resources.
* @method
* @param articleId Article slug or id which uniquely identifies article whose article file need to be updated.
* @param data Article file object that need to be updated in the system.
* @returns A promise that is resolved once the update action has been performed.
* @example articleInstanceFilesBatchClient.update(files)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
ArticleInstanceFilesBatchClient.prototype.update = function (articleId, data) {
return this.apiClient.put(this.routeDefinition.update(articleId), 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 articleId Article slug or id which uniquely identifies article whose article files need to be linked.
* @param data A collection of article file objects that need to be inserted into the system.
* @returns A promise that is resolved once the link action has been performed.
* @example articleInstanceFilesBatchClient.link(files)
.then(function (data) {
// perform success action here
},
function (response, status, headers, config) {
// perform error handling here
});
**/
ArticleInstanceFilesBatchClient.prototype.link = function (articleId, data) {
return this.apiClient.post(this.routeDefinition.link(articleId), this.routeDefinition.createParams(data));
};
ArticleInstanceFilesBatchClient = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(__1.TYPES.ArticleInstanceFilesBatchRoute)),
tslib_1.__param(1, inversify_1.inject(httpApi_1.httpTYPES.ApiClient)),
tslib_1.__metadata("design:paramtypes", [__1.ArticleInstanceFilesBatchRoute,
httpApi_1.ApiClient])
], ArticleInstanceFilesBatchClient);
return ArticleInstanceFilesBatchClient;
}());
exports.ArticleInstanceFilesBatchClient = ArticleInstanceFilesBatchClient;
/**
* @overview
***Notes:**
- Refer to the [REST API documentation](https://github.com/Baasic/baasic-rest-api/wiki) for detailed information about available Baasic REST API end-points.
- All end-point objects are transformed by the associated route service.
*/