Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update User Testimonial API #374

Open
18 tasks
Laban254 opened this issue Feb 27, 2025 · 1 comment
Open
18 tasks

feat: Update User Testimonial API #374

Laban254 opened this issue Feb 27, 2025 · 1 comment
Assignees

Comments

@Laban254
Copy link

Feature: Update User Testimonial API

Description

Develop an API endpoint to update an existing testimonial associated with a specific user.

Acceptance Criteria

  • Only authenticated users can access this endpoint.
  • The endpoint should be accessible at api/v1/testimonials/{testimonial_id}.
  • The endpoint should accept HTTP PATCH requests.
  • The endpoint should be protected and require authentication.
  • Request to the endpoint should include a valid authentication token in the Authorization header.
  • The request should allow partial updates to testimonial content.
  • Return appropriate response and status code.

Purpose

Delivers an API that updates an existing testimonial linked to a specific user.

Requirements

Data Validation:
The API should validate the request to ensure that the testimonial_id is present and valid.

Expected Outcome

Successful update of a testimonial associated with the provided testimonial_id.

Endpoint:

HTTP [PATCH] /api/v1/testimonials/{testimonial_id}

API Request Example:

PATCH /api/v1/testimonials/{testimonial_id}

{
  "Content-Type": "application/json",
  "Authorization": "Bearer <token>",
  "content": "Updated testimonial text."
}

API Successful Response

{
  "status": "success",
  "status_code": 200,
  "message": "Testimonial updated successfully",
  "data": {
    "id": "string",
    "user_id": "string",
    "content": "Updated testimonial text.",
    "created_at": "string",
    "updated_at": "string"
  }
}

API Error Response

Bad Request

{
  "status": "error",
  "status_code": 400,
  "message": "Invalid request parameters",
  "error": "string"
}

Unauthorized

{
  "status": "error",
  "status_code": 401,
  "message": "Unauthorized access",
  "error": "string"
}

Not Found

{
  "status": "error",
  "status_code": 404,
  "message": "Testimonial not found",
  "error": "string"
}

Server Error

{
  "status": "error",
  "status_code": 500,
  "message": "Internal server error",
  "error": "string"
}

Tasks

  • Develop server-side logic to handle updating a testimonial for a specific user.
  • Implement authentication and authorization to restrict access to authenticated users.
  • Validate the incoming testimonial_id parameter.
  • Ensure proper error handling for edge cases such as non-existing testimonials.
  • Optimize the update operation for efficiency.

Testing

  • Write unit tests for the testimonial update logic.
  • Test various scenarios, including:
    • Updating a testimonial for an existing user.
    • Attempting an update without authentication.
    • Trying with an invalid testimonial_id.
    • Handling cases where the testimonial does not exist.
@Laban254
Copy link
Author

Laban254 commented Feb 27, 2025

slack ID @kibe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants