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: Create Billing Plan Endpoint #678

Open
odero-lavenda opened this issue Feb 27, 2025 · 1 comment
Open

FEAT: Create Billing Plan Endpoint #678

odero-lavenda opened this issue Feb 27, 2025 · 1 comment

Comments

@odero-lavenda
Copy link

Description

Develop an API endpoint that allows authenticated users to create a new billing plan by providing details such as the plan name and price, with proper validation to ensure data accuracy. The endpoint should handle errors gracefully by returning appropriate HTTP status codes, meaningful error messages, and logging requests for monitoring and debugging.


Endpoint Details

Method: POST
URL: /api/v1/billing-plans

Request

Headers

  • Authorization: Bearer <token>
    (Required: Ensures only authenticated users can access the endpoint)
  • Content-Type: application/json

Request Body

{
  "name": "string",  
  "price": "number"  
}

Response

Success (201 Created)

Body:

{
  "Status": 201,
  "Message": "Billing plan created successfully",
  "Data": {
    "id": "string",  
    "name": "string",
    "price": "number"
  }
}

Failure Responses

401 Unauthorized

Body:

{
  "Status": 401,
  "Message": "Unauthorized"
}
500 Internal Server Error

Body:

{
  "Status": 500,
  "Message": "Internal server error"
}

Acceptance Criteria

  • The endpoint must require authentication, returning a 401 Unauthorized error if the user is not authenticated.
  • Upon successful creation, the endpoint must return:
    • 201 Created status code
    • A success message
    • The created billing plan details under the Data key
  • The system should properly handle unexpected errors and return a 500 Internal Server Error when necessary.

Additional Details

Authorization

  • Only authenticated users should be able to create billing plans.
  • Unauthorized access must result in a 401 Unauthorized response with a clear error message.

Data Validation

  • name: Must be a non-empty string.
  • price: Must be a valid numerical value.

Error Handling

  • Implement meaningful error messages and appropriate HTTP status codes.
  • Ensure consistent response formats for errors.

Logging

  • Log both successful operations and errors to facilitate debugging and system monitoring.
@odero-lavenda odero-lavenda changed the title Develop an endpoint that allows for the creation of a new billing plan within the system. FEAT: Create Billing Plan Endpoint Feb 27, 2025
@Am0du
Copy link
Contributor

Am0du commented Feb 27, 2025

This has been implemented check plan

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

2 participants