hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 137 forks source link

[FEAT] : API Endpoint To Retrieve Product Categories #659

Open Arnthorny opened 1 month ago

Arnthorny commented 1 month ago

Description

Create an API endpoint that allows an authenticated user retrieve all product categories thus providing essential information for product navigation and filtering.

This endpoint will validate the user and then return all product categories stored in the database.

Acceptance Criteria

Requirements

Expected Outcome

Endpoints

[GET] /api/v1/products/categories

Responses

{
  "success": true,
  "message": "Categories retrieved successfully",
  "status_code": 200,
  "data": [
     {
     "name": "Category_1",
     "id": "id_1",
   },
    {
     "name": "Category_2",
     "id": "id_2",
   }
  ]
}
{
  "success": false,
  "message": "Not authenticated",
  "status_code": 401
}
{
  "success": false,
  "message": "<string>",
  "status_code": 500
}

Test Scenarios

  1. Successful Retrieval of Product Categories

    • Ensure that the endpoint successfully retrieves all categories in the database.
    • Confirm that the status code is 200.
    • Verify that the response body contains the retrieved data.
  2. Unauthenticated Request

    • Send a request without being authenticated.
    • Verify that the endpoint returns a 401 Unauthenticated status code.
Arnthorny commented 1 month ago

Referred from the main Boilerplate repo https://github.com/hngprojects/hng_boilerplate_nestjs/issues/257