-
Notifications
You must be signed in to change notification settings - Fork 216
Open
Labels
Description
Implement Endpoint to Get Billing Plan Details
Description:
Implement an endpoint to retrieve billing plan details for a specific organization. This endpoint will fetch the details of a specified billing plan.
Endpoint:
GET /api/v1/organizations/{organization_id}/billing-plans/{plan_name}
Request Parameters:
organization_id(path parameter): The unique identifier of the organization.plan_name(path parameter): The name of the billing plan to fetch details for.
Request Headers:
Content-Type: application/jsonAuthorization: Bearer <token>
Response:
status: HTTP status code indicating the request outcome.message: Description of the response.data: The billing plan details.
Response Body Example:
{
"status": 200,
"message": "details fetched successfully",
"data": {
"plan": {
"id": "premium",
"name": "Premium Plan",
"price": 20.00,
"features": ["Feature 1", "Feature 2", "Feature 3"],
"description": "Detailed description of the Premium Plan."
}
}
}Tasks:
-
Route Handler:
- Create a route handler for the endpoint.
-
Authentication & Authorization:
- Implement authentication and authorization middleware to verify the Bearer token.
-
Database Design:
- Ensure the database schema supports storing billing plan details.
- Define necessary relationships between organizations and billing plans.
-
Fetch Billing Plan Details:
- Fetch billing plan details based on the provided
organization_idandplan_name.
- Fetch billing plan details based on the provided
-
Response Format:
- Return the billing plan details in the specified response format.
-
Unit Testing:
- Write unit tests to ensure the endpoint works as expected.
- Test cases should include valid requests, invalid requests (e.g., missing or invalid token), and error handling.
-
API Documentation:
- Update the API documentation to include this new endpoint.
Acceptance Criteria:
- The endpoint should validate the presence of
organization_idandplan_name. - The endpoint should return a 401 status code if the authorization token is invalid or missing.
- The endpoint should return a 200 status code with the billing plan details if the request is successful.
- The endpoint should handle errors gracefully and return appropriate error messages and status codes.
- Unit tests should cover all scenarios, including success, failure, and edge cases.
- Database design should support efficient retrieval and storage of billing plan details.
Notes:
- Ensure that the
organization_idandplan_nameare validated and sanitized to prevent SQL injection or other security issues. - Follow RESTful API design principles and best practices.
- Ensure that unit tests are comprehensive and cover all possible edge cases.
- Review and adhere to the existing database design and conventions.