-
Notifications
You must be signed in to change notification settings - Fork 61
Open
Description
Description
Enhance the API by adding the ability to update product categories. Currently, the API supports creating, retrieving and deleting product categories via GET
, POST
and DELETE
methods but lacks endpoints for updating them. This enhancement will allow administrators to manage product categories more effectively.
Endpoints
1. Update Product Category
- Method:
PUT
- URL:
/api/v1/products/categories/{category_id}
Requirements
1. Input Validation
- Validate the incoming data (e.g., category name, description) to ensure data integrity.
2. Error Handling
- Return a
400
error for invalid input data. - Return a
404
error if the specified product category does not exist. - Return a
500
error for unexpected server issues.
Success Response
HTTP 200 OK
{
"status": "success",
"status_code": 200,
"message": "Product category updated successfully",
"data": {
"id": "12345",
"name": "Updated Category Name",
"description": "Updated description",
"updated_at": "2025-02-28T12:00:00Z"
}
}
Error Responses
400 BAD REQUEST
{
"status": "failure",
"status_code": 400,
"message": "Invalid input data"
}
404 NOT FOUND
{
"status": "failure",
"status_code": 404,
"message": "Product category not found"
}
500 INTERNAL SERVER ERROR
{
"status": "error",
"status_code": 500,
"message": "An unexpected error occurred"
}
Testing
-
Unit Tests
- Confirm that a product category is updated correctly when valid data is provided.
- Verify that attempting to update a non-existent category returns a
404
error. - Confirm that invalid input data results in a
400 BAD REQUEST
response.
-
Integration Tests
- Ensure end-to-end functionality for updating product categories.
- Validate proper error handling for edge cases.
Metadata
Metadata
Assignees
Labels
No labels