hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 140 forks source link

[FEAT]: Fetch Customer List Endpoint #54

Open Okunola11 opened 1 month ago

Okunola11 commented 1 month ago

Develop an API endpoint to fetch the list of customers in the database.

Acceptance Criteria

Response (Success)

{
"status_code": 200,
"current_page": 1,
"total_pages": 20,
"limit": 10,
"total_items": 202,
"data":
[
  {
     "first_name": "Emmanuel",
     "last_name": "xxxxxxxxxxx",
     "phone_number": "xxxxxxxxxxx",
     "organisations": ["xxxxxxxxxxxx", "xxxxxxxxxxx", "xxxxxxxxxxxx"]
  },
],
}

Response (Error)

{
  "status_code": 401,
  "message": "Unauthorized",
  "error": "Bad Request"
}

Internal Server Error

{
  "error": Bad Request,
  "message": "Internal server error",
  "status_code": 500
}

Purpose

To fetch the list of customers in the Database

Requirements

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

  1. 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
Okunola11 commented 1 month ago

This issue has been approved here.