baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
167 lines (166 loc) • 8.95 kB
JavaScript
"use strict";
/* globals module */
/**
* @module blogPostRoute
* @description Baasic Blog Route Definition provides Baasic route templates which can be expanded to Baasic REST URIs. Various services can use Baasic blogPost 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 BlogPostRoute = /** @class */ (function (_super) {
tslib_1.__extends(BlogPostRoute, _super);
function BlogPostRoute(appOptions) {
var _this = _super.call(this, appOptions) || this;
_this.appOptions = appOptions;
_this.findRoute = 'blog/blog-posts/{?searchQuery,ids,from,to,publishedFrom,publishedTo,url,template,blogPostPostStatusIds,languageIds,blogPostSlugs,tagSlugs,page,rpp,sort,embed,fields}';
_this.getRoute = 'blog/blog-posts/{id}/{?embed,fields}';
_this.purgeRoute = 'blog/blog-posts/purge';
_this.createRoute = 'blog/blog-posts';
_this.updateRoute = 'blog/blog-posts/{id}';
_this.publishRoute = 'blog/blog-posts/{id}/publish';
_this.rejectRoute = 'blog/blog-posts/{id}/reject';
_this.reviewPendingRoute = 'blog/blog-posts/{id}/review-pending';
_this.unpublishRoute = 'blog/blog-posts/{id}/unpublish';
_this.archiveRoute = 'blog/blog-posts/{id}/archive';
_this.draftRoute = 'blog/blog-posts/{id}/draft';
_this.deleteRoute = 'blog/blog-posts/{id}';
return _this;
}
/**
* Parses find blogPost route which can be expanded with additional options. Supported items are:
* - `searchQuery` - A string referencing blogPost properties using the phrase or BQL (Baasic Query Language) search.
* - `page` - A value used to set the page number, i.e. to retrieve certain blogPost subset from the storage.
* - `rpp` - A value used to limit the size of result set per page.
* - `sort` - A string used to set the blogPost property to sort the result collection by.
* - `embed` - Comma separated list of resources to be contained within the current representation.
* - `startDate` - A value used to specify the blogPost creation, publish or archive date date starting from which blogPost resource collection should be returned.
* - `endDate` - A value used to specify the blogPost creation, publish or archive date until (and including) which blogPost resource collection should be returned.
* - `statuses` - Comma separated list of blogPost statuses that specify where search should be done (Allowed statuses: Published, Draft and Archived).
* - `tags` - A value used to restrict the search to blogPost resources with these tags. Multiple tags should be comma separated.
* @method
* @param options A promise that is resolved once the find action has been performed.
* @example blogPostRoute.find.expand({searchQuery: '<search-phrase>'});
**/
BlogPostRoute.prototype.find = function (options) {
var opt = options || {};
return _super.prototype.baseFind.call(this, this.findRoute, opt);
};
/**
* Parses get blogPost route which must be expanded with the Id of the previously created blogPost 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 blogPost slug or id which uniquely identifies blogPost resource that needs to be retrieved.
* @param options Options object that contains embed items.
* @example blogPostRoute.get({id: '<blogPost-id>'});
**/
BlogPostRoute.prototype.get = function (id, options) {
return _super.prototype.baseGet.call(this, this.getRoute, id, options);
};
/**
* Parses publish blog post route which must be expanded with the Id of the previously created blog post resource in the system.
* @method
* @param data An blog post object.
* @example blogPostRoute.publish.expand({id: '<blog-post-id>'});
**/
BlogPostRoute.prototype.publish = function (data) {
return _super.prototype.baseUpdate.call(this, this.publishRoute, data);
};
/**
* Parses unpublish blog post route which must be expanded with the Id of the previously created blog post resource in the system.
* @method
* @param data An blog post object.
* @example blogPostRoute.unpublish.expand({id: '<blog-post-id>'});
**/
BlogPostRoute.prototype.unPublish = function (data) {
return _super.prototype.baseUpdate.call(this, this.unpublishRoute, data);
};
/**
* Parses draft blog post route which must be expanded with the Id of the previously created blog post resource in the system.
* @method
* @param data An blog post object.
* @example blogPostRoute.draft.expand({id: '<blog-post-id>'});
**/
BlogPostRoute.prototype.draft = function (data) {
return _super.prototype.baseUpdate.call(this, this.draftRoute, data);
};
/**
* Parses reject blog post route which must be expanded with the Id of the previously created blog post resource in the system.
* @method
* @param data An blog post object.
* @example blogPostRoute.reject.expand({id: '<blog-post-id>'});
**/
BlogPostRoute.prototype.reject = function (data) {
return _super.prototype.baseUpdate.call(this, this.rejectRoute, data);
};
/**
* Parses archive blog post route which must be expanded with the Id of the previously created blog post resource in the system.
* @method
* @param data An blog post object.
* @example blogPostRoute.archive.expand({id: '<blog-post-id>'});
**/
BlogPostRoute.prototype.archive = function (data) {
return _super.prototype.baseUpdate.call(this, this.archiveRoute, data);
};
/**
* Parses review pending blog post route which must be expanded with the Id of the previously created blog post resource in the system.
* @method
* @param data An blog post object.
* @example blogPostRoute.reviewPending.expand({id: '<blog-post-id>'});
**/
BlogPostRoute.prototype.reviewPending = function (data) {
return _super.prototype.baseUpdate.call(this, this.reviewPendingRoute, data);
};
/**
* Parses purge blogPost route, this URI template doesn't expose any additional properties.
* @method
* @example blogPostRoute.purge();
**/
BlogPostRoute.prototype.purge = function () {
return _super.prototype.baseDelete.call(this, this.purgeRoute, {});
};
/**
* Parses create blogPost route; this URI template doesn't expose any additional properties.
* @method
* @example blogPostRoute.create();
**/
BlogPostRoute.prototype.create = function () {
return _super.prototype.baseCreate.call(this, this.createRoute, {});
};
/**
* Parses update blogPost route; this URI template doesn't expose any additional properties.
* @method
* @param data An blogPost object that needs to be updated into the system.
* @example blogPostRoute.update(data);
**/
BlogPostRoute.prototype.update = function (data) {
return _super.prototype.baseUpdate.call(this, this.updateRoute, data);
};
/**
* Parses delete blogPost route; this URI template doesn't expose any additional properties.
* @method
* @param data An blogPost object that needs to be removed from the system.
* @example blogPostRoute.delete(data);
**/
BlogPostRoute.prototype.delete = function (data) {
return _super.prototype.baseDelete.call(this, this.deleteRoute, data);
};
BlogPostRoute = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__param(0, inversify_1.inject(contracts_1.TYPES.IAppOptions)),
tslib_1.__metadata("design:paramtypes", [Object])
], BlogPostRoute);
return BlogPostRoute;
}(common_1.BaseRoute));
exports.BlogPostRoute = BlogPostRoute;
/**
* @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.
*/