RoleService
Extends:
Service handling UserRole calls with specific endpoints.
Constructor Summary
Public Constructor | ||
public |
Update type to be user_roles |
Method Summary
Public Methods | ||
public |
|
|
public |
async deletePermission(permission: Permission, cacheMode: String): Promise |
|
public |
|
|
public |
getAuthorizableResources(): Promise<[Object]> |
|
public |
|
|
public |
async getPermissions(role: Object, options: String): Promise<Permission[]|Permission> |
|
public |
|
|
public |
async insertPermission(permission: Permission, cacheMode: String): Promise<Permission> |
|
public |
|
Inherited Summary
From class AbstractService | ||
public get |
|
|
public set |
|
|
public |
|
|
private |
|
From class JsonApiService | ||
public |
options: * |
|
public |
Call a DELETE request on the main obj.type expecting JSON API information. |
|
public |
Call a GET request expecting JSON API information. |
|
public |
async getChildren(parent: Object, child: Object, options: String): Promise Call a GET request expecting JSON API information for children given a parent. |
|
public |
Call a POST request on the main obj.type expecting JSON API information. |
|
public |
Call a PATCH request on the main obj.type expecting JSON API information. |
Public Constructors
Public Methods
public async delete(object: Object, cacheMode: String): Promise source
Call a DELETE request on the main obj.type expecting JSON API information.
Override:
JsonApiService#deletepublic async deletePermission(permission: Permission, cacheMode: String): Promise source
Params:
Name | Type | Attribute | Description |
permission | Permission | Permission object in which to delete |
|
cacheMode | String |
|
Override the caching method for this call |
Example:
import { roleService } from 'clinical6';
// You will be able to delete a permission using `delete`.
roleService.delete({ id: 23 });
// This will also clear the local storage of this type and id
public async get(params: Object, cacheMode: String): Promise<Role[]|Role> source
Call a GET request expecting JSON API information.
Override:
JsonApiService#getThrow:
If missing token or missing required parameters |
Example:
import { roleService } from 'clinical6';
// You will be able to access these roles using the `get` method.
roleService.get().then(roles => console.log(roles));
// Additionally, you can retrieve a specific role with the `get`
// method, using the ID of the desired role as a parameter.
roleService.get({ id: 23}).then(role => console.log(role));
public getAuthorizableResources(): Promise<[Object]> source
Return:
Promise<[Object]> | Promise object that returns an array of Flow, ContentType, and Section objects. |
Throw:
If missing token or missing required parameters |
Example:
import { roleService } from 'clinical6';
// You will be able to access authorizable data using the `get` method.
roleService.getAuthorizableResources().then(authorizables => console.log(authorizables));
public async getInvitableRoles(role: Object, cacheMode: String): Promise<Role[]|Role> source
Throw:
If missing token or missing required parameters |
Example:
import { roleService } from 'clinical6';
// You will be able to access the invitable user roles using the `get` method.
roleService.getInvitableRoles({ id: 5 }).then(roles => console.log(roles));
public async getPermissions(role: Object, options: String): Promise<Permission[]|Permission> source
Return:
Promise<Permission[]|Permission> | Promise object that returns one role or a key:role hashtable |
Throw:
If missing token or missing required parameters |
Example:
import { roleService } from 'clinical6';
// You will be able to access the role permissions using the `get` method.
roleService.getPermissions().then(roles => console.log(roles));
public async insert(role: Role, cacheMode: String): Promise<Role> source
Call a POST request on the main obj.type expecting JSON API information.
Override:
JsonApiService#insertExample:
import { Role, roleService } from 'clinical6';
const user = new Role({...});
// you can insert a role using the `insert` method.
roleService.insert(role).then(role => console.log(role));
// you could also just call `save` on the role if it doesn't have an id, which will also
// invoke the `insert` method
role.save();
public async insertPermission(permission: Permission, cacheMode: String): Promise<Permission> source
Params:
Name | Type | Attribute | Description |
permission | Permission | Permission object in which to insert |
|
permission.role | Role | Role object in which to insert |
|
permission.authorizable | Object | Object in which to insert |
|
permission.allowedAction | AllowedAction |
|
Optional allowedAction object in which to insert |
cacheMode | String |
|
Override the caching method for this call |
Example:
import { Permission, Role, roleService } from 'clinical6';
const permission = new Permission({...});
permission.authorizable = {id: 117, type: 'sections'}
permission.role = new Role({...})
// you can insert a permission using the `insertPermission` method.
roleService.insertPermssion(permission).then(permission => console.log(permission));
public async update(role: UserRole, cacheMode: String): Promise<Role> source
Call a PATCH request on the main obj.type expecting JSON API information.
Override:
JsonApiService#updateParams:
Name | Type | Attribute | Description |
role | UserRole | Role object in which to update |
|
cacheMode | String |
|
Override the caching method for this call |
Example:
import { Role, roleService } from 'clinical6';
const role = new Role({...});
// you can update a role using the `update` method.
roleService.update(role).then(role => console.log(role));
// you could also just call `save` on the role if it has an id, which will also
// invoke the `update` method
role.save();