The Bookings API Schema contains the details of reserving seats for a particular bus. In this module, it will let you:
- Create a new bus booking
- Get Booking Records
- Get Cancelled Booking Records
- Filter Booking Records
- Update Booking Status Record
Field | Type | Description |
---|---|---|
id
|
string | The unique booking ID and the primary key. |
bus_id
|
string | The unique bus ID. |
bus_route_id
|
string | The bus route ID and the sort key. |
user_id
|
string | The unique user ID. |
status
|
string |
The status of the particular booking.
There are 3 different status types: - PENDING - CONFIRMED - CANCELLED |
seat_number
|
string | The specific seat number(s) for the particular booking. |
travel_date
|
string | The date when to travel. |
date_confirmed
|
string | The date the booking was confirmed. |
is_cancelled
|
boolean | Indicates if the booking is cancelled or not. |
cancelled
|
object | Contains the cancelled booking information. |
timestamp
|
string | The timestamp when the request was made. |
date_created
|
string | The date that this booking record was created. |
Field | Type | Description |
---|---|---|
id
|
string | The unique booking cancellation ID. |
booking_id
|
string | The unique booking ID as the primary key. |
reason
|
string | The reason for booking cancellation. |
cancelled_by
|
string | Indicates who cancelled the booking. |
date_cancelled
|
string | The date that this booking record was cancelled. |
Key | Value |
---|---|
Content-Type
|
application/json
|
Setting to application/json
is recommended.
Status Code | Description |
---|---|
200 | OK |
400 | Bad Request |
500 | Internal Server Error |
To create a new booking instance, you need to instantiate an object that represents the booking property. The booking instance holds the information related to the details of reserving seats for a particular bus.
Method: POST
Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bookings/create
Field | Type | Description | Required |
---|---|---|---|
user_id
|
string | The unique user ID. | ✅ |
bus_id
|
string | The unique bus ID. | ✅ |
bus_route_id
|
string | The bus route ID and the sort key. | ✅ |
seat_number
|
string | The specific seat number(s) for the particular booking. | ✅ |
travel_date
|
string | The date when to travel. | ✅ |
status
|
string | The status of the particular booking. Should be set to "PENDING". | ✅ |
timestamp
|
string | The timestamp when the request was made. | ✅ |
{
"user_id": "ADMN-878495",
"bus_id": "BCBSCMPN-884690",
"bus_route_id": "RTBRTC15001900884691",
"seat_number": "23,24,25,26",
"status": "PENDING",
"timestamp": "2023-07-01 10:30",
"travel_date": "2023-07-06 19:30"
}
When retrieving the specific booking record, the id
and bus_route_id
query parameters must be present in the URL. These parameters identify which information should be returned. It will either return a representation of a specific booking record or a list of booking record.
Method: GET
Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bookings/get
Query Parameters
Parameter | Type | Description | Required |
---|---|---|---|
id
|
string | The unique booking ID. | ✅ |
bus_route_id
|
string | The unique bus route ID. | ✅ |
[
{
"id": "bd866a7e-34cd-4ea1-8411-5351a6b76ffd",
"user_id": "ADMN-878495",
"bus_id": "BCBSCMPN-884690",
"bus_route_id": "RTBRTC15001900884691",
"status": "PENDING",
"seat_number": "23,24,25,26",
"travel_date": "2023-07-06 19:30",
"date_created": "2023-07-05 07:48:26",
"cancelled": {
"id": "",
"booking_id": "",
"reason": "",
"cancelled_by": "",
"date_cancelled": ""
},
"timestamp": "2023-07-01 10:30"
}
]
When retrieving the specific cancelled booking record, the booking_id
query parameter must be present in the URL. This parameter identify which information should be returned. It will either return a representation of a specific cancelled booking record or a list of cancelled booking record.
Method: GET
Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bookings/cancelled/get
Query Parameters
Parameter | Type | Description | Required |
---|---|---|---|
booking_id
|
string | The unique booking ID. | ✅ |
[
{
"id": "053607ed-3dc6-40a3-aea4-d7e87fd015f6",
"booking_id": "ce4e0245-b772-47f8-92fc-0d70cbd511c0",
"reason": "sample reason",
"cancelled_by": "ADMN-878495",
"date_cancelled": "2023-07-05 04:16:41"
}
]
When retrieving a list of booking records, the status
query parameter must be present in the URL, and either of the bus_id
, or route_id
is optional in the query parameter. These parameters will identify which booking record(s) should be returned.
Method: GET
Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bookings/search?status=xxxxxx
Parameter | Type | Description | Required |
---|---|---|---|
status
|
string | The status of the particular booking. There are 3 different status types: - PENDING - CONFIRMED - CANCELLED Should be defaulted to "ALL" if fetching all records with different statuses. |
✅ |
bus_id
|
string | The unique bus ID. | ❌ |
route_id
|
string | The unique bus route ID. | ❌ |
[
{
"id": "bd866a7e-34cd-4ea1-8411-5351a6b76ffd",
"user_id": "ADMN-878495",
"bus_id": "BCBSCMPN-884690",
"bus_route_id": "RTBRTC15001900884691",
"status": "PENDING",
"seat_number": "23,24,25,26",
"travel_date": "2023-07-06 19:30",
"date_created": "2023-07-05 07:48:26",
"cancelled": {
"id": "",
"booking_id": "",
"reason": "",
"cancelled_by": "",
"date_cancelled": ""
},
"timestamp": "2023-07-01 10:30"
}
]
When modifying the booking record, the id
and bus_route_id
query parameters must be present in the URL. These parameters identify which booking record should be modified. After the update is performed, it will return a representation of the updated booking record.
Method: POST
Endpoint: https://{api_id}.execute-api.{region}.amazonaws.com/prod/bus-route/update?id=xxxxx&bus_id=xxxxx
Parameter | Type | Description | Required |
---|---|---|---|
id
|
string | The unique booking ID. | ✅ |
route_id
|
string | The unique bus route ID. | ✅ |
Payload
Parameter | Type | Description | Required |
---|---|---|---|
status
|
string | The status of the particular booking. Should be set as "CONFIRMED". | ✅ |
seat_number
|
string | The specific seat number(s) for the particular booking. | ❌ |
Sample Request Payload:
{
"status": "CONFIRMED",
"seat_number": "23,24,25"
}
Payload
Parameter | Type | Description | Required |
---|---|---|---|
status
|
string | The status of the particular booking. Should be set as "CANCELLED". | ✅ |
cancelled
|
object | Contains the cancelled booking information (reason and cancelled_by fields). | ✅ |
Sample Request
Payload:
{
"status": "CANCELLED",
"cancelled": {
"reason": "sample reason",
"cancelled_by": "ADMN-878495"
}
}