baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
201 lines (200 loc) • 11 kB
JavaScript
"use strict";
/* globals module */
/**
* @module articleInstanceCommentsRoute
* @description Baasic Article Instance Comments Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic Article Instance 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 __1 = require("../");
var ArticleInstanceCommentsRoute = /** @class */ (function (_super) {
tslib_1.__extends(ArticleInstanceCommentsRoute, _super);
function ArticleInstanceCommentsRoute(articleInstanceCommentRepliesRoute, appOptions) {
var _this = _super.call(this, appOptions) || this;
_this.articleInstanceCommentRepliesRoute = articleInstanceCommentRepliesRoute;
_this.appOptions = appOptions;
_this.findRoute = 'articles/{articleId}/comments/{?searchQuery,statuses,page,rpp,sort,embed,fields}';
_this.getRoute = 'articles/{articleId}/comments/{id}/{?embed,fields}';
_this.createRoute = 'articles/{articleId}/comments/';
_this.updateRoute = 'articles/{articleId}/comments/{id}';
_this.deleteRoute = 'articles/{articleId}/comments/{id}';
_this.deleteAllRoute = 'articles/{articleId}/comments/{id}';
_this.approveRoute = 'articles/{articleId}/comments/{id}/approve';
_this.unapproveRoute = 'articles/{articleId}/comments/{id}/unapprove';
_this.flagRoute = 'articles/{articleId}/comments/{id}/flag';
_this.unflagRoute = 'articles/{articleId}/comments/{id}/unflag';
_this.reportRoute = 'articles/{articleId}/comments/{id}/report';
_this.unreportRoute = 'articles/{articleId}/comments/{id}/unreport';
_this.spamRoute = 'articles/{articleId}/comments/{id}/spam';
_this.unspamRoute = 'articles/{articleId}/comments/{id}/unspam';
return _this;
}
Object.defineProperty(ArticleInstanceCommentsRoute.prototype, "replies", {
get: function () {
return this.articleInstanceCommentRepliesRoute;
},
enumerable: true,
configurable: true
});
/**
* 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 articleId Article slug or id which uniquely identifies article whose comment resources need to be retrieved.
* @param options Query resource options object.
* @example articleInstanceCommentsRoute.find({ searchQuery: '<search-phrase>' });
**/
ArticleInstanceCommentsRoute.prototype.find = function (articleId, options) {
var params = this.modelMapper.findParams(options);
params.articleId = articleId;
return _super.prototype.baseCreate.call(this, this.findRoute, params);
};
/**
* 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 articleId Article slug or id which uniquely identifies article whose comment resource needs to be retrieved.
* @param commentId Id which identifies article comment resource that needs to be retrieved.
* @param options Options object that contains embed data.
* @example articleInstanceCommentsRoute.get().expand({ id: '<comment-id>' });
**/
ArticleInstanceCommentsRoute.prototype.get = function (articleId, commentId, options) {
var params = this.utility.extend({}, options);
params.articleId = articleId;
params.id = commentId;
return _super.prototype.baseGet.call(this, this.getRoute, params);
};
/**
* 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 articleInstanceCommentsRoute.create(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comments object used to update specified article comment resource.
* @example articleInstanceCommentsRoute.update(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comments object used to delete specified article comment resource.
* @example articleInstanceCommentsRoute.delete(data);
**/
ArticleInstanceCommentsRoute.prototype.delete = function (data) {
return _super.prototype.baseDelete.call(this, this.deleteRoute, data);
};
/**
* Parses delete all route; this URI template doesnt support any additional options.
* @method
* @param data An article object used to delete specified article comment resource.
* @example articleInstanceCommentsRoute.deleteAll(data);
**/
ArticleInstanceCommentsRoute.prototype.deleteAll = function (data) {
return _super.prototype.baseDelete.call(this, this.deleteAllRoute, data, undefined, 'delete-comments-by-article');
};
/**
* Parses approve route; this URI template doesnt support any additional options.
* @method
* @param data An article comment object.
* @example articleInstanceCommentsRoute.approve(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comment object.
* @example articleInstanceCommentsRoute.unapprove(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comment object.
* @example articleInstanceCommentsRoute.flag(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comment object.
* @example articleInstanceCommentsRoute.unflag(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comment object.
* @example articleInstanceCommentsRoute.report(data);
**/
ArticleInstanceCommentsRoute.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
* @param data An article comment object.
* @example articleInstanceCommentsRoute.unreport(data);
**/
ArticleInstanceCommentsRoute.prototype.unreport = function (data) {
return _super.prototype.baseUpdate.call(this, this.unreportRoute, data, undefined, 'comment-unreport');
};
/**
* Parses spam route; this URI template doesnt support any additional options.
* @method
* @param data An article comment object.
* @example articleInstanceCommentsRoute.spam(data);
**/
ArticleInstanceCommentsRoute.prototype.spam = function (data) {
return _super.prototype.baseUpdate.call(this, this.spamRoute, data, undefined, 'comment-spam');
};
/**
* Parses unspam route; this URI template doesnt support any additional options.
* @method
* @param data An article comment object.
* @example articleInstanceCommentsRoute.unspam(data);
**/
ArticleInstanceCommentsRoute.prototype.unspam = function (data) {
return _super.prototype.baseUpdate.call(this, this.unspamRoute, data, undefined, 'comment-unspam');
};
ArticleInstanceCommentsRoute = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(__1.TYPES.ArticleInstanceCommentRepliesRoute)),
tslib_1.__param(1, inversify_1.inject(contracts_1.TYPES.IAppOptions)),
tslib_1.__metadata("design:paramtypes", [__1.ArticleInstanceCommentRepliesRoute, Object])
], ArticleInstanceCommentsRoute);
return ArticleInstanceCommentsRoute;
}(common_1.BaseRoute));
exports.ArticleInstanceCommentsRoute = ArticleInstanceCommentsRoute;
/**
* @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.
*/