UNPKG

baasic-sdk-javascript

Version:

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

131 lines (130 loc) 7.7 kB
"use strict"; /* globals module */ /** * @module articleInstanceRatingsRoute * @description Baasic Article Instance Ratings Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Article Sub Ratings 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 common_1 = require("../../../common"); ; var contracts_1 = require("../../../core/contracts"); var ArticleInstanceRatingsRoute = /** @class */ (function (_super) { tslib_1.__extends(ArticleInstanceRatingsRoute, _super); function ArticleInstanceRatingsRoute(appOptions) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.createRoute = 'articles/{articleId}/ratings/'; _this.findRoute = 'articles/{articleId}/ratings{?page,rpp,sort,embed,fields}'; _this.findByUserRoute = 'articles/{articleId}/users/{username}/ratings/{?embed,fields}'; _this.getRoute = 'articles/{articleId}/ratings/{id}/{?embed,fields}'; _this.updateRoute = 'articles/{articleId}/ratings/{id}'; _this.deleteRoute = 'articles/{articleId}/ratings/{id}'; _this.deleteAllRoute = 'articles/{articleId}/ratings'; return _this; } /** * Parses create article rating route; this URI does not support any additional embed items. * @method * @param data An article rating object that needs to be inserted into the system. * @example articleInstanceRatingsRoute.create(data); **/ ArticleInstanceRatingsRoute.prototype.create = function (data) { return _super.prototype.baseCreate.call(this, this.createRoute, data); }; /** * Parses find article rating route which can be expanded with additional options. Supported items are: * - `searchQuery` - A string referencing article rating properties using the phrase or BQL (Baasic Query Language) search. * - `page` - A value used to set the page number, i.e. to retrieve certain article rating 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 rating property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @param articleId Article slug or id which uniquely identifies article whose rating resources need to be retrieved. * @param options Query resource options object. * @example articleInstanceRatingsRoute.find({searchQuery: '<search-phrase>'}); **/ ArticleInstanceRatingsRoute.prototype.find = function (articleId, options) { var params = this.utility.extend({}, options); params.articleId = articleId; return _super.prototype.baseFind.call(this, this.findRoute, params); }; /** * Parses findByUser article rating route which can be expanded with additional options. Supported items are: * - `username` - A value that uniquely identifies a user which has created an article rating. * - `page` - A value used to set the page number, i.e. to retrieve certain article rating 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 rating property to sort the result collection by. * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @param articleId Article slug or id which uniquely identifies article whose rating resources need to be retrieved. * @param username Username which uniquely identifies a user which has created an article rating. * @param options Query resource options object. * @example articleInstanceRatingsRoute.find({username: '<username>'}); **/ ArticleInstanceRatingsRoute.prototype.findByUser = function (articleId, username, options) { var params = this.utility.extend({}, options); params.username = username; params.articleId = articleId; return _super.prototype.baseFind.call(this, this.findByUserRoute, params); }; /** * Parses get article rating route which must be expanded with the Id of the previously created article rating resource in the system. Additional expand supported items are: * - `embed` - Comma separated list of resources to be contained within the current representation. * @method * @param articleId Article slug or id which uniquely identifies article whose rating resources need to be retrieved. * @param id Article slug or id which uniquely identifies article resource that needs to be retrieved. * @param options Options object that contains embed data. * @example articleInstanceRatingsRoute.get({id: '<articleRating-id>'}); **/ ArticleInstanceRatingsRoute.prototype.get = function (articleId, id, options) { var params = this.utility.extend({}, options); params.articleId = articleId; return _super.prototype.baseGet.call(this, this.getRoute, id, params); }; /** * Parses update article rating route; this URI does not support any additional embed items. * @method * @param data An article object used to update specified article resource. * @example articleInstanceRatingsRoute.update(data); **/ ArticleInstanceRatingsRoute.prototype.update = function (data) { return _super.prototype.baseUpdate.call(this, this.updateRoute, data); }; /** * Parses delete article rating route; this URI does not support any additional embed items. * @method * @param data Rating resource resource that needs to be deleted. * @example articleInstanceRatingsRoute.delete(data); **/ ArticleInstanceRatingsRoute.prototype.delete = function (data) { return _super.prototype.baseDelete.call(this, this.deleteRoute, data); }; /** * Parses delete article rating route; this URI does not support any additional embed items. * @method * @param data Article object whose ratings needs to be deleted. * @example articleInstanceRatingsRoute.deleteAll(data); **/ ArticleInstanceRatingsRoute.prototype.deleteAll = function (data) { return _super.prototype.baseDelete.call(this, this.deleteAllRoute, data, undefined, 'delete-ratings-by-article'); }; ArticleInstanceRatingsRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [Object]) ], ArticleInstanceRatingsRoute); return ArticleInstanceRatingsRoute; }(common_1.BaseRoute)); exports.ArticleInstanceRatingsRoute = ArticleInstanceRatingsRoute; /** * @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. - [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. */