Get Available Departments / Roles API
Require Authentication
This API is used to get available departments / roles for the company based on combination of deviceID and token.
Only users that have module "user_and_roles_menu" in their role/department (currently only Administrator) can view role/department list
URL
api/companies/department
Required parameter (POST)
- deviceID
- token
Optional parameter (GET)
All optional parameters use GET method. So it should be embedded in the URL, e.g: api/companies/department?q=department%20name&o=departmentName
- q «contains keyword that want to be looked for. Keyword will search departmentName field only»
- o «used to sort data, contains field name. Available value: departmentName, total_users. Default value: departmentName»
- ot «used to sort data, contains sort type. Available value: asc, desc. Default value: asc»
- per_page «indicates how many data that will be displayed in each call. Value must be a number between 1 to 500. Default value: 500»
- offset «indicates the first data index that will be displayed in each call. Value must be a number with minimum value is 0. Default value: 0»
Example JSON Payload
{
"deviceID": "ABCD-EFGH-IJKL-MNOP",
"token": "bb602ab13b8090268cd6e3bb9dfa39e2"
}
Possible return HTTP status code
- 200
- 401
- 405
Return message
{
"status": "success",
"message": {
"current_parameter": "?per_page=500&offset=0",
"next_parameter": "",
"previous_parameter": "",
"start": 0,
"total": 2,
"lists": [{
"departmentID": 1,
"departmentName": "Administrator",
"createdDate": 1446208931,
"createdBy": 0,
"modifiedDate": 1446208931,
"modifiedBy": 0,
"companyID": 1,
"total_users": 2
}, {
"departmentID": 2,
"departmentName": "department from api",
"createdDate": 1449305897,
"createdBy": 3,
"modifiedDate": 1449305897,
"modifiedBy": 3,
"companyID": 1,
"total_users": 0
}]
}
}
Note: use "next_parameter" and "previous_parameter" to go to next or previous result page. Just combine it with the API URL, e.g: "api/companies/department"+next_parameter or "api/companies/department"+previous_parameter