Mee42 / cs509-project

2 stars 0 forks source link

Flight Search API Updates #20

Closed travis-mann closed 7 months ago

travis-mann commented 7 months ago

Updates to flight search API (https://github.com/Mee42/cs509-project/issues/3) based on 02/26/2024 discussion.

  1. API shall be called with a POST request containing the following JSON data:
    {departAirport: string,
    arriveAirport: string,
    departDate: string,
    connectionNum: int,
    sort: string,
    order: string}
  2. "departDate" shall be provided in the POST request with the following date format: "YYYY-MM-DD"
  3. "connectionNum" will support the following values: [0, 1, 2]. The response shall return all trips with equal to or less than this number of connecting flights.
  4. "order" field in the POST request shall support the following values: ["asc", desc"]. a. "asc" will return values in asc order based on "sort" value b. "desc" will return values in descending order based on "sort" value
  5. "sort" will support the following values: ["depart", "arrive", "travelTime"]. a. "depart" will order by departure time b. "arrive" will order the results based on arrival time, c. "travelTime" will order by the total travel time. d. Results must be ordered based on all possible options, not just the subset returned in the batch.
  6. Results shall be returned in batches of 10 references with an index number appended at the end of the endpoint. i.e., "/1" for the first 10 results, "/2" for the next 10 and so on.
  7. Results shall be returned from the API as JSON in the following format (list of trips with 1-3 flights):
{outbound: [
  // 2 connection flight example
  [
    {departAirport: string, arriveAirport: string, departDateTime: string, arriveDateTime: string, flightNumber: string},
    {departAirport: string, arriveAirport: string, departDateTime: string, arriveDateTime: string, flightNumber: string},
    {departAirport: string, arriveAirport: string, departDateTime: string, arriveDateTime: string, flightNumber: string},
  ],
  // 0 connection flight example
  [
    {departAirport: string, arriveAirport: string, departDateTime: string, arriveDateTime: string, flightNumber: string},
  ],
  ...
]}
  1. Layovers with less than 60min or more than 24hrs between flights shall not be considered

Note: Round trips will be implemented on the front end by calling the flight search API twice: once with the depature date and a second time with the airports reversed and the return date.

ChinhDangg commented 7 months ago

Updated the JSON response body sending to frontend. Added the sort and order options for filtering.

travis-mann commented 7 months ago

Example Call: POST http://localhost:8080/api/flights/submitForm/1

{
    "departAirport":"Atlanta (ATL)",
    "arriveAirport":"Tucson (TUS)",
    "departDate":"2023-01-01",
    "connectionNum":1,
    "sort":"Depart",
    "order":"DESC"
}