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]: Retrieve Product Details By Id #460

Open
CallmeInnocent opened this issue Aug 9, 2024 · 0 comments
Open

[FEAT]: Retrieve Product Details By Id #460

CallmeInnocent opened this issue Aug 9, 2024 · 0 comments

Comments

@CallmeInnocent
Copy link
Collaborator

Description:

Develop a backend API endpoint to allow logged-in users to retrieve the details of a specific product. This functionality is part of the product management system and requires user authentication.

Acceptance Criteria:

Endpoint security:
Only authenticated users can have access to the endpoint
A user must have the appropriate permissions to access the endpoint
Each request to the endpoint must include a valid authentication token in the

  1. Retrieve Product Details:
    • Method: GET
    • URL: /api/v1/products/:id
    • Request:
    o Headers:
     Authorization: Bearer <JWT_token>
    • Response:
    On successful retrieval:
    {
	  "status": "success",
	  "message": "Product details retrieved successfully",
	  "status_code": 200,
	  "data": {
	    "id": 1,
	    "name": "string",
	    "description": "string",
            "category": null,
            "price": 50.0,
            "imageUrl": null,
            "status": true,
            "current_stock": 789
    }
On error (e.g., product not found):
{
  "status": "error",
  "message": "Product not found",
  "status_code": 404
}
On error (e.g., unauthorized access):
{
  "status": "error",
  "message": "Unauthorized access",
  "status_code": 401
}

Validation:

• Validate the JWT auth token.
• Validate that the id exists and the user is authorized to view the product.

Purpose:

To provide a secure and authenticated endpoint for retrieving details of a specific product, ensuring only authorized users can access this information.

Expected Outcome:

A fully functional backend API endpoint that allows logged-in users to retrieve product details, with proper validation and error handling.

Tasks:

• Implement the GET endpoint to retrieve product details.
• Validate inputs and handle errors appropriately.
• Write unit tests for the endpoint to ensure it handles valid and invalid inputs correctly.

Test Scenarios:

  1. Successful product retrieval: Verify that a logged-in user can retrieve product details with a valid product ID.
  2. Product not found: Verify that the endpoint returns a 404 status code when the product does not exist.
  3. Unauthorized access: Verify that the endpoint returns a 401 status code when the user is not authorized to view the product.
  4. Validation error: Verify that the endpoint returns a 400 status code when required parameters are missing or incorrectly formatted.
@CallmeInnocent CallmeInnocent changed the title [FEAT]: Retrieve Product Details- Backend [FEAT]: Retrieve Product Details By Id Aug 9, 2024
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