You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a protected API endpoint that allows authenticated users to create a new testimonial. Ensure the endpoint handles validation errors properly and returns the created testimonial along with appropriate status codes.
Acceptance Criteria
Authentication
The endpoint should be protected and require the user to be authenticated.
If the user is not authenticated, the endpoint should return a 401 Unauthorized status with an appropriate error message.
Create Testimonial
The endpoint should allow authenticated users to create a new testimonial.
The testimonial submission should include necessary fields like “name” and "content".
Successful Response
If successful, it should return a 200 OK status code.
The response should include the created testimonial.
Endpoint
[POST] /api/v1/testimonials
Requests
POST /api/v1/testimonials
Content-Type: application/json
Authorization: Bearer <access_token>
{
"name": "Charles Ugberaese",
"content": "The service is fantastic, great experience."
}
Successful Response
{
"status": "success",
"message": "Testimonial created successfully",
"data": {
"user_id": "0b89cd08-57fc-40b0-aa17-ed6d95f43cfe",
"name": "Charles Ugberaese",
"content": "The service is fantastic, great experience.",
"created_at": "2024-07-18"
}
}
Description
Implement a protected API endpoint that allows authenticated users to create a new testimonial. Ensure the endpoint handles validation errors properly and returns the created testimonial along with appropriate status codes.
Acceptance Criteria
Authentication
Create Testimonial
Successful Response
Endpoint
[POST] /api/v1/testimonials
Requests
POST /api/v1/testimonials
<access_token>
Successful Response
Error Response
401 Unauthorized
Error Response
400 Bad Request
Error Response
500 Internal Server Error
Purpose
Allow authenticated users to submit and create new testimonials and ensure that the submitted data is stored accurately in the database.
Requirements
Expected Outcome
Testing
Unit Tests:
Authorization Tests:
Validation Tests:
The text was updated successfully, but these errors were encountered: