UNPKG

baasic-sdk-javascript

Version:

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

113 lines (112 loc) 6.31 kB
"use strict"; /* globals module */ /** * @module articleRatingsRoute * @description Baasic Article Ratings Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Article 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 ArticleRatingsRoute = /** @class */ (function (_super) { tslib_1.__extends(ArticleRatingsRoute, _super); function ArticleRatingsRoute(appOptions) { var _this = _super.call(this, appOptions) || this; _this.appOptions = appOptions; _this.createRoute = 'article-ratings'; _this.findRoute = 'article-ratings/{?searchQuery,page,rpp,sort,embed,fields}'; _this.findByUserRoute = 'article-ratings/{?username,page,rpp,sort,embed,fields}'; _this.getRoute = 'article-ratings/{id}/{?embed,fields}'; _this.updateRoute = 'article-ratings/{id}'; _this.deleteRoute = 'article-ratings/{id}'; 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 articleRatingsRoute.create(data); **/ ArticleRatingsRoute.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 options Query resource options object. * @example articleRatingsRoute.find({searchQuery: '<search-phrase>'}); **/ ArticleRatingsRoute.prototype.find = function (options) { return _super.prototype.baseFind.call(this, this.findRoute, options); }; /** * 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 username Username which uniquely identifies a user which has created an article rating. * @param options Query resource options object. * @example articleRatingsRoute.find({username: '<username>'}); **/ ArticleRatingsRoute.prototype.findByUser = function (username, options) { var params = this.utility.extend({}, options); params.username = username; 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 id Id which uniquely identifies article rating resource that needs to be retrieved. * @param options Options object that contains embed data. * @example articleRatingsRoute.get({id: '<articleRating-id>'}); **/ ArticleRatingsRoute.prototype.get = function (id, options) { return _super.prototype.baseGet.call(this, this.getRoute, id, options); }; /** * 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 rating resource. * @example articleRatingsRoute.update(data); **/ ArticleRatingsRoute.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 An article object used to delete specified article rating resource. * @example articleRatingsRoute.delete(data); **/ ArticleRatingsRoute.prototype.delete = function (data) { return _super.prototype.baseDelete.call(this, this.deleteRoute, data); }; ArticleRatingsRoute = tslib_1.__decorate([ inversify_1.injectable(), tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)), tslib_1.__metadata("design:paramtypes", [Object]) ], ArticleRatingsRoute); return ArticleRatingsRoute; }(common_1.BaseRoute)); exports.ArticleRatingsRoute = ArticleRatingsRoute; /** * @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. */