hngprojects / hng_boilerplate_php_laravel_web

Apache License 2.0
148 stars 58 forks source link

[FIX](PHP) Refactor Billing API Endpoint for Creating New Plans #598

Open tulbadex opened 2 weeks ago

tulbadex commented 2 weeks ago

Description

Refactor our current API endpoint for creating a new billing plan to have the following route, request body, and response body.

Route

POST: /api/v1/billing-plans

Request Body:

{
  "name": "string",
  "frequency": "Monthly",
  "is_active": true,
  "amount": 0,
  "description": "string"
}

Response Body:

Status Code: 201 Created

{
  "data": {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "name": "string",
    "frequency": "Monthly",
    "is_active": true,
    "amount": 0,
    "description": "string",
    "created_at": "2024-08-24T14:53:25.025Z",
    "updated_at": "2024-08-24T14:53:25.025Z"
  },
  "message": "string",
  "status_code": 0
}

Status Code:

400 Bad Request

{
  "data": "string",
  "error": "string",
  "message": "string",
  "status_code": 0
}