UNPKG

baasic-sdk-javascript

Version:

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

146 lines (145 loc) 7.82 kB
"use strict"; /* globals module */ /** * @module articleCommentsRoute * @description Baasic Article Comments Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Article Comments 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 common_1 = require("../../common"); ; var contracts_1 = require("../../core/contracts"); var ArticleCommentsRoute = /** @class */ (function (_super) { tslib_1.__extends(ArticleCommentsRoute, _super); function ArticleCommentsRoute(appOptions) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.findRoute = 'article-comments/{?searchQuery,statuses,page,rpp,sort,embed,fields}'; _this.getRoute = 'article-comments/{id}/{?embed,fields}'; _this.createRoute = 'article-comments/'; _this.updateRoute = 'article-comments/{id}'; _this.deleteRoute = 'article-comments/{id}'; _this.approveRoute = 'article-comments/{id}/approve'; _this.unapproveRoute = 'article-comments/{id}/unapprove'; _this.flagRoute = 'article-comments/{id}'; _this.unflagRoute = 'article-comments/{id}/unflag'; _this.reportRoute = 'article-comments/{id}/report'; _this.unreportRoute = 'article-comments/{id}/unreport'; return _this; } /** * Parses find route which can be expanded with additional options. Supported items are: * - `searchQuery` - A string value used to identify article comment resources using the phrase search. * - `page` - A value used to set the page number, i.e. to retrieve certain article comment subset from the storage. * - `rpp` - A value used to limit the size of result set per page. * - `sort` - A string used to set the article comment property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * - `statuses` - Comma separated list of article comment states that specify where search should be done (Allowed states: Approved, Spam, Reported, Flagged and UnApproved). * @method * @param options Query resource options object. * @example articleCommentsRoute.find({ searchQuery: '<search-phrase>' }); **/ ArticleCommentsRoute.prototype.find = function (options) { return _super.prototype.baseFind.call(this, this.findRoute, options); }; /** * Parses get route which can be expanded with additional options. Supported items are: * - `id` - Id which uniquely identifies article comment resource that needs to be retrieved. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @param id Id which uniquely identifies article comment resource that needs to be retrieved. * @param options Options object that contains embed data. * @example articleCommentsRoute.get().expand({ id: '<comment-id>' }); **/ ArticleCommentsRoute.prototype.get = function (id, options) { return _super.prototype.baseGet.call(this, this.getRoute, id, options); }; /** * Parses create route; this URI template doesnt support any additional options. * @method * @param data An article comment object that needs to be inserted into the system. * @example articleCommentsRoute.create(data); **/ ArticleCommentsRoute.prototype.create = function (data) { return _super.prototype.baseCreate.call(this, this.createRoute, data); }; /** * Parses update route; this URI template doesnt support any additional options. * @method An article comment object used to update specified article comment resource. * @example articleCommentsRoute.update(data); **/ ArticleCommentsRoute.prototype.update = function (data) { return _super.prototype.baseUpdate.call(this, this.updateRoute, data); }; /** * Parses delete route; this URI template doesnt support any additional options. * @method An article comment object used to delete specified article comment resource. * @example articleCommentsRoute.delete(data); **/ ArticleCommentsRoute.prototype.delete = function (data) { return _super.prototype.baseDelete.call(this, this.deleteRoute, data); }; /** * Parses approve route; this URI template doesnt support any additional options. * @method An article comment object. * @example articleCommentsRoute.approve(data); **/ ArticleCommentsRoute.prototype.approve = function (data) { return _super.prototype.baseUpdate.call(this, this.approveRoute, data, undefined, 'comment-approve'); }; /** * Parses unapprove route; this URI template doesnt support any additional options. * @method An article comment object. * @example articleCommentsRoute.unapprove(data); **/ ArticleCommentsRoute.prototype.unapprove = function (data) { return _super.prototype.baseUpdate.call(this, this.unapproveRoute, data, undefined, 'comment-unapprove'); }; /** * Parses flag route; this URI template doesnt support any additional options. * @method An article comment object. * @example articleCommentsRoute.flag(data); **/ ArticleCommentsRoute.prototype.flag = function (data) { return _super.prototype.baseUpdate.call(this, this.flagRoute, data, undefined, 'comment-flag'); }; /** * Parses unflag route; this URI template doesnt support any additional options. * @method An article comment object. * @example articleCommentsRoute.unflag(data); **/ ArticleCommentsRoute.prototype.unflag = function (data) { return _super.prototype.baseUpdate.call(this, this.unflagRoute, data, undefined, 'comment-unflag'); }; /** * Parses report route; this URI template doesnt support any additional options. * @method An article comment object. * @example articleCommentsRoute.report(data); **/ ArticleCommentsRoute.prototype.report = function (data) { return _super.prototype.baseUpdate.call(this, this.reportRoute, data, undefined, 'comment-report'); }; /** * Parses unreport route; this URI template doesnt support any additional options. * @method An article comment object. * @example articleCommentsRoute.unreport(data); **/ ArticleCommentsRoute.prototype.unreport = function (data) { return _super.prototype.baseUpdate.call(this, this.unreportRoute, data, undefined, 'comment-unreport'); }; ArticleCommentsRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [Object]) ], ArticleCommentsRoute); return ArticleCommentsRoute; }(common_1.BaseRoute)); exports.ArticleCommentsRoute = ArticleCommentsRoute; /** * @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. - [URI Template](https://github.com/Baasic/uritemplate-js) syntax enables expanding the Baasic route templates to Baasic REST URIs providing it with an object that contains URI parameters. - All end-point objects are transformed by the associated route service. */