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]: Add Update Endpoints for Product Categories #646

Open
idehen-divine opened this issue Mar 2, 2025 · 0 comments
Open

[FEAT]: Add Update Endpoints for Product Categories #646

idehen-divine opened this issue Mar 2, 2025 · 0 comments

Comments

@idehen-divine
Copy link

idehen-divine commented Mar 2, 2025

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant