-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Description
Description
Develop an endpoint to create new billing plans. The endpoint will handle requests to create a new plan with the specified details. If the plan is created successfully, a confirmation message will be returned to the client with a '201 Created' status. If an error occurs during creation, an appropriate error status will be returned.
Acceptance Criteria
The endpoint creates a new billing plan with the provided details including plan_name and amount.
Returns a 201 Created status code and a confirmation message when the plan is created successfully.
Returns a 400 Bad Request status code and an appropriate error message if the request data is invalid.
Returns a 500 Internal Server Error status code and an appropriate error message if an unexpected error occurs.
The endpoint is correctly versioned.
Requirements
Implement an API endpoint for creating a new billing plan.
The request should include the plan_name and amount fields.
Validate the request data and handle errors appropriately.
Ensure the endpoint is correctly versioned (e.g., /api/v1/organization/plans).
Expected Outcome
Users should be able to send a request to the backend to create a new billing plan.
Users should receive appropriate status codes and responses based on the outcome of the request.
Endpoints
[POST] /api/v1/organization/plans
Description: Creates a new billing plan.
Request Body:
json
{
"plan_name": "premium",
"amount": 1200
}
Success Response:
Status: 201 Created
Body:
json
> {
> "message": "New plan created successfully",
> "status": "success",
> "data": {
> "plan_name": "premium",
> "amount": 1200
> }
> }
Error Response:
Status: 400 Bad Request
Body:
json
{
"error": "Invalid request data."
}
Status: 500 Internal Server Error
Body:
json
```
{
"error": "Internal server error."
}
**Testing**
**Test Scenarios**
Successful Creation of a Billing Plan
Ensure that the endpoint successfully creates a new billing plan with valid data.
Verify that the response includes a confirmation message and the correct status code (201 Created).
Invalid Request Data
Simulate a scenario where the request data is missing required fields or includes invalid values.
Confirm that the response body contains a 400 Bad Request status code and an appropriate error message.
Internal Server Error
Simulate an internal server error (e.g., database failure) during the creation process.
Verify that the endpoint returns a 500 Internal Server Error status code.
Confirm that the response body contains an appropriate error message.
Invalid HTTP Method
Send a request using an invalid HTTP method (e.g., GET) to the endpoint.
Verify that the endpoint returns a 405 Method Not Allowed status code.
Confirm that the response body contains an appropriate error message.
Bad Request
Send a request with invalid data formats (e.g., non-integer amount).
Verify that the endpoint returns a 400 Bad Request status code.
Confirm that the response body contains an appropriate error message.
Metadata
Metadata
Assignees
Labels
No labels