hngprojects / hng_boilerplate_python_fastapi_web

Apache License 2.0
153 stars 137 forks source link

[FEAT] Create a GET endpoint to Retrieve Client Testimonials #104

Open chionz opened 1 month ago

chionz commented 1 month ago

Description

Create an API GET endpoint that allows users to retrieve client testimonials.

Acceptance Criteria

Purpose

The purpose of this endpoint is to provide a way for users to easily access and retrieve client testimonials from our database.

Requirements

Expected Outcome

Request Example

GET /api/testimonials?

Successful Response

{
  "message": "Testimonials retrieved successfully",
  "status_code": 200,
  "data": [
    {
      "id": 1,
      "client_name": "Jane Smith",
      "client_designation": "Freelance Designer",
      "testimonial": "Excellent service and support!",
      "rating": 5,

    }
   ]
 "pagination": {
    "current_page": 1,
    "per_page": 3,
    "total_pages": 5,
    "total_testimonials": 50
  }
}

Unsuccessful Response

{
  "message": "Error retrieving testimonials",
  "status_code": 500
}
{
  "message": "Error retrieving testimonials",
  "errors": [
    "Invalid client name format",
    "Rating out of range (expected 1-5 stars)",
    "Invalid date format"
  ],
  "status_code": 400
}

Unit Tests

Expected Outcome

chionz commented 1 month ago

Ticket Reference: https://github.com/hngprojects/hng_boilerplate_nestjs/issues/201