Skip to content

services articleService

Baasic edited this page Jan 18, 2017 · 27 revisions

baasicArticleService

Baasic Articles Service provides an easy way to consume Baasic Articles REST API end-points. In order to obtain needed routes baasicArticleService uses baasicArticleRouteService.


baasicArticleService.statuses()

Contains a reference to valid list of article statuses. It returns an object containing all article statuses: { draft: 1, published: 2, archive: 4 }

Example:

baasicArticleService.statuses.archive;

baasicArticleService.updateSlug()

Parses article object and updates slug of an article.

Example:

baasicArticleService.updateSlug(article);

baasicArticleService.toSlug()

Generates and returns a valid slug url string.

Example:

baasicArticleService.toSlug('<slug>');

baasicArticleService.find()

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.

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
});    

baasicArticleService.get()

Returns a promise that is resolved once the get action has been performed. Success response returns a single article resource.

Example:

baasicArticleService.get('<article-id>')
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});

baasicArticleService.create()

Returns a promise that is resolved once the create article action has been performed, this action creates a new article resource.

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
});

baasicArticleService.update()

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;

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
});

baasicArticleService.saveDraft()

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.

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
});

baasicArticleService.remove()

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;

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
});		

baasicArticleService.archive()

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;

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
});		

baasicArticleService.restore()

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;

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
});		

baasicArticleService.unpublish()

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;

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
});		

baasicArticleService.publish()

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".

Example:

baasicArticleService.publish(article, articleOptions)
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});		

baasicArticleService.purge()

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.

Example:

baasicArticleService.purge({})
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});		

baasicArticleService.subscriptions.articleModule.subscribe()

Returns a promise that is resolved once the subscribe action has been performed. This action subscribes an user to the article module.

Example:

baasicArticleService.subscriptions.articleModule.subscribe(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.articleModule.isSubscribed()

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.

Example:

baasicArticleService.subscriptions.articleModule.isSubscribed(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.articleModule.unSubscribe()

Returns a promise that is resolved once the unSubscribe action has been performed. This action unsubscribes a user from the article module.

Example:

baasicArticleService.subscriptions.articleModule.unSubscribe(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.article.subscribe()

Returns a promise that is resolved once the subscribe action has been performed. This action subscribes an user to the specified article.

Example:

baasicArticleService.subscriptions.article.subscribe(article, user)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.article.isSubscribed()

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.

Example:

baasicArticleService.subscriptions.article.isSubscribed(article, user)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.article.unSubscribe()

Returns a promise that is resolved once the unSubscribe action has been performed. This action unsubscribes a user from the specified article.

Example:

baasicArticleService.subscriptions.article.unSubscribe(article, user)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.commentReported.subscribe()

Returns a promise that is resolved once the subscribe action has been performed.

Example:

baasicArticleService.subscriptions.commentReported.subscribe(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.commentReported.isSubscribed()

Returns a promise that is resolved once the isSubscribed action has been performed.

Example:

baasicArticleService.subscriptions.commentReported.isSubscribed(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.commentReported.unSubscribe()

Returns a promise that is commentReported once the unSubscribe action has been performed.

Example:

baasicArticleService.subscriptions.commentReported.unSubscribe(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.commentRequiresModeration.subscribe()

Returns a promise that is resolved once the subscribe action has been performed.

Example:

baasicArticleService.subscriptions.commentRequiresModeration.subscribe(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.commentRequiresModeration.isSubscribed()

Returns a promise that is resolved once the isSubscribed action has been performed.

Example:

baasicArticleService.subscriptions.commentRequiresModeration.isSubscribed(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.subscriptions.commentRequiresModeration.unSubscribe()

Returns a promise that is commentReported once the unSubscribe action has been performed.

Example:

baasicArticleService.subscriptions.commentRequiresModeration.unSubscribe(data)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.ratings.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the specified article rating resource.

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
});

baasicArticleService.ratings.find()

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.

Example:

baasicArticleService.ratings.find('<article-id>')
.success(function (collection) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});    

baasicArticleService.ratings.findByUsername()

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.

Example:

baasicArticleService.ratings.findByUsername('<article-id>', '<username>')
.success(function (collection) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});    

baasicArticleService.ratings.create()

Returns a promise that is resolved once the create article rating action has been performed; this action creates a new rating for an article.

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
});

baasicArticleService.ratings.update()

Returns a promise that is resolved once the update article rating action has been performed; this action updates a rating of an article.

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
});

baasicArticleService.ratings.remove()

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;

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
});		

baasicArticleService.ratings.removeAll()

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;

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
});		

baasicArticleService.tags.find()

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.

Example:

baasicArticleService.tags.find('<article-id>')
.success(function (collection) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});    

baasicArticleService.tags.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the specified article tag resource.

Example:

baasicArticleService.tags.get('<article-id>', '<tag>')
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicArticleService.tags.create()

Returns a promise that is resolved once the create article tag action has been performed; this action creates a new tag for an article.

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
});

baasicArticleService.tags.remove()

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;

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
});		

baasicArticleService.tags.removeAll()

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;

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
});		

baasicArticleService.comments.statuses()

Contains a reference to valid list of article comment states. It returns an object containing all article comment states.

Example:

baasicArticleService.comments.statuses.approved;

baasicArticleService.comments.approve()

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;

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
});		

baasicArticleService.comments.unapprove()

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;

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
});		

baasicArticleService.comments.create()

Returns a promise that is resolved once the create article comment action has been performed; this action creates a new comment for an article.

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
});

baasicArticleService.comments.find()

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.

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
});    

baasicArticleService.comments.flag()

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;

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
});		

baasicArticleService.comments.unflag()

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;

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
});		

baasicArticleService.comments.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the specified article comment resource.

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
});

baasicArticleService.comments.remove()

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;

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
});		

baasicArticleService.comments.removeAll()

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;

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
});		

baasicArticleService.comments.report()

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;

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
});		

baasicArticleService.comments.unreport()

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;

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
});		

baasicArticleService.comments.spam()

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;

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
});		

baasicArticleService.comments.unspam()

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;

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
});		

baasicArticleService.comments.update()

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;

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
});		

baasicArticleService.comments.replies.statuses()

Contains a reference to valid list of article comment reply states. It returns an object containing all article comment reply states.

Example:

baasicArticleService.comments.replies.statuses.approved;

baasicArticleService.comments.replies.approve()

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;

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
});		

baasicArticleService.comments.replies.unapprove()

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;

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
});		

baasicArticleService.comments.replies.create()

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.

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
});

baasicArticleService.comments.replies.find()

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.

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(function (response, status, headers, config) {
  // perform error handling here
});    

baasicArticleService.comments.replies.flag()

Returns a promise that is resolved once the flag article comment reply action has been performed. This action sets the state of an article comment reply 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(articleCommentReply);
var uri = params['model'].links('comment-flag').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.flag(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.unflag()

Returns a promise that is resolved once the unflag article comment reply action has been performed. This action removes the "flagged" comment reply 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(articleCommentReply);
var uri = params['model'].links('comment-unflag').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.unflag(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the specified article comment reply resource.

Example:

baasicArticleService.comments.replies.get('<article-id>', '<comment-id>', '<comment-reply-id>')
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicArticleService.comments.replies.remove()

Returns a promise that is resolved once the remove article comment reply action has been performed. If the action is successfully completed, the article comment reply 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(articleCommentReply);
var uri = params['model'].links('delete').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.remove(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.removeAll()

Returns a promise that is resolved once the removeAll article comment reply action has been performed. This action will remove all comment replies from an article comment 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(articleCommentReply);
var uri = params['model'].links('delete-comments-by-article').href;

Example:

// articleCommentReply is a resource previously fetched using get action.					
baasicArticleService.comments.replies.removeAll(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.report()

Returns a promise that is resolved once the report article comment reply action has been performed. This action sets the state of an article comment reply 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(articleCommentReply);
var uri = params['model'].links('comment-report').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.report(articleCommentReply, commentOptions)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.unreport()

Returns a promise that is resolved once the unreport article comment reply action has been performed. This action removes the "reported" comment reply 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(articleCommentReply);
var uri = params['model'].links('comment-unreport').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.unreport(articleCommentReply, commentOptions)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.spam()

Returns a promise that is resolved once the mark as spam article comment reply action has been performed. This action sets the state of an article comment reply 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(articleCommentReply);
var uri = params['model'].links('comment-spam').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.spam(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.unspam()

Returns a promise that is resolved once the unspam article comment reply action has been performed. This action removes the "spam" comment reply 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(articleCommentReply);
var uri = params['model'].links('comment-unspam').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.unspam(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.comments.replies.update()

Returns a promise that is resolved once the update article comment reply action has been performed; this action updates an article comment reply 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(articleCommentReply);
var uri = params['model'].links('put').href;

Example:

// articleCommentReply is a resource previously fetched using get action.				 
baasicArticleService.comments.replies.update(articleCommentReply)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		

baasicArticleService.files.find()

Returns a promise that is resolved once the find action has been performed. Success response returns a list of file resources matching the given criteria.

Example:

baasicArticleService.files.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
});    

baasicArticleService.files.get()

Returns a promise that is resolved once the get action has been performed. Success response returns requested file resource.

Example:

baasicArticleService.files.get('<article-id>', '<file-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.unlink()

Returns a promise that is resolved once the unlink action has been performed. This action will remove one or many file resources from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicArticleService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.removeParams(fileEntry);
var uri = params['model'].links('unlink').href;

Example:

// fileEntry is a file resource previously fetched using get action. The following action will remove the original file resource and all accompanying derived file resources.			 
baasicArticleService.files.unlink(fileEntry)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.unlinkByArticle()

Returns a promise that is resolved once the unlink by article action has been performed. This action will remove all file resources from the system related to the requested article if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicArticleService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.removeParams(fileEntry);
var uri = params['model'].links('unlink-by-article').href;

Example:

// fileEntry is a file resource previously fetched using get action.		 
baasicArticleService.files.unlinkByArticle(fileEntry)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.update()

Returns a promise that is resolved once the update file action has been performed; this action will update a file resource if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicArticleService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.updateParams(fileEntry);
var uri = params['model'].links('put').href;

Example:

// fileEntry is a file resource previously fetched using get action.
fileEntry.description = '<description>';
baasicArticleService.files.update(fileEntry)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.link()

Returns a promise that is resolved once the link action has been performed; this action links file resource from other modules into the Article Files module (For example: file resources from the Media Vault module can be linked directly into the Article Files module).

Example:

baasicArticleService.files.link(fileObject)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.streams.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the file stream if successfully completed. If derived resource's format is passed, such as width and height for the image type of file resource, the operation will return a stream of the derived resource. Otherwise, stream of the original file resource will be retrieved.

Example:

// Request the original file stream              
baasicArticleService.files.streams.get({id: '<file-id>'})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});                    
// Request derived file stream                
baasicArticleService.files.streams.get({id: '<file-id>', width: <width>, height: <height>})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.streams.getBlob()

Returns a promise that is resolved once the get action has been performed. Success response returns the file stream as a blob. If derived resource's format is passed, such as width and height for the image type of file resource, the operation will return a blob of the derived file resource. Otherwise, blob of the original file resource will be retrieved. For more information on Blob objects please see Blob Documentation.

Example:

// Request the original blob                
baasicArticleService.files.streams.getBlob('<article-id>', '<file-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
// Request derived blob                 
baasicArticleService.files.streams.getBlob('<article-id>', {id: '<file-id>', width: <width>, height: <height>})
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.streams.update()

Returns a promise that is resolved once the update file stream action has been performed; this action will replace the existing stream with a new one. Alternatively, if a derived stream is being updated it will either create a new derived stream or replace the existing one. In order to update a derived stream, format needs to be passed (For example: width and height for the image type of file stream data type).

Example:

// Update original file stream 
baasicArticleService.files.streams.update('<article-id>', '<file-id>', <file-stream>)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
// Update derived file stream 
baasicArticleService.files.streams.update('<article-id>', {id: '<file-id>', width: <width>, height: <height>}, <file-stream>)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.streams.create()

Returns a promise that is resolved once the create file stream action has been performed; this action will upload the specified blob. For more information on Blob objects please see Blob Documentation.

Example:

baasicArticleService.files.streams.create('<article-id>', '<filename>', <blob>)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.batch.unlink()

Returns a promise that is resolved once the unlink action has been performed. This action will remove file resources from the system if successfully completed. Specified file and all its accompanying derived resources will be removed from the system.

Example:

// Remove original file resources                
baasicArticleService.files.batch.unlink('<article-id>', [{ id: '<file-id>' }])
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});		  

baasicArticleService.files.batch.update()

Returns a promise that is resolved once the update action has been performed; this action updates specified file resources.

Example:

baasicArticleService.batch.update('<article-id>', files)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.files.batch.link()

Returns a promise that is resolved once the link action has been performed; this action links file resources from other modules into the Article Files module (For example: file resources from the Media Vault module can be linked directly into the Article Files module).

Example:

baasicArticleService.batch.link(files)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});

baasicArticleService.acl.get()

Returns a promise that is resolved once the get action has been performed. Success response returns a list of ACL policies established for the specified article resource.

Example:

baasicArticleService.acl.get({id: '<article-id>'})
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicArticleService.acl.update()

Returns a promise that is resolved once the update acl action has been performed, this action creates new ACL policy for the specified article resource.

Example:

var options = {id : '<article-id>'};
var aclObj =  {
 actionId: '<action-id'>,
 roleId: '<roleId>',
 userId: '<userId>'
};
options[baasicConstants.modelPropertyName] = aclObj;
baasicArticleService.acl.update(options)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicArticleService.acl.deleteByUser()

Returns a promise that is resolved once the removeByUser action has been performed. This action deletes ACL policy assigned to the specified user and article resource.

Example:

baasicArticleService.acl.removeByUser('<article-id>', '<access-action>', '<username>')
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicArticleService.acl.deleteByRole()

Returns a promise that is resolved once the removeByRole action has been performed. This action deletes ACL policy assigned to the specified role and article resource.

Example:

baasicArticleService.acl.removeByRole('<article-id>', '<access-action>', '<role-name>')
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});

baasicArticleService.routeService()

Provides direct access to baasicArticleRouteService.

Example:

baasicArticleService.routeService.get.expand(expandObject);

Notes:

  • Refer to the Baasic REST API for detailed information about available Baasic REST API end-points.
  • All end-point objects are transformed by the associated route service.

(c) 2017 Mono Ltd

Author: Mono Ltd

License: MIT

Clone this wiki locally