Skip to content

Latest commit

 

History

History
403 lines (377 loc) · 7.92 KB

bus.md

File metadata and controls

403 lines (377 loc) · 7.92 KB

Bus

The Bus API Schema contains the bus information. In this module, it will let you:

Data Structure

Field Type Description
id string The unique bus ID and the sort key.
name string The name of the bus line and is the primary key.
owner string The name of the bus company owner.
email string The bus company e-mail address.
address string The bus company address.
company string The name of the bus company and is the sort key.
mobile_number string The bus company phone number.
date_created string The date that this bus information 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 Information

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

Method: POST

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

Payload

Field Type Description Required
name string The name of the bus line.
owner string The name of the bus company owner.
email string The bus company e-mail address.
address string The bus company address.
company string The name of the bus company.
mobile_number string The bus company phone number.

Sample Payload

[
  {
    "name": "Blue Horizon",
    "owner": "John Doe",
    "email": "john.doe@example.com",
    "address": "123 Main Street, City",
    "company": "ABC Bus Company",
    "mobile_number": "123-456-7890"
  },
  {
    "name": "Green Wave",
    "owner": "Jane Smith",
    "email": "jane.smith@example.com",
    "address": "456 Elm Avenue, Town",
    "company": "XYZ Bus Services",
    "mobile_number": "987-654-3210"
  }
]

Get Bus Information

When retrieving the specific bus information, the id and name query parameters must be present in the URL. These parameters identify which bus information should be returned. It will either return a representation of a specific bus information or a list of bus information.

Method: GET

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

Specific Bus

Query Parameters

Parameter Type Description Required
id string The unique bus ID.
name string The name of the bus line.

Sample Response

[
  {
    "id": "BCBSCMPN-875011",
    "name": "Blue Horizon",
    "owner": "John Doe",
    "email": "john.doe@example.com",
    "address": "123 Main Street, City",
    "company": "ABC Bus Company",
    "mobile_number": "123-456-7890"
  }
]

Filter Bus Record

When retrieving a list of bus records, either name or company query parameter must be present in the URL. This parameter will identify which bus records should be returned.

Method: GET

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

Query Parameters

Parameter Type Description Required
name string The name of the bus line.
company string The name of the bus company.

Sample Response

[
  {
    "id": "TRNSTBSC-875011",
    "name": "Yellow Sunshine",
    "owner": "Melissa Anderson",
    "email": "melissa.anderson@example.com",
    "address": "741 Oak Avenue, Suburb",
    "company": "Transit Bus Co",
    "mobile_number": "999-333-7777",
    "date_created": "1687501112"
  },
  {
    "id": "BCBSCMPN-875011",
    "name": "Blue Horizon",
    "owner": "John Doe",
    "email": "john.doe@example.com",
    "address": "123 Main Street, City",
    "company": "ABC Bus Company",
    "mobile_number": "123-456-7890",
    "date_created": "1687501112"
  }
]

Update Bus Record

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

Method: POST

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

Query Parameters

Parameter Type Description Required
id string The unique bus ID.
name string The name of the bus line.

Payload

Field Type Description Required
owner string The name of the bus company owner.
email string The bus company e-mail address.
address string The bus company address.
mobile_number string The bus company phone number.

Sample Request

Payload:

{
  "owner": "Daniel Martinez",
  "email": "daniel.martinez@example.com"
}

Response:

{
  "id": "BCBSCMPN-875011",
  "name": "Blue Horizon",
  "owner": "Daniel Martinez",
  "email": "daniel.martinez@example.com",
  "address": "123 Main Street, City",
  "company": "ABC Bus Company",
  "mobile_number": "123-456-7890",
  "date_created": "1687501112"
}