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

Category List API Endpoint #10

Open
3 tasks
Pythonian opened this issue Jul 25, 2024 · 0 comments
Open
3 tasks

Category List API Endpoint #10

Pythonian opened this issue Jul 25, 2024 · 0 comments

Comments

@Pythonian
Copy link
Owner

Description

Develop an endpoint to handle requests to retrieve all categories. This endpoint will return a list of categories to the client.

Acceptance Criteria

  • The endpoint retrieves all categories that are not marked as deleted.
  • Returns a 200 OK status code with the list of categories.
  • Handles errors appropriately, returning the correct status codes for unexpected issues.

Requirements

  • Implement API endpoint for retrieving all categories.
  • Ensure that the endpoint only retrieves categories that are not marked as deleted.
  • Handle unexpected errors and return the appropriate status code.

Expected Outcome

  • Users should be able to send a request to retrieve all categories.
  • Users should receive a list of categories with appropriate status codes based on the outcome of the request.

Endpoints

[GET] /api/v1/categories

  • Description: Retrieves all categories that are not marked as deleted.

  • Success Response:

    • Status: 200 OK

    • Body:

      {
        "categories": [
          {
            "id": 1,
            "name": "Technology",
            "description": "Posts related to technology",
            "created_at": "2024-07-18T00:00:00Z",
            "updated_at": "2024-07-18T00:00:00Z"
          },
          {
            "id": 2,
            "name": "Health",
            "description": "Posts related to health",
            "created_at": "2024-07-18T00:00:00Z",
            "updated_at": "2024-07-18T00:00:00Z"
          }
        ]
      }
  • Internal Server Error Response:

    • Status: 500 Internal Server Error

    • Body:

      {
          "error": "Internal server error."
      }

Testing

Test Scenarios

  1. Successful Retrieval of All Categories

    • Ensure that the endpoint successfully retrieves all categories that are not marked as deleted.
    • Verify that the response includes the list of categories and a 200 OK status code.
  2. Internal Server Error

    • Simulate an internal server error to raise an exception.
    • Verify that the endpoint returns a 500 Internal Server Error status code and an appropriate error message.
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