baasic-sdk-angularjs
Version:
AngularJS SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
169 lines (117 loc) • 5.01 kB
Markdown
# baasicArticleTagsService
Baasic Article Tags Service provides an easy way to consume Baasic Article Tags REST API end-points. `baasicArticleTagsService` functions enable performing standard CRUD operations directly on article tag resources, whereas the `baasicArticleService` functions allow management between article and article tag. In order to obtain needed routes `baasicArticleTagsService` uses `baasicArticleTagsRouteService`.
* * *
### baasicArticleTagsService.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**:
```js
baasicArticleTagsService.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
});
```
### baasicArticleTagsService.get()
Returns a promise that is resolved once the get action has been performed. Success response returns the specified article tag resource.
**Example**:
```js
baasicArticleTagsService.get('<articleTag-id>')
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
```
### baasicArticleTagsService.update()
Returns a promise that is resolved once the update article tag action has been performed; this action updates a tag. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleTagsRouteService` 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('put').href;
```
**Example**:
```js
// articleTag is a resource previously fetched using get action.
articleTag.tag = '<new-tag>';
baasicArticleTagsService.update(articleTag)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
```
### baasicArticleTagsService.remove()
Returns a promise that is resolved once the remove article tag action has been performed. If the action is successfully completed, the article tag resource will be permanently removed from the system. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply `baasicArticleTagsRouteService` 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**:
```js
// articleTag is a resource previously fetched using get action.
baasicArticleTagsService.remove(articleTag)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
```
### baasicArticleTagsService.routeService()
Provides direct access to `baasicArticleTagsRouteService`.
**Example**:
```js
baasicArticleTagsService.routeService.get(expandObject);
```
### baasicArticleTagsService.subscriptions.subscribe()
Returns a promise that is resolved once the subscribe action has been performed. This action subscribes an user to the specified tag.
**Example**:
```js
baasicArticleTagsService.subscriptions.subscribe(tag, user)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
```
### baasicArticleTagsService.subscriptions.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 tag.
**Example**:
```js
baasicArticleTagsService.subscriptions.isSubscribed(tag, user)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
```
### baasicArticleTagsService.subscriptions.unSubscribe()
Returns a promise that is resolved once the unSubscribe action has been performed. This action unsubscribes a user from the specified tag.
**Example**:
```js
baasicArticleTagsService.subscriptions.unSubscribe(tag, user)
.success(function (data) {
// perform success action here
})
.error(function (response, status, headers, config) {
// perform error handling here
});
```
* * *
**Notes:**
- Refer to the [Baasic REST API](http://dev.baasic.com/api/reference/home) 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