- Implement a RESTful JSON HTTP API gateway that allows programmatic CRUD operations on user records.
- All requests should be authenticated using HTTP Basic Authentication i.e. RFC2617
- Host the API gateway on a publicly accessible server.
Note: If you need a server to host your application and would like us to provide one for you, kindly contact our R&D Team on rd@pmglobaltechnology.com
API Endpoint: “http://{HOSTNAME}:{PORT}/users” e.g. http://test.com/users
Authentication
- Username: test
- Password: pass1234
Request
Endpoint : "/users" e.g. http://test.com/users
Method: POST
Data:
{
"firstname": "chibunna",
"lastname": "oduonye",
"gender": "M",
"date_of_birth": "2015-04-08"
}
Response
Code: 200
Data:
{
"id": "1",
"firstname": "chibunna",
"lastname": "oduonye",
"gender": "M",
"date_of_birth": "2015-04-08",
"date_created": "2014-07-17T03:03:34",
"date_updated": "2014-07-17T03:03:34"
}
Request
Endpoint : "/users" e.g. http://test.com/users?filter_field=firstname&filter_value=chibunna
Method: GET
Parameters (Optional):
- sort_field - this can be any field in the JSON e.g. "firstname",
- sort_order_mode - this can be either "asc" or "desc"
- filter_field - this can be any field in the JSON e.g. "firstname",
- filter_value - the criteria upon which the response data will be filtered
- page : The current page. Default is 1
- page_size: The number of records per page. Default is 25
Response
Code: 200
Data:
[
{
"id": "1",
"firstname": "chibunna",
"lastname": "oduonye",
"gender": "M",
"date_of_birth": "1990-04-08",
"date_created": "2014-07-17T03:03:34",
"date_updated": "2014-07-17T03:03:34"
},
{
"id": "2",
"firstname": "Godwin",
"lastname": "Orubebe",
"gender": "M",
"date_of_birth": "1965-04-08",
"date_created": "2014-07-17T04:12:25",
"date_updated": "2014-07-17T04:12:25"
}
]
Request
Endpoint : "/users/{id}" e.g. http://test.com/users/1
Method: GET
Response:
Code: 200
Data:
{
"id": "1",
"firstname": "chibunna",
"lastname": "oduonye",
"gender": "M",
"date_of_birth": "2015-04-08",
"date_created": "2014-07-17T03:03:34",
"date_updated": "2014-07-17T03:03:34"
}
Request
Method: PUT
Endpoint: "users/{id}" e.g. http://test.com/users/1
Payload:
{
"id": "2"
"firstname": "Godwin",
"lastname": "Jega",
"gender": "M",
"date_of_birth": "2015-04-08"
}
Response
Code: 200
Data:
{
"id": "2"
"firstname": "Godwin",
"lastname": "Jega",
"gender": "M",
"date_of_birth": "2015-04-08",
"date_created": "2014-07-17T04:12:25",
"date_updated": "2014-07-17T18:44:19"
}
Request
Method: DELETE
Endpoint: "users/{id}" e.g http://test.com/1
Response
Code: 200
Data:
Milestone | Marks | |
1 | Ability to create new users | 15 |
2 | Ability to update users | 15 |
3 | Ability to delete users | 15 |
4 | Ability to fetch a single user | 15 |
5 | Ability to search for users by at least one criteria | 10 |
6 | Ability to sort users by at least one criteria | 10 |
7 | Authenticates the test user’s credentials | 10 |
8 | Handle error conditions with the correct HTTP status codes e.g. 404, 403, 401, 400 etc | 10 |
TOTAL | 100 |
Send an email to rd@pmglobaltechnology.com that contains
- The URL to your work
- Include any special instructions on how to test it
The closing date for all submissions is April 30, 2015
Updated closing date July 30, 2019
After going through the Pre-Assessment Task, I need some clarifications with the following:
Response code/Data: The response code does not state the status of the request. When there is an error with the request, I guess there should be an error code and an error message, for example:
The question is should I include error code and message with the response or I should stick to the format earlier prescribed. Adding error code and message would also be of great help with the integration of the api.