Skip to content

Vendor Testimonials API

This API provides endpoints to manage vendor testimonials. Users can list, create, update, or delete testimonials. Testimonials are sorted by highest rating, limited to the top 10 entries.


Endpoints

  1. List Vendor Testimonials: GET /api/v1/testimonials/list/
  2. Create Vendor Testimonial: POST /api/v1/testimonials/add/
  3. Update Vendor Testimonial: PATCH /api/v1/testimonials/edit/<str:pk>/
  4. Delete Vendor Testimonial: DELETE /api/v1/testimonials/remove/<str:pk>/

Permissions

  • Listing: AllowAny
  • Creating, Updating, Deleting: Authenticated vendors only (IsAuthenticated).

1. List Vendor Testimonials

Endpoint

  • URL: /api/v1/testimonials/list/
  • Method: GET
  • Permission Required: AllowAny

Description

Retrieve the top 10 vendor testimonials sorted by the highest rating.

Request Payload

This API provides only GET request

Response Examples

Success

{
  "id": 1,
  "vendor": "Vendor Name",
  "rating": 5,
  "testimonial": "Excellent service!",
 "created_at": "2024-12-01T12:00:00Z"
}


2. Create Vendor Testimonial

Endpoint

  • URL: /api/v1/testimonials/add/
  • Method: POST
  • Permission Required: IsAuthenticated

Description

Allows a vendor to create a testimonial. Only registered vendors can add testimonials.

Request Payload

{
  "rating": 5,
  "testimonial": "Great experience!"
}

Response Examples

Success

  {
  "id": 1,
  "vendor": "Vendor Name",
  "rating": 5,
  "testimonial": "Great experience!",
  "created_at": "2024-12-01T12:00:00Z"
  }

Error

  {
  "error": "You must be a registered vendor to add a testimonial."
  }


3. Update Vendor Testimonial

Endpoint

  • URL: /api/v1/testimonials/edit/<str:pk>/
  • Method: PATCH
  • Permission Required: IsAuthenticated

Description

Allows a vendor to update their testimonial. Vendors can only update testimonials they created.

Request Payload

{
  "rating": 4,
  "testimonial": "Good service, but some delays."
}

Response Examples

Success

{
  "id": 1,
  "vendor": "Vendor Name",
  "rating": 4,
  "testimonial": "Good service, but some delays.",
  "created_at": "2024-12-01T12:00:00Z"
}
Error
{
  "detail": "You do not have permission to update this testimonial."
}


4. Delete Vendor Testimonial

Endpoint

  • URL: /api/v1/testimonials/remove/<str:pk>/
  • Method: DELETE
  • Permission Required: IsAuthenticated

Description

Allows a vendor to delete their testimonial. Vendors can only delete testimonials they created.

Request Payload

This endpoint does not require any request payload.

Response Examples

Success

{
  Testimonial successfully deleted.
}

Error

{
  "detail": "You do not have permission to delete this testimonial."
}