UNPKG

baasic-sdk-angularjs

Version:

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

1,013 lines 79.2 kB
/* globals module */ /** * @module baasicArticleService * @description Baasic Articles Service provides an easy way to consume Baasic Articles REST API end-points. In order to obtain needed routes `baasicArticleService` uses `baasicArticleRouteService`. */ (function (angular, module, undefined) { 'use strict'; module.service('baasicArticleService', ['baasicApp', function (baasicApps) { var baasicApp = baasicApps.get(); return { /** * Contains a reference to valid list of article statuses. It returns an object containing all article statuses: `{ draft: 1, published: 2, archive: 4 }` * @method * @example baasicArticleService.statuses.archive; **/ statuses: baasicApp.articleModule.articles.statuses, /** * Parses article object and updates slug of an article. * @method * @example baasicArticleService.updateSlug(article); **/ updateSlug: function (article) { return baasicApp.articleModule.articles.articleUtility.updateSlug(article); }, /** * Generates and returns a valid slug url string. * @method * @example baasicArticleService.toSlug('<slug>'); **/ toSlug: function (slug) { return baasicApp.articleModule.articles.articleUtility.toSlug(slug); }, /** * Returns a promise that is resolved once the find action has been performed. Success response returns a list of article resources matching the given criteria. * @method * @example baasicArticleService.find({ pageNumber : 1, pageSize : 10, orderBy : '<field>', orderDirection : '<asc|desc>', search : '<search-phrase>' }) .success(function (collection) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ find: function (options) { return baasicApp.articleModule.articles.find(options); }, /** * Returns a promise that is resolved once the get action has been performed. Success response returns a single article resource. * @method * @example baasicArticleService.get('<article-id>') .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ get: function (id, options) { return baasicApp.articleModule.articles.get(id, options); }, /** * Returns a promise that is resolved once the create article action has been performed, this action creates a new article resource. * @method * @example baasicArticleService.create({ publishDate : new Date(), title : '<title>', content : '<content>', slug : '', status : baasicArticleService.statuses.draft, $tags : ['<tag1>', '<tag2>'] }) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ create: function (data) { return baasicApp.articleModule.articles.create(data); }, /** * Returns a promise that is resolved once the update article action has been performed; this action updates an article resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(article); var uri = params['model'].links('put').href; ``` * @method * @example // article is a resource previously fetched using get action. article.title = '<title>'; baasicArticleService.update(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ update: function (data) { return baasicApp.articleModule.articles.update(data); }, /** * Returns a promise that is resolved once the saveDraft article action has been performed. This action saves an article with "draft" status. If an article does not exist it will create a new article resource otherwise it will update an existing article resource. * @method * @example // article is a resource previously fetched using get action. baasicArticleService.saveDraft(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ saveDraft: function (data) { if (angular.isUndefined(data.id)) { //Create new draft return this.create(data); } //Update draft return this.update(data); }, /** * Returns a promise that is resolved once the remove article action has been performed. If the action is successfully completed, the article resource will be permanently removed from the system. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(article); var uri = params['model'].links('delete').href; ``` * @method * @example // article is a resource previously fetched using get action. baasicArticleService.remove(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ remove: function (data) { return baasicApp.articleModule.articles.remove(data); }, /** * Returns a promise that is resolved once the archive article action has been performed. This action sets the status of an article from "published" to "archive". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(article); var uri = params['model'].links('archive').href; ``` * @method * @example // article is a resource previously fetched using get action. baasicArticleService.archive(article, articleOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ archive: function (data, options) { return baasicApp.articleModule.articles.archive(data, options); }, /** * Returns a promise that is resolved once the restore article action has been performed. This action sets the status of an article from "archive" to "published". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(article); var uri = params['model'].links('restore').href; ``` * @method * @example // article is a resource previously fetched using get action. baasicArticleService.restore(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ restore: function (data) { return baasicApp.articleModule.articles.restore(data); }, /** * Returns a promise that is resolved once the unpublish article action has been performed. This action sets the status of an article from "published" to "draft". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(article); var uri = params['model'].links('unpublish').href; ``` * @method * @example // article is a resource previously fetched using get action. baasicArticleService.unpublish(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unpublish: function (data) { return baasicApp.articleModule.articles.unpublish(data); }, /** * Returns a promise that is resolved once the publish article action has been performed. This action sets the status of an article from "draft" to "published". * @method * @example baasicArticleService.publish(article, articleOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ publish: function (article, articleOptions) { return baasicApp.articleModule.articles.publish(article, articleOptions); }, /** * Returns a promise that is resolved once the purge articles action has been performed. Please note that all article resources will be deleted from the system once the action is successfully completed and therefore it can only be executed by user assigned to account owner role. * @method * @example baasicArticleService.purge({}) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ purge: function (options) { return baasicApp.articleModule.articles.purge(options); }, subscriptions: { articleModule: { /** * Returns a promise that is resolved once the subscribe action has been performed. This action subscribes an user to the article module. * @method subscriptions.articleModule.subscribe * @example baasicArticleService.subscriptions.articleModule.subscribe(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ subscribe: function (data) { return baasicApp.articleModule.subscriptions.subscribe(data); }, /** * Returns a promise that is resolved once the isSubscribed action has been performed. This action checks if a user is subscribed to the article module. * @method subscriptions.articleModule.isSubscribed * @example baasicArticleService.subscriptions.articleModule.isSubscribed(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ isSubscribed: function (data) { return baasicApp.articleModule.subscriptions.isSubscribed(data); }, /** * Returns a promise that is resolved once the unSubscribe action has been performed. This action unsubscribes a user from the article module. * @method subscriptions.articleModule.unSubscribe * @example baasicArticleService.subscriptions.articleModule.unSubscribe(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unSubscribe: function (data) { return baasicApp.articleModule.subscriptions.unSubscribe(data); } }, article: { /** * Returns a promise that is resolved once the subscribe action has been performed. This action subscribes an user to the specified article. * @method subscriptions.article.subscribe * @example baasicArticleService.subscriptions.article.subscribe(article, user) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ subscribe: function (article, data) { return baasicApp.articleModule.articles.subscriptions.subscribe(article, data); }, /** * Returns a promise that is resolved once the isSubscribed action has been performed. This action checks if a user is subscribed to the specified article. * @method subscriptions.article.isSubscribed * @example baasicArticleService.subscriptions.article.isSubscribed(article, user) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ isSubscribed: function (article, data) { return baasicApp.articleModule.articles.subscriptions.isSubscribed(article, data); }, /** * Returns a promise that is resolved once the unSubscribe action has been performed. This action unsubscribes a user from the specified article. * @method subscriptions.article.unSubscribe * @example baasicArticleService.subscriptions.article.unSubscribe(article, user) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unSubscribe: function (article, data) { return baasicApp.articleModule.articles.subscriptions.unSubscribe(article, data); } }, commentReported: { /** * Returns a promise that is resolved once the subscribe action has been performed. * @method subscriptions.commentReported.subscribe * @example baasicArticleService.subscriptions.commentReported.subscribe(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ subscribe: function (data) { return baasicApp.articleModule.articles.subscriptions.commentReported.subscribe(data); }, /** * Returns a promise that is resolved once the isSubscribed action has been performed. * @method subscriptions.commentReported.isSubscribed * @example baasicArticleService.subscriptions.commentReported.isSubscribed(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ isSubscribed: function (data) { return baasicApp.articleModule.articles.subscriptions.commentReported.isSubscribed(data); }, /** * Returns a promise that is commentReported once the unSubscribe action has been performed. * @method subscriptions.commentReported.unSubscribe * @example baasicArticleService.subscriptions.commentReported.unSubscribe(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unSubscribe: function (data) { return baasicApp.articleModule.articles.subscriptions.commentReported.unSubscribe(data); } }, commentRequiresModeration: { /** * Returns a promise that is resolved once the subscribe action has been performed. * @method subscriptions.commentRequiresModeration.subscribe * @example baasicArticleService.subscriptions.commentRequiresModeration.subscribe(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ subscribe: function (data) { return baasicApp.articleModule.articles.subscriptions.commentRequiresModeration.subscribe(data); }, /** * Returns a promise that is resolved once the isSubscribed action has been performed. * @method subscriptions.commentRequiresModeration.isSubscribed * @example baasicArticleService.subscriptions.commentRequiresModeration.isSubscribed(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ isSubscribed: function (data) { return baasicApp.articleModule.articles.subscriptions.commentRequiresModeration.isSubscribed(data); }, /** * Returns a promise that is commentReported once the unSubscribe action has been performed. * @method subscriptions.commentRequiresModeration.unSubscribe * @example baasicArticleService.subscriptions.commentRequiresModeration.unSubscribe(data) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unSubscribe: function (data) { return baasicApp.articleModule.articles.subscriptions.commentRequiresModeration.unSubscribe(data); } } }, ratings: { /** * Returns a promise that is resolved once the get action has been performed. Success response returns the specified article rating resource. * @method ratings.get * @example baasicArticleService.ratings.get('<article-id>', '<rating-id>') .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ get: function (articleId, ratingId, options) { return baasicApp.articleModule.articles.ratings.get(articleId, ratingId, options); }, /** * Returns a promise that is resolved once the find action has been performed. Success response returns a list of article rating resources for a specified article. * @method ratings.find * @example baasicArticleService.ratings.find('<article-id>') .success(function (collection) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ find: function (articleId, options) { return baasicApp.articleModule.articles.ratings.find(articleId, options); }, /** * Returns a promise that is resolved once the findByUsername action has been performed. Success response returns a list of article rating resources filtered by username and article identifier. * @method ratings.findByUsername * @example baasicArticleService.ratings.findByUsername('<article-id>', '<username>') .success(function (collection) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ findByUsername: function (articleId, username, options) { return baasicApp.articleModule.articles.ratings.findByUser(articleId, username, options); }, /** * Returns a promise that is resolved once the create article rating action has been performed; this action creates a new rating for an article. * @method ratings.create * @example baasicArticleService.ratings.create({ articleId : '<article-id>', rating : 5, userId : '<user-id>' }) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ create: function (data) { return baasicApp.articleModule.articles.ratings.create(data); }, /** * Returns a promise that is resolved once the update article rating action has been performed; this action updates a rating of an article. * @method ratings.update * @example // article is a resource previously fetched using get action. article.rating = 4; baasicArticleService.update(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ update: function (data) { return baasicApp.articleModule.articles.ratings.update(data); }, /** * Returns a promise that is resolved once the remove article rating action has been performed. This action will remove a rating from an article if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(articleRating); var uri = params['model'].links('delete').href; ``` * @method ratings.remove * @example // articleRating is a resource previously fetched using get action. baasicArticleService.remove(articleRating) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ remove: function (data) { return baasicApp.articleModule.articles.ratings.remove(data); }, /** * Returns a promise that is resolved once the removeAll article rating action has been performed. If the action is successfully completed, the article rating resources will be permanently removed from the system for a specified article resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(article); var uri = params['model'].links('delete-ratings-by-article').href; ``` * @method ratings.removeAll * @example // article is a resource previously fetched using get action. baasicArticleService.removeAll(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ removeAll: function (data) { return baasicApp.articleModule.articles.ratings.removeAll(data); } }, tags: { /** * Returns a promise that is resolved once the find action has been performed. Success response returns a list of article tag resources matching the given criteria. * @method tags.find * @example baasicArticleService.tags.find('<article-id>') .success(function (collection) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ find: function (articleId, options) { return baasicApp.articleModule.articles.tags.find(articleId, options); }, /** * Returns a promise that is resolved once the get action has been performed. Success response returns the specified article tag resource. * @method tags.get * @example baasicArticleService.tags.get('<article-id>', '<tag>') .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ get: function (articleId, id, options) { return baasicApp.articleModule.articles.tags.get(articleId, id, options); }, /** * Returns a promise that is resolved once the create article tag action has been performed; this action creates a new tag for an article. * @method tags.create * @example baasicArticleService.tags.create({ articleId : '<article-id>', tag : { slug : '<slug>', sortOrder : 1, tag : '<tag>' } }) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ create: function (data) { return baasicApp.articleModule.articles.tags.create(data); }, /** * Returns a promise that is resolved once the remove article tag action has been performed. This action will remove a tag from an article if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(articleTag); var uri = params['model'].links('delete').href; ``` * @method tags.remove * @example // articleTag is a resource previously fetched using get action. baasicArticleService.tags.remove(articleTag) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ remove: function (data) { return baasicApp.articleModule.articles.tags.remove(data); }, /** * Returns a promise that is resolved once the removeAll article tag action has been performed. This action will remove all tags from an article if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(article); var uri = params['model'].links('delete-tags-by-article').href; ``` * @method tags.removeAll * @example // article is a resource previously fetched using get action. baasicArticleService.tags.removeAll(article) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ removeAll: function (data) { return baasicApp.articleModule.articles.tags.removeAll(data); } }, comments: { /** * Contains a reference to valid list of article comment states. It returns an object containing all article comment states. * @method comments.statuses * @example baasicArticleService.comments.statuses.approved; **/ statuses: baasicApp.articleModule.articles.comments.statuses, /** * Returns a promise that is resolved once the approve article comment action has been performed. This action sets the state of an article comment to "approved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-approve').href; ``` * @method comments.approve * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.approve(articleComment, commentOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ approve: function (data, options) { return baasicApp.articleModule.articles.comments.approve(data, options); }, /** * Returns a promise that is resolved once the unapprove article comment action has been performed. This action sets the state of an article comment to "unapproved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-unapprove').href; ``` * @method comments.unapprove * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.unapprove(articleComment, commentOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unapprove: function (data) { return baasicApp.articleModule.articles.comments.unapprove(data); }, /** * Returns a promise that is resolved once the create article comment action has been performed; this action creates a new comment for an article. * @method comments.create * @example baasicArticleService.comments.create({ articleId : '<article-id>', comment : <comment>, userId : '<user-id>' }) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ create: function (data) { return baasicApp.articleModule.articles.comments.create(data); }, /** * Returns a promise that is resolved once the find action has been performed. Success response returns a list of article comment resources matching the given criteria. * @method comments.find * @example baasicArticleService.comments.find('<article-id>', { pageNumber : 1, pageSize : 10, orderBy : '<field>', orderDirection : '<asc|desc>', search : '<search-phrase>' }) .success(function (collection) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ find: function (articleId, options) { return baasicApp.articleModule.articles.comments.find(articleId, options); }, /** * Returns a promise that is resolved once the flag article comment action has been performed. This action sets the state of an article comment to "flagged". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-flag').href; ``` * @method comments.flag * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.flag(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ flag: function (data) { return baasicApp.articleModule.articles.comments.flag(data); }, /** * Returns a promise that is resolved once the unflag article comment action has been performed. This action removes the "flagged" comment state. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-unflag').href; ``` * @method comments.unflag * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.unflag(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unflag: function (data) { return baasicApp.articleModule.articles.comments.unflag(data); }, /** * Returns a promise that is resolved once the get action has been performed. Success response returns the specified article comment resource. * @method comments.get * @example baasicArticleService.comments.get('<article-id>', '<comment-id>') .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ get: function (articleId, commentId, options) { return baasicApp.articleModule.articles.comments.get(articleId, commentId, options); }, /** * Returns a promise that is resolved once the remove article comment action has been performed. If the action is successfully completed, the article comment resource and its replies will be permanently removed from the system. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(articleComment); var uri = params['model'].links('delete').href; ``` * @method comments.remove * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.remove(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ remove: function (data) { return baasicApp.articleModule.articles.comments.remove(data); }, /** * Returns a promise that is resolved once the removeAll article comment action has been performed. This action will remove all comments and comment replies from an article if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.removeParams(articleComment); var uri = params['model'].links('delete-comments-by-article').href; ``` * @method comments.removeAll * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.removeAll(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ removeAll: function (data) { return baasicApp.articleModule.articles.comments.removeAll(data); }, /** * Returns a promise that is resolved once the report article comment action has been performed. This action sets the state of an article comment to "reported". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-report').href; ``` * @method comments.report * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.report(articleComment, commentOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ report: function (data, options) { return baasicApp.articleModule.articles.comments.report(data, options); }, /** * Returns a promise that is resolved once the unreport article comment action has been performed. This action removes the "reported" comment state. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-unreport').href; ``` * @method comments.unreport * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.unreport(articleComment, commentOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unreport: function (data) { return baasicApp.articleModule.articles.comments.unreport(data); }, /** * Returns a promise that is resolved once the mark as spam article comment action has been performed. This action sets the state of an article comment to "spam". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-spam').href; ``` * @method comments.spam * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.spam(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ spam: function (data) { return baasicApp.articleModule.articles.comments.spam(data); }, /** * Returns a promise that is resolved once the unspam article comment action has been performed. This action removes the "spam" comment state. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('comment-unspam').href; ``` * @method comments.unspam * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.unspam(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unspam: function (data) { return baasicApp.articleModule.articles.comments.unspam(data); }, /** * Returns a promise that is resolved once the update article comment action has been performed; this action updates an article comment resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleComment); var uri = params['model'].links('put').href; ``` * @method comments.update * @example // articleComment is a resource previously fetched using get action. baasicArticleService.comments.update(articleComment) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ update: function (data) { return baasicApp.articleModule.articles.comments.update(data); }, replies: { /** * Contains a reference to valid list of article comment reply states. It returns an object containing all article comment reply states. * @method comments.replies.statuses * @example baasicArticleService.comments.replies.statuses.approved; **/ statuses: baasicApp.articleModule.articles.comments.statuses, /** * Returns a promise that is resolved once the approve article comment reply action has been performed. This action sets the state of an article comment reply to "approved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleCommentReply); var uri = params['model'].links('comment-approve').href; ``` * @method comments.replies.approve * @example // articleCommentReply is a resource previously fetched using get action. baasicArticleService.comments.replies.approve(articleCommentReply, commentOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ approve: function (data, options) { return baasicApp.articleModule.articles.comments.replies.approve(data, options); }, /** * Returns a promise that is resolved once the unapprove article comment reply action has been performed. This action sets the state of an article comment reply to "unapproved". This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleRouteService` route template. Here is an example of how a route can be obtained from HAL enabled objects: ``` var params = baasicApiService.updateParams(articleCommentReply); var uri = params['model'].links('comment-unapprove').href; ``` * @method comments.replies.unapprove * @example // articleCommentReply is a resource previously fetched using get action. baasicArticleService.comments.replies.unapprove(articleCommentReply, commentOptions) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ unapprove: function (data) { return baasicApp.articleModule.articles.comments.replies.unapprove(data); }, /** * Returns a promise that is resolved once the create article comment reply action has been performed; this action creates a new comment reply for an article. * @method comments.replies.create * @example baasicArticleService.comments.replies.create('<article-id>', { commentId : '<comment-id>', comment : <comment>, userId : '<user-id>' }) .success(function (data) { // perform success action here }) .error(function (response, status, headers, config) { // perform error handling here }); **/ create: function (articleId, data) { return baasicApp.articleModule.articles.comments.replies.create(data); }, /** * Returns a promise that is resolved once the find action has been performed. Success response returns a list of article comment reply resources matching the given criteria. * @method comments.replies.find * @example baasicArticleService.comments.replies.find('<article-id>, <comment-id>', { pageNumber : 1, pageSize : 10, orderBy : '<field>', orderDirection : '<asc|desc>', search : '<search-phrase>' }) .success(function (collection) { // perform success action here }) .error(fun