Skip to content

Latest commit

 

History

History
378 lines (352 loc) · 7.46 KB

bus_unit.md

File metadata and controls

378 lines (352 loc) · 7.46 KB

Bus Unit

The Bus Unit API Schema contains the Bus Company's active bus unit and the unit's capacity. In this module, it will let you:

Data Structure

Field Type Description
bus_id string The unique bus ID and the sort key.
code string The code is a unique identification of a Bus Unit and is the primary key.
active boolean Defines if the Bus Unit is on "trip".
min_capacity number The minimum number of passenger.
max_capacity number The maximum number of passenger.
date_created string The date that this bus unit record was created.

API Usage and Specification

Headers

Key Value
Content-Type application/json

Setting to application/json is recommended.

HTTP Response Status Codes

Status Code Description
200 OK
400 Bad Request
500 Internal Server Error

Create Bus Unit Records

To create a new bus unit instance, you must initialize an array of objects representing bus units. It should contain at least one item in the array and each item represents specific bus unit properties.

Method: POST

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bus-unit/create

Payload

Field Type Description Required
code string The code is a unique identification of a Bus Unit.
bus_id string The unique bus ID.
active boolean Defines if the Bus Unit is on "trip".
min_capacity number The minimum number of passenger.
max_capacity number The maximum number of passenger.

Sample Payload

[
  {
    "bus_id": "BCBSCMPN-875011",
    "code": "BCBSCMPNBUS001",
    "active": true,
    "min_capacity": 30,
    "max_capacity": 60
  },
  {
    "bus_id": "BCBSCMPN-875011",
    "code": "BCBSCMPNBUS002",
    "active": true,
    "min_capacity": 30,
    "max_capacity": 60
  }
]

Get Bus Unit Record

When retrieving the specific bus unit record, the code and bus_id query parameters must be present in the URL. These parameters identify which bus unit record should be returned. It will either return a representation of a specific bus unit record or a list of bus unit records.

Method: GET

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bus-unit/get

Specific Bus Unit

Query Parameters

Parameter Type Description Required
code string The code is a unique identification of a Bus Unit.
bus_id string The unique bus ID.

Sample Response

[
  {
    "bus_id": "BCBSCMPN-875011",
    "code": "BCBSCMPNBUS002",
    "active": true,
    "min_capacity": 30,
    "max_capacity": 60
  }
]

Filter Bus Unit Record

When retrieving a list of bus unit records, the bus_id query parameter must be present in the URL, and either code or active is optional in the query parameter. These parameters will identify which bus unit record(s) should be returned.

Method: GET

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bus-unit/search?bus_id=xxxxxx

Query Parameters

Parameter Type Description Required
bus_id string The unique bus ID.
code string The code is a unique identification of a Bus Unit.
active boolean Defines if the Bus Unit is on "trip".

Sample Response

[
  {
    "bus_id": "BCBSCMPN-875011",
    "code": "BCBSCMPNBUS001",
    "active": true,
    "min_capacity": 30,
    "max_capacity": 60,
    "date_created": "1687501761"
  },
  {
    "bus_id": "BCBSCMPN-875011",
    "code": "BCBSCMPNBUS003",
    "active": true,
    "min_capacity": 45,
    "max_capacity": 70,
    "date_created": "1687501761"
  },
  {
    "bus_id": "BCBSCMPN-875011",
    "code": "BCBSCMPNBUS002",
    "active": true,
    "min_capacity": 30,
    "max_capacity": 60,
    "date_created": "1687501761"
  }
]

Update Bus Unit Record

When modifying the bus unit record, the code and bus_id query parameters must be present in the URL. These parameters identify which bus unit record should be modified. After the update is performed, it will return a representation of the updated bus unit record.

Method: POST

Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bus-unit/update?code=xxxxx&bus_id=xxxxx

Query Parameters

Parameter Type Description Required
code string The code is a unique identification of a Bus Unit.
bus_id string The unique bus ID.

Payload

Field Type Description Required
active boolean Defines if the Bus Unit is on "trip".
min_capacity number The minimum number of passenger.
max_capacity number The maximum number of passenger.

Sample Request

Payload:

{
  "active": false
}

Response:

{
  "bus_id": "BCBSCMPN-875011",
  "code": "BCBSCMPNBUS002",
  "active": false,
  "min_capacity": 30,
  "max_capacity": 60,
  "date_created": "1687501761"
}