# baasicRoleService

Baasic Role Service provides an easy way to consume Baasic Role REST API end-points.



* * *

### baasicRoleService.find() 

Returns a promise that is resolved once the find action has been performed. Success response returns a list of role resources matching the given criteria.


**Example**:
```js
baasicRoleService.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
});    
```


### baasicRoleService.get() 

Returns a promise that is resolved once the get action has been performed. Success response returns the specified role resource.


**Example**:
```js
baasicRoleService.get('<role-id>')
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});
```


### baasicRoleService.create() 

Returns a promise that is resolved once the create action has been performed; this action creates a role.


**Example**:
```js
baasicRoleService.create({
  description : '<description>',
  name : '<name>'
})
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});
```


### baasicRoleService.update() 

Returns a promise that is resolved once the update role action has been performed; this action updates a role.


**Example**:
```js
// role is a resource previously fetched using get action.
role.name = '<new-name>';
baasicRoleService.update(role)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});
```


### baasicRoleService.remove() 

Returns a promise that is resolved once the remove role action has been performed. This action will remove a role from the system, if completed successfully.


**Example**:
```js
// Role is a resource previously fetched using get action.				 
baasicRoleService.remove(role)
.success(function (data) {
  // perform success action here
})
.error(function (response, status, headers, config) {
  // perform error handling here
});		
```


### baasicRoleService.batch.create(data) 

Returns a promise that is resolved once the create action has been performed; this action creates specified role resources.

**Parameters**

**data**: , A collection of role objects that needs to be created.

**Returns**: , A promise that is resolved once the create action has been performed.

**Example**:
```js
baasicRoleService.batch.create(files)
                        .then(function (data) {   
                            // perform success action here 
                        },
                        function (response, status, headers, config) {   
                            // perform error handling here 
                        });                   
```


### baasicRoleService.batch.update(data) 

Returns a promise that is resolved once the update action has been performed; this action updates specified role resources.

**Parameters**

**data**: , A collection of role objects used to update specified role resources.

**Returns**: , A promise that is resolved once the update action has been performed.

**Example**:
```js
baasicRoleService.batch.update(files)
                            .then(function (data) {   
                                // perform success action here 
                            },
                            function (response, status, headers, config) {   
                                // perform error handling here 
                            });                   
```


### baasicRoleService.batch.remove(data) 

Returns a promise that is resolved once the remove action has been performed; this action removes specified role resources.

**Parameters**

**data**: , A collection of role objects that needs to be removed.

**Returns**: , A promise that is resolved once the remove action has been performed.

**Example**:
```js
baasicRoleService.batch.remove(files)
                            .then(function (data) {   
                                // perform success action here 
                            },
                            function (response, status, headers, config) {   
                                // perform error handling here 
                            });                   
```


### baasicRoleService.routeService() 

Provides direct access to route definition.


**Example**:
```js
baasicRoleService.routeService.get('<id>', expandObject);
```



* * *

**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.







