The MDJM REST API includes the /employee/
endpoint to enable a specific employees details to be retrieved.
The /employee/
endpoint allows you to query the database by an employee’s user ID, and then returns MDJM relevant information pertaining to that employee.
Parameters
The /employee/
endpoint requires one of two possible parameters to be sent along with the API request;
- employee_id (Optional)
The user ID of the employee you wish to retrieve. - employee_email (Optional)
The email address of the employee you wish to retrieve.
If neither one of these parameters is provided, the request will return an error.
If validation succeeds and the employee is located the following details will be returned;
ID
(integer)
The user ID of the employeefirst_name
(string)
First name of employeelast_name
(string)
Last name of employeeemail
(string)
Email address of employeeroles
(array)
An array of roles this employee haslast_login
(date/time)
The last date and time that the employee last logged in to MDJMevents
(array)
An array of the employees events stored within MDJM (Event ID => Event date)next_event
(array)
An array containing the ID and date of the employee’s next eventtotal_events
(integer)
Total number of events this employee is assigned to (past and present)
Method
The /employee/
endpoint accepts both the GET and POST HTTP methods.
The /employee/
endpoint requires security validation and therefore your API Key and Token need to be included within the API request. Furthermore, the API will determine whether or not the employee_id being specified is indeed that of n employee. If it is not, an error will be returned.
Example API Call
To retrieve information for the employee with user ID 84, the following would be used;
http://<yoursite.com>/wp-json/mdjm/v1/employee/?api_key=03e8d350690c06b6106edc7936bd2b96&token=b35b7c30f56e2975dcc7dc171db90cdb&employee_id=84
Response
The response from the above query would look like;
{ "data": { "employee": { "first_name": "Employee", "last_name": "Three", "email": "[email protected]", "roles": { "mdjm-accountant": "Accountant" }, "last_login": "2016-04-29", "events": { "5636": "2016-10-29", "7983": "2016-05-29", "8154": "2016-09-23", "8181": "2016-05-27" }, "next_event": { "id": 5636, "date": "2016-10-29" }, "total_events": 4 } }, "headers": { "Content-type": "application/json" }, "status": 200 }