Develop an API endpoint to fetch the list of customers in the database.
Acceptance Criteria
The endpoint would be accessible at /api/v1/customers?limit=10&page=1.
The endpoint would return a paginated response with an arrayof customer objects containing first_name, last_name, email, phone_number and organisations array containing the organisation's UUID.
The endpoint would accept HTTP GET requests.
The endpoint would be secured to ensure that only a user with an admin role can fetch the list of customers.
Proper authentication mechanisms (e.g., JWT, OAuth2, SAML) would be implemented.
Requests to the endpoint must include a valid authentication token in the Authorization header. Authorization: Bearer <token>.
{
"error": Bad Request,
"message": "Internal server error",
"status_code": 500
}
Purpose
To fetch the list of customers in the Database
Requirements
[ ] User must be authenticated thereby having an Authorization: Bearer <token> header in the request body
[ ] User must have the role of an admin
[ ] User account must be active
[ ] User must indicate the limit number and page number
Expected Outcome
A paginated response with an array of customer objects where each customer object contains first_name, last_name, email, phone_number and organisations array containing the organisations UUID.
Testing
Unit Tests
The systems should have unit tests covering:
[ ] Ensure data is fetched correctly from the database.
[ ] Test that the appropriate response and status code is returned
Develop an API endpoint to fetch the list of customers in the database.
Acceptance Criteria
/api/v1/customers?limit=10&page=1
.array
of customer objects containingfirst_name
,last_name
,email
,phone_number
andorganisations
array containing the organisation's UUID.GET
requests.Authorization: Bearer <token>
.Response (Success)
Response (Error)
Internal Server Error
Purpose
To fetch the list of customers in the Database
Requirements
Authorization: Bearer <token>
header in the request bodyExpected Outcome
A paginated response with an array of customer objects where each customer object contains
first_name
,last_name
,email
,phone_number
andorganisations
array containing the organisations UUID.Testing