diff --git a/.eslintrc.js b/.eslintrc.js index 670033cb..c86434fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -55,11 +55,13 @@ module.exports = { ' ', '^[-\\w]+/[-\\w\\.]+$', '^[a-z]{3,4}_[a-zA-Z0-9]{21,23}$', - 'pas_00009hj8USM7Ncg31cBCLL', - 'ord_00009hthhsUZ8W4LxQgkjo', - 'ser_00009UhD4ongolulWd9123', - 'seg_00009hj8USM7Ncg31cB456', - 'pit_00009htYpSCXrwaB9DnUm2', + 'pas_[a-zA-Z0-9]{22}', + 'ord_[a-zA-Z0-9]{22}', + 'ser_[a-zA-Z0-9]{22}', + 'seg_[a-zA-Z0-9]{22}', + 'sto_[a-zA-Z0-9]{22}', + 'pit_[a-zA-Z0-9]{22}', + 'quo_[a-zA-Z0-9]{22}', 'g2wAAAACbQAAABBBZXJvbWlzdC1LaGFya2l2bQAAAB=', 'Earhart', 'Embraer', diff --git a/src/Places/Suggestions/mockSuggestions.ts b/src/Places/Suggestions/mockSuggestions.ts index 809ee97b..21cb386e 100644 --- a/src/Places/Suggestions/mockSuggestions.ts +++ b/src/Places/Suggestions/mockSuggestions.ts @@ -18,6 +18,7 @@ export const mockPlacesSuggestionsResponse: Places = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, airports: [ { @@ -30,11 +31,14 @@ export const mockPlacesSuggestionsResponse: Places = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + type: 'airport', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, ], diff --git a/src/Stays/StaysTypes.ts b/src/Stays/StaysTypes.ts index 60fec311..162b2e6c 100644 --- a/src/Stays/StaysTypes.ts +++ b/src/Stays/StaysTypes.ts @@ -13,6 +13,7 @@ export interface StaysBed { } export interface StaysRating { + // eslint-disable-next-line spellcheck/spell-checker /** * The source of this rating. Possible values: `"aaa"` (American Automobile Association Diamond Rating), `"northstar"` (Northstar Crown Rating), `"priceline"` (Priceline star rating) */ diff --git a/src/Stays/mocks.ts b/src/Stays/mocks.ts index c74de199..a03347d3 100644 --- a/src/Stays/mocks.ts +++ b/src/Stays/mocks.ts @@ -165,6 +165,7 @@ export const MOCK_BOOKING: StaysBooking = { email: 'jean@example.com', phone_number: '+4407242242424', status: 'confirmed', + // eslint-disable-next-line spellcheck/spell-checker reference: 'dhg-4692ARxBI85qTkbDDEZMO8', id: 'bok_0000ARxBI85qTkbDDEZMO3', confirmed_at: '2022-12-20T15:45:03.000000Z', @@ -173,7 +174,7 @@ export const MOCK_BOOKING: StaysBooking = { cancelled_at: null, guests: [ { - given_name: 'Raiden', + given_name: 'John', family_name: 'Ei', }, ], @@ -194,7 +195,7 @@ export const MOCK_CREATE_BOOKING_PAYLOAD: StaysBookingPayload = { guests: [ { given_name: 'Jean', - family_name: 'Gunnhildr', + family_name: 'Gun', }, ], email: 'jean@example.com', diff --git a/src/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes.ts b/src/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes.ts index 37b36f49..249b8bd4 100644 --- a/src/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes.ts +++ b/src/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes.ts @@ -11,6 +11,17 @@ export type AirlineInitiatedChangeAvailableAction = | 'change' | 'update' +/** + * The associated Travel Agent Ticket, if any, for this Airline-Initiated Change. + * This value will be present for Airline-Initiated changes that take some time to be processed. + */ +export interface TravelAgentTicket { + id: string + external_ticket_id: string +} + +type EmptyObject = Record + export interface AirlineInitiatedChange { /** * The action taken in response to this airline-initiated change. Accepted, @@ -66,7 +77,7 @@ export interface AirlineInitiatedChange { * Change. This value will be present for Airline-Initiated changes that take * some time to be processed. */ - travel_agent_ticket: any | null + travel_agent_ticket: TravelAgentTicket | EmptyObject | null /** * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which diff --git a/src/booking/AirlineInitiatedChanges/mockAirlineInitiatedChanges.ts b/src/booking/AirlineInitiatedChanges/mockAirlineInitiatedChanges.ts index f5e8e479..abf234a1 100644 --- a/src/booking/AirlineInitiatedChanges/mockAirlineInitiatedChanges.ts +++ b/src/booking/AirlineInitiatedChanges/mockAirlineInitiatedChanges.ts @@ -11,6 +11,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { penalty_amount: '100.00', allowed: true, }, + refund_before_departure: null, }, destination_type: 'airport', origin_type: 'airport', @@ -23,6 +24,9 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { baggages: [], }, ], + origin_terminal: 'A', + destination_terminal: '1', + stops: [], origin: { time_zone: 'Europe/London', name: 'Heathrow Airport', @@ -34,11 +38,13 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_code: 'LHR', iata_city_code: 'LON', city_name: 'London', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '0472', @@ -67,7 +73,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { }, id: 'seg_00009htYpSCXrwaB9Dn456', duration: 'PT2H10M', - distance: null, + distance: '123.1', destination: { time_zone: 'Europe/Madrid', name: 'Barcelona–El Prat Josep Tarradellas Airport', @@ -80,6 +86,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_city_code: 'BCN', city_name: 'Barcelona', city: null, + type: 'airport', }, departing_at: '2023-03-26T06:15:00', arriving_at: '2023-03-26T09:25:00', @@ -101,11 +108,13 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_code: 'LHR', iata_city_code: 'LON', city_name: 'London', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, id: 'sli_00009htYpSCXrwaB9Dn123', @@ -122,6 +131,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_city_code: 'BCN', city_name: 'Barcelona', city: null, + type: 'airport', }, }, ], @@ -137,6 +147,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { penalty_amount: '100.00', allowed: true, }, + refund_before_departure: null, }, destination_type: 'airport', origin_type: 'airport', @@ -149,6 +160,9 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { baggages: [], }, ], + destination_terminal: '1', + origin_terminal: 'B', + stops: [], origin: { time_zone: 'Europe/London', name: 'Heathrow Airport', @@ -160,11 +174,13 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_code: 'LHR', iata_city_code: 'LON', city_name: 'London', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '0474', @@ -193,7 +209,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { }, id: 'seg_00009htYpSCXrwaB9Dn457', duration: 'PT2H15M', - distance: null, + distance: '42.1', destination: { time_zone: 'Europe/Madrid', name: 'Barcelona–El Prat Josep Tarradellas Airport', @@ -206,10 +222,12 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_city_code: 'BCN', city_name: 'Barcelona', city: null, + type: 'airport', }, departing_at: '2023-03-28T11:00:00', arriving_at: '2023-03-28T14:15:00', aircraft: { + // eslint-disable-next-line spellcheck/spell-checker name: 'Airbus A320neo', id: 'arc_00009lcSPZuSbgKG1u4Pkn', iata_code: '32N', @@ -227,11 +245,13 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_code: 'LHR', iata_city_code: 'LON', city_name: 'London', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, id: 'sli_00009htYpSCXrwaB9Dn124', @@ -247,6 +267,7 @@ export const mockAirlineInitiatedChange: AirlineInitiatedChange = { iata_code: 'BCN', iata_city_code: 'BCN', city_name: 'Barcelona', + type: 'airport', city: null, }, }, diff --git a/src/booking/Identity/ComponentClientKey/ComponentClientKeys.spec.ts b/src/booking/Identity/ComponentClientKey/ComponentClientKeys.spec.ts index 8a87c155..e84dce6b 100644 --- a/src/booking/Identity/ComponentClientKey/ComponentClientKeys.spec.ts +++ b/src/booking/Identity/ComponentClientKey/ComponentClientKeys.spec.ts @@ -18,6 +18,7 @@ describe('component client keys', () => { ).create() const regex_to_match_jwt = new RegExp( + // eslint-disable-next-line spellcheck/spell-checker 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.[a-zA-Z0-9_-]*.[a-zA-Z0-9_-]*', ) expect(response.data.component_client_key).toMatch(regex_to_match_jwt) diff --git a/src/booking/Identity/ComponentClientKey/mockComponentClientKey.ts b/src/booking/Identity/ComponentClientKey/mockComponentClientKey.ts index c845f041..7e30d4f0 100644 --- a/src/booking/Identity/ComponentClientKey/mockComponentClientKey.ts +++ b/src/booking/Identity/ComponentClientKey/mockComponentClientKey.ts @@ -2,5 +2,6 @@ import { type ComponentClientKey } from './types' export const mockComponentClientKey: ComponentClientKey = { component_client_key: + // eslint-disable-next-line spellcheck/spell-checker 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiaWN1XzAwMDBBZ1ppdHBPblF0ZDNOUXhqd08iLCJvcmRlcl9pZCI6Im9yZF8wMDAwQUJkWm5nZ1NjdDdCb3JhVTFvIiwiaWF0IjoxNTE2MjM5MDIyfQ.GtJDKrfum7aLlNaXmUj-RtQIbx0-Opwjdid0fiJk6DE', } diff --git a/src/booking/OfferRequests/OfferRequestsTypes.ts b/src/booking/OfferRequests/OfferRequestsTypes.ts index 64887d33..b54e76b5 100644 --- a/src/booking/OfferRequests/OfferRequestsTypes.ts +++ b/src/booking/OfferRequests/OfferRequestsTypes.ts @@ -1,7 +1,7 @@ import { Airline, CabinClass, - DuffelPassengerType, + PassengerType, Place, PlaceType, } from '../../types' @@ -75,7 +75,7 @@ export interface CreateOfferRequestAdultPassenger * specify their `age` instead of a `type`. A passenger can have only a type * or an age, but not both. */ - type: Extract + type: Extract } export interface CreateOfferRequestNonAdultPassenger @@ -157,7 +157,7 @@ export interface OfferRequestPassenger { /** * The type of the passenger. */ - type?: DuffelPassengerType + type?: PassengerType /** * The passenger's family name. Only `space`, `-`, `'`, and letters from the `ASCII`, `Latin-1 Supplement` and `Latin diff --git a/src/booking/OfferRequests/mockOfferRequest.ts b/src/booking/OfferRequests/mockOfferRequest.ts index 2c569c54..331969e6 100644 --- a/src/booking/OfferRequests/mockOfferRequest.ts +++ b/src/booking/OfferRequests/mockOfferRequest.ts @@ -42,26 +42,8 @@ export const mockOfferRequest: OfferRequest = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, destination_type: 'airport', destination: { @@ -81,26 +63,8 @@ export const mockOfferRequest: OfferRequest = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, departure_date: '2020-04-24', }, diff --git a/src/booking/Offers/OfferTypes.ts b/src/booking/Offers/OfferTypes.ts index f2b4c57d..56112898 100644 --- a/src/booking/Offers/OfferTypes.ts +++ b/src/booking/Offers/OfferTypes.ts @@ -4,13 +4,14 @@ import { Airport, CabinClass, CreateOfferRequestPassengerFareType, - DuffelPassengerType, + PassengerType, FlightsConditions, LoyaltyProgrammeAccount, OfferSliceConditions, PaginationMeta, Place, PlaceType, + Stop, } from '../../types' /** @@ -331,12 +332,12 @@ export interface OfferPassenger { /** * The age of the passenger on the departure_date of the final slice. */ - age?: number + age: number | null /** * The type of the passenger. */ - type?: DuffelPassengerType + type: PassengerType | null /** * The passenger's family name. Only `space`, `-`, `'`, and letters from the `ASCII`, `Latin-1 Supplement` and `Latin @@ -450,7 +451,7 @@ export interface OfferSlice { * - `"4"`: premium seating, additional legroom and recline. Situated in business class or higher. * - `"5"`: deluxe seating, additional legroom and reclines to lie flat position. Situated in business class or higher. */ - ngs_shelf: number + ngs_shelf: number | null } export interface OfferSliceSegment { @@ -534,34 +535,7 @@ export interface OfferSliceSegment { /** * Additional segment-specific information about the stops, if any, included in the segment */ - stops?: OfferSliceSegmentStop[] -} - -export interface OfferSliceSegmentStop { - /** - * Duffel's unique identifier for the Stop - */ - id: string - - /** - * The airport at which the Stop happens - */ - airport: Airport - - /** - * The ISO 8601 datetime at which the Stop is scheduled to arrive, in the airport's timezone (see destination.timezone) - */ - arriving_at: string - - /** - * The ISO 8601 datetime at which the Stop is scheduled to depart, in the airport's timezone (see origin.timezone) - */ - departing_at: string - - /** - * The duration of the Stop, represented as a ISO 8601 duration - */ - duration: string + stops: Array } export type WiFiAmenityCost = 'free' | 'paid' | 'free or paid' | 'n/a' @@ -607,70 +581,72 @@ export interface OfferSliceSegmentPassenger { /** * Data about the cabin that the passenger will be flying in for this segment */ - cabin: { - /** - * The name of the cabin class - */ - name: CabinClass + cabin: OfferSliceSegmentPassengerCabin | null +} + +export interface OfferSliceSegmentPassengerCabin { + /** + * The name of the cabin class + */ + name: CabinClass + + /** + * TThe name that the marketing carrier uses to market this cabin class + */ + marketing_name: string + /** + * The amenities specific to this cabin class on this plane + */ + amenities: { /** - * TThe name that the marketing carrier uses to market this cabin class + * If Wi-Fi is available, information on its cost, availability, etc */ - marketing_name: string + wifi: { + /** + * Whether Wi-Fi is available in this cabin + */ + available: boolean + + /** + * The cost, if any, to use the Wi-Fi + */ + cost: WiFiAmenityCost + } | null /** - * The amenities specific to this cabin class on this plane + * Information on the standard seat in this cabin class. Exceptions may apply, such as on exit rows. */ - amenities: { + seat: { /** - * If Wi-Fi is available, information on its cost, availability, etc + * The distance from a point on a seat to the seat front/behind it, in inches, or "n/a" if not available */ - wifi: { - /** - * Whether Wi-Fi is available in this cabin - */ - available: boolean - - /** - * The cost, if any, to use the Wi-Fi - */ - cost: WiFiAmenityCost - } | null + pitch: SeatPitch /** - * Information on the standard seat in this cabin class. Exceptions may apply, such as on exit rows. + * A summary of the seat characteristics for the cabin. + * Includes the following: + * - `"standard"` - typical seating with regular legroom / recline + * - `"extra_legroom"` - typical seating with additional legroom + * - `"skycouch"` - a row of seats converted into a couch layout + * - `"recliner"` - seating with additional legroom and recline + * - `"angle_flat"` - seating with additional legroom and near flat recline + * - `"full_flat_pod"` - seating with full flat recline and enclosing privacy screens + * - `"private_suite"` - a full suite, typically including a bed and recliner seat */ - seat: { - /** - * The distance from a point on a seat to the seat front/behind it, in inches, or "n/a" if not available - */ - pitch: SeatPitch - - /** - * A summary of the seat characteristics for the cabin. - * Includes the following: - * - `"standard"` - typical seating with regular legroom / recline - * - `"extra_legroom"` - typical seating with additional legroom - * - `"skycouch"` - a row of seats converted into a couch layout - * - `"recliner"` - seating with additional legroom and recline - * - `"angle_flat"` - seating with additional legroom and near flat recline - * - `"full_flat_pod"` - seating with full flat recline and enclosing privacy screens - * - `"private_suite"` - a full suite, typically including a bed and recliner seat - */ - type: SeatType - } | null + type: SeatType + } | null + /** + * If power (AC and/or USB) is available, information on what is available + */ + power: { /** - * If power (AC and/or USB) is available, information on what is available + * Whether there is power available or not in this cabin */ - power: { - /** - * Whether there is power available or not in this cabin - */ - available: boolean - } | null - } - } | null + available: boolean + } | null + } } export type BaggageType = 'carry_on' | 'checked' diff --git a/src/booking/Offers/mockOffer.ts b/src/booking/Offers/mockOffer.ts index 7db90527..25862a2a 100644 --- a/src/booking/Offers/mockOffer.ts +++ b/src/booking/Offers/mockOffer.ts @@ -36,6 +36,7 @@ export const mockOffer: Offer = { }, ], origin_terminal: 'B', + stops: [], origin: { time_zone: 'Europe/London', name: 'Heathrow', @@ -46,11 +47,14 @@ export const mockOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + type: 'airport', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -91,11 +95,14 @@ export const mockOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -119,11 +126,13 @@ export const mockOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, id: 'sli_00009htYpSCXrwaB9Dn123', @@ -141,11 +150,13 @@ export const mockOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, conditions: { @@ -154,6 +165,7 @@ export const mockOffer: Offer = { penalty_amount: '100.00', allowed: true, }, + refund_before_departure: null, advance_seat_selection: false, priority_boarding: false, priority_check_in: false, diff --git a/src/booking/Offers/mockPartialOffer.ts b/src/booking/Offers/mockPartialOffer.ts index 0794b083..631a5d13 100644 --- a/src/booking/Offers/mockPartialOffer.ts +++ b/src/booking/Offers/mockPartialOffer.ts @@ -46,11 +46,14 @@ export const mockPartialOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -81,6 +84,7 @@ export const mockPartialOffer: Offer = { duration: 'PT02H26M', distance: '424.2', destination_terminal: '5', + stops: [], destination: { time_zone: 'Europe/London', name: 'Heathrow', @@ -91,11 +95,14 @@ export const mockPartialOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -119,11 +126,13 @@ export const mockPartialOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, id: 'sli_00009htYpSCXrwaB9Dn123', @@ -141,11 +150,13 @@ export const mockPartialOffer: Offer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, conditions: { @@ -154,6 +165,7 @@ export const mockPartialOffer: Offer = { penalty_amount: '100.00', allowed: true, }, + refund_before_departure: null, advance_seat_selection: false, priority_boarding: false, priority_check_in: false, diff --git a/src/booking/OrderCancellations/OrderCancellationsTypes.ts b/src/booking/OrderCancellations/OrderCancellationsTypes.ts index 7e70cdc7..3769308b 100644 --- a/src/booking/OrderCancellations/OrderCancellationsTypes.ts +++ b/src/booking/OrderCancellations/OrderCancellationsTypes.ts @@ -14,6 +14,43 @@ export interface ListOrderCancellationsParams extends PaginationMeta { order_id?: string } +export interface OrderCancellationAirlineCredit { + /** + * Duffel's unique identifier for the airline credit + */ + id: string + + /** + * The human-readable name used by the airline to categorize the type of credit being offered. This name should help when trying to understand the airline's conditions of use which apply to this credit. + */ + credit_name: string + + /** + * The code which identifies the airline credit to the airline and will be used to redeem the airline credit + */ + credit_code: string + + /** + * The monetary value associated with this airline credit + */ + credit_amount: string + + /** + * The currency in which this airline credit is issued, as an ISO 4217 currency code + */ + credit_currency: string + + /** + * The date the credit was issued. It is important to note that this date might not be the same as the date of cancellation. Often airlines associate credits with tickets, in which case the date of issue is considered to be the date the ticket was originally issued. Airline credits may have expiration dates which are based on the date of issue. Airlines don't always reliably disclose the expiration date in their APIs at the time of cancellation, so we are unable to return this information on airline credits. To get the latest info on expiration dates for airline credits we recommend checking directly with the airlines to determine the specific conditions of use for the credit. + */ + issued_on: string + + /** + * Duffel's unique identifier for the passenger on the order that the credit is associated with + */ + passenger_id: string +} + export interface OrderCancellation { /** * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime that indicates when the order cancellation was confirmed @@ -62,4 +99,10 @@ export interface OrderCancellation { | 'card' | 'voucher' | 'awaiting_payment' + | 'airline_credits' + + /** + * The airline credits for this OrderCancellation + */ + airline_credits: OrderCancellationAirlineCredit[] } diff --git a/src/booking/OrderCancellations/mockOrderCancellations.ts b/src/booking/OrderCancellations/mockOrderCancellations.ts index 796eeeb1..d55a4b24 100644 --- a/src/booking/OrderCancellations/mockOrderCancellations.ts +++ b/src/booking/OrderCancellations/mockOrderCancellations.ts @@ -10,4 +10,5 @@ export const mockOrderCancellation: OrderCancellation = { expires_at: '2020-01-17T10:42:14.545052Z', created_at: '2020-04-11T15:48:11.642Z', confirmed_at: '2020-01-17T11:51:43.114803Z', + airline_credits: [], } diff --git a/src/booking/OrderChangeOffers/mockOrderChangeOffer.ts b/src/booking/OrderChangeOffers/mockOrderChangeOffer.ts index 6027a8df..6b3b455a 100644 --- a/src/booking/OrderChangeOffers/mockOrderChangeOffer.ts +++ b/src/booking/OrderChangeOffers/mockOrderChangeOffer.ts @@ -7,6 +7,7 @@ export const mockOrderChangeOffer: OrderChangeOffer = { { segments: [ { + stops: [], origin_terminal: 'B', origin: { time_zone: 'Europe/London', @@ -18,11 +19,14 @@ export const mockOrderChangeOffer: OrderChangeOffer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -63,11 +67,14 @@ export const mockOrderChangeOffer: OrderChangeOffer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -97,26 +104,8 @@ export const mockOrderChangeOffer: OrderChangeOffer = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, id: 'sli_00009htYpSCXrwaB9Dn123', duration: 'PT02H26M', @@ -138,26 +127,8 @@ export const mockOrderChangeOffer: OrderChangeOffer = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, }, ], @@ -165,6 +136,7 @@ export const mockOrderChangeOffer: OrderChangeOffer = { { segments: [ { + stops: [], origin_terminal: 'B', origin: { time_zone: 'Europe/London', @@ -176,11 +148,14 @@ export const mockOrderChangeOffer: OrderChangeOffer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -221,11 +196,14 @@ export const mockOrderChangeOffer: OrderChangeOffer = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -255,26 +233,8 @@ export const mockOrderChangeOffer: OrderChangeOffer = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, id: 'sli_00009htYpSCXrwaB9Dn123', duration: 'PT02H26M', @@ -296,26 +256,8 @@ export const mockOrderChangeOffer: OrderChangeOffer = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, }, ], diff --git a/src/booking/OrderChangeRequests/mockOrderChangeRequests.ts b/src/booking/OrderChangeRequests/mockOrderChangeRequests.ts index ab899e43..d3b650b4 100644 --- a/src/booking/OrderChangeRequests/mockOrderChangeRequests.ts +++ b/src/booking/OrderChangeRequests/mockOrderChangeRequests.ts @@ -26,26 +26,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, destination: { type: 'airport', @@ -64,26 +46,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, departure_date: '2020-04-24', cabin_class: 'economy', @@ -98,6 +62,7 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { { segments: [ { + stops: [], origin_terminal: 'B', origin: { time_zone: 'Europe/London', @@ -109,11 +74,14 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -154,11 +122,14 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -188,26 +159,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, id: 'sli_00009htYpSCXrwaB9Dn123', duration: 'PT02H26M', @@ -229,26 +182,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, }, ], @@ -257,6 +192,7 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { segments: [ { origin_terminal: 'B', + stops: [], origin: { time_zone: 'Europe/London', name: 'Heathrow', @@ -267,11 +203,14 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -312,11 +251,14 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -346,26 +288,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, id: 'sli_00009htYpSCXrwaB9Dn123', duration: 'PT02H26M', @@ -387,26 +311,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, }, ], @@ -450,26 +356,8 @@ export const mockOrderChangeRequestAltered: OrderChangeRequestResponse = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, destination: { type: 'airport', @@ -490,7 +378,6 @@ export const mockOrderChangeRequestAltered: OrderChangeRequestResponse = { iata_country_code: 'US', iata_code: 'NYC', }, - airports: null, }, departure_date: '2020-04-24', cabin_class: 'economy', diff --git a/src/booking/OrderChanges/OrderChangesTypes.ts b/src/booking/OrderChanges/OrderChangesTypes.ts index 40aa722e..e83ccbdd 100644 --- a/src/booking/OrderChanges/OrderChangesTypes.ts +++ b/src/booking/OrderChanges/OrderChangesTypes.ts @@ -4,7 +4,7 @@ export interface OrderChange { /** * The price of this offer as a change to your existing order, excluding taxes */ - change_total_amount: string | null + change_total_amount: string /** * The currency of the change_total_amount, as an ISO 4217 currency code. @@ -13,7 +13,7 @@ export interface OrderChange { * by the airline (which will usually be based on the country where your * IATA agency is registered). */ - change_total_currency: string | null + change_total_currency: string /** * Whether the order was created in live mode. This field will be set to `true` @@ -29,7 +29,7 @@ export interface OrderChange { /** * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime that indicates when the order change was confirmed */ - confirmed_at: string + confirmed_at: string | null /** * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the offer will expire @@ -45,7 +45,7 @@ export interface OrderChange { /** * The price of this offer if it was newly purchased, excluding taxes */ - new_total_amount: string | null + new_total_amount: string /** * The currency of the new_total_amount, as an ISO 4217 currency code. @@ -64,7 +64,7 @@ export interface OrderChange { /** * The penalty price imposed by the airline for making this change */ - penalty_amount: string | null + penalty_total_amount: string | null /** * The currency of the penalty_amount, as an ISO 4217 currency code. @@ -73,19 +73,15 @@ export interface OrderChange { * currency provided by the airline (which will usually be based on * the country where your IATA agency is registered). */ - penalty_currency: string | null + penalty_total_currency: string | null /** - * Where the refund, once confirmed, will be sent. card is currently a restricted feature. - * `awaiting_payment` is for pay later orders where no payment has been made yet. + * Where the refund, once confirmed, will be sent. + * Refunds are indicated by a negative change_total_amount. + * If the change does not require a refund, this field will be null. + * original_form_of_payment refers to the form of payment used to create the order. */ - refund_to: - | 'arc_bsp_cash' - | 'balance' - | 'card' - | 'voucher' - | 'awaiting_payment' - | 'original_form_of_payment' + refund_to: 'voucher' | 'original_form_of_payment' /** * The slices to be added and/or removed diff --git a/src/booking/OrderChanges/mockOrderChanges.ts b/src/booking/OrderChanges/mockOrderChanges.ts index 6ee7cc26..d70195bb 100644 --- a/src/booking/OrderChanges/mockOrderChanges.ts +++ b/src/booking/OrderChanges/mockOrderChanges.ts @@ -6,6 +6,7 @@ export const mockOrderChange: OrderChange = { { segments: [ { + stops: [], origin_terminal: 'B', origin: { time_zone: 'Europe/London', @@ -17,11 +18,14 @@ export const mockOrderChange: OrderChange = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -62,11 +66,14 @@ export const mockOrderChange: OrderChange = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -96,26 +103,8 @@ export const mockOrderChange: OrderChange = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, id: 'sli_00009htYpSCXrwaB9Dn123', duration: 'PT02H26M', @@ -137,26 +126,8 @@ export const mockOrderChange: OrderChange = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, }, ], @@ -164,6 +135,7 @@ export const mockOrderChange: OrderChange = { { segments: [ { + stops: [], origin_terminal: 'B', origin: { time_zone: 'Europe/London', @@ -175,11 +147,14 @@ export const mockOrderChange: OrderChange = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, operating_carrier_flight_number: '4321', @@ -220,11 +195,14 @@ export const mockOrderChange: OrderChange = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, departing_at: '2020-06-13T16:38:02', @@ -254,26 +232,8 @@ export const mockOrderChange: OrderChange = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, id: 'sli_00009htYpSCXrwaB9Dn123', duration: 'PT02H26M', @@ -295,33 +255,15 @@ export const mockOrderChange: OrderChange = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, }, ], }, - refund_to: 'arc_bsp_cash', - penalty_currency: 'GBP', - penalty_amount: '15.50', + refund_to: 'original_form_of_payment', + penalty_total_currency: 'GBP', + penalty_total_amount: '15.50', order_id: 'ord_0000A3tQcCRZ9R8OY0QlxA', new_total_currency: 'GBP', new_total_amount: '60.10', diff --git a/src/booking/Orders/OrdersTypes.ts b/src/booking/Orders/OrdersTypes.ts index 184a01bb..7b3442a5 100644 --- a/src/booking/Orders/OrdersTypes.ts +++ b/src/booking/Orders/OrdersTypes.ts @@ -6,7 +6,7 @@ import { CabinClass, DuffelPassengerGender, DuffelPassengerTitle, - DuffelPassengerType, + PassengerType, FlightsConditions, LoyaltyProgrammeAccount, OfferAvailableServiceBaggage, @@ -157,7 +157,7 @@ export interface OrderPassenger { * The type of the passenger * @return "adult", "child", or "infant_without_seat" */ - type: DuffelPassengerType + type: PassengerType /** * The id of the infant associated with this passenger * @return "adult", "child", or "infant_without_seat" @@ -168,6 +168,20 @@ export interface OrderPassenger { * The **Loyalty Programme Accounts** for this passenger. */ loyalty_programme_accounts?: LoyaltyProgrammeAccount[] + + /** + * The passenger's email address. + * Note that this data may differ from the airline's records if it was updated directly with the airline since the order was created. + * @xample "amelia@duffel.com" + */ + email: string + + /** + * The passenger's phone number in E.164 (international) format. + * Note that this data may differ from the airline's records if it was updated directly with the airline since the order was created. + * @xample "442080160509" + */ + phone_number: string } export interface OrderPassengerIdentityDocument { @@ -215,7 +229,7 @@ export interface OrderSliceSegment { /** * The aircraft that the operating carrier will use to operate this segment */ - aircraft?: Aircraft + aircraft: Aircraft /** * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the segment is scheduled to arrive, in the destination airport timezone (see destination.timezone) */ @@ -232,11 +246,11 @@ export interface OrderSliceSegment { * The terminal at the destination airport where the segment is scheduled to arrive * @example "5" */ - destination_terminal?: string | null + destination_terminal: string /** * The duration of the segment, represented as a [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601#Durations) duration */ - duration?: string + duration: string /** * Duffel's unique identifier for the segment. * It identifies the segment of an order (i.e. the same segment across orders will have different ids. @@ -268,7 +282,7 @@ export interface OrderSliceSegment { * The terminal at the origin airport from which the segment is scheduled to depart * @example "B" */ - origin_terminal?: string | null + origin_terminal: string /** * Additional segment-specific information about the passengers included in the offer (e.g. their baggage allowance and the cabin class they will be travelling in) */ @@ -277,7 +291,47 @@ export interface OrderSliceSegment { * The distance of the segment in kilometres * @example "424.2" */ - distance?: string | null + distance: string + + /** + * Additional segment-specific information about the stops, if any, included in the segment + */ + stops: Array +} + +export interface Stop { + /** + * The airport at which the stop happens + */ + airport: Airport + + /** + * The ISO 8601 datetime at which the stop is scheduled to arrive, in the airport's timezone (see destination.timezone) + * + * @example "2020-06-13T16:38:02" + */ + arriving_at: string + + /** + * The ISO 8601 datetime at which the stop is scheduled to depart, in the airport's timezone (see origin.timezone) + * + * @example "2020-06-13T16:38:02" + */ + departing_at: string + + /** + * The duration of the stop, represented as a ISO 8601 duration + * + * @example "PT02H26M" + */ + duration: string + + /** + * Duffel's unique identifier for the resource + * + * @example "sto_00009htYpSCXrwaB9Dn456" + */ + id: string } export interface OrderSlice { @@ -342,6 +396,11 @@ export interface OrderPaymentStatus { * Price Guarantee means it will hold price */ price_guarantee_expires_at?: string + + /** + * The ISO 8601 datetime at which the Order was paid for, if at all + */ + paid_at: string | null } /** @@ -365,6 +424,12 @@ export interface OrderDocument { * The type of document */ type: OrderDocumentsType + + /** + * The list of passenger ids the document applies to + * @example ["pas_00009hj8USM7Ncg31cBCLL"] + */ + passenger_ids: string[] } export interface OrderPayment { @@ -507,7 +572,7 @@ export interface Order { /** * The airline-initiated changes for this order. */ - airline_initiated_changes?: AirlineInitiatedChange[] + airline_initiated_changes: AirlineInitiatedChange[] /** * The available actions you can take on this order through our API. @@ -520,6 +585,15 @@ export interface Order { * @example: ["cancel","update"] */ available_actions: OrderAvailableAction[] + + /** + * Airlines are always the source of truth for orders. The orders returned in the Duffel API + * are a view of those orders. This field is the ISO 8601 datetime at which the order was + * last synced with the airline. If this datetime is in the last minute you can consider the order up to date. + * + * @example "2020-04-11T15:48:11Z" + */ + synced_at: string } export type OrderAvailableAction = 'cancel' | 'change' | 'update' diff --git a/src/booking/Orders/mockOrders.ts b/src/booking/Orders/mockOrders.ts index ba8146cf..b2735045 100644 --- a/src/booking/Orders/mockOrders.ts +++ b/src/booking/Orders/mockOrders.ts @@ -45,6 +45,8 @@ export const mockCreateOrderRequest: CreateOrder = { } export const mockOrder: Order = { + synced_at: '2020-04-11T15:48:11Z', + airline_initiated_changes: [], available_actions: ['cancel', 'change'], total_currency: 'GBP', total_amount: '90.80', @@ -86,13 +88,17 @@ export const mockOrder: Order = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + type: 'airport', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, + stops: [], operating_carrier_flight_number: '4321', operating_carrier: { name: 'British Airways', @@ -136,7 +142,10 @@ export const mockOrder: Order = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, + type: 'airport', + iata_city_code: 'LON', }, departing_at: '2020-06-13T16:38:02', arriving_at: '2020-06-13T16:38:02', @@ -159,11 +168,13 @@ export const mockOrder: Order = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, id: 'sli_00009htYpSCXrwaB9Dn123', @@ -180,11 +191,13 @@ export const mockOrder: Order = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, }, conditions: { @@ -193,6 +206,7 @@ export const mockOrder: Order = { penalty_amount: '100.00', allowed: true, }, + refund_before_departure: null, }, }, ], @@ -211,6 +225,7 @@ export const mockOrder: Order = { price_guarantee_expires_at: '2020-01-17T10:42:14.545Z', payment_required_by: '2020-01-17T10:42:14.545Z', awaiting_payment: true, + paid_at: null, }, passengers: [ { @@ -228,6 +243,8 @@ export const mockOrder: Order = { account_number: '12901014', }, ], + email: 'amelia@duffel.com', + phone_number: '+442080160509', }, ], owner: { @@ -248,6 +265,7 @@ export const mockOrder: Order = { id: 'ord_00009hthhsUZ8W4LxQgkjo', documents: [ { + passenger_ids: ['pas_00009hj8USM7Ncg31cBCLL'], unique_identifier: '1252106312810', type: 'electronic_ticket', }, @@ -295,7 +313,7 @@ export const mockOnHoldOrders: Order[] = [ ], }, ], - origin_terminal: null, + origin_terminal: 'B', origin: { time_zone: 'America/Indiana/Indianapolis', name: 'Indianapolis International Airport', @@ -307,6 +325,8 @@ export const mockOnHoldOrders: Order[] = [ iata_code: 'IND', city_name: 'Indianapolis', city: null, + type: 'airport', + iata_city_code: 'IND', }, operating_carrier_flight_number: '4721', operating_carrier: { @@ -328,8 +348,8 @@ export const mockOnHoldOrders: Order[] = [ }, id: 'seg_0000A6GioOO1UDbjb7nIi9', duration: 'PT2H45M', - distance: null, - destination_terminal: null, + distance: '424.2', + destination_terminal: 'A', destination: { time_zone: 'America/New_York', name: 'Miami International Airport', @@ -340,6 +360,8 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'MIA', city_name: 'Miami', + type: 'airport', + iata_city_code: 'MIA', city: { type: 'city', name: 'Miami', @@ -348,6 +370,7 @@ export const mockOnHoldOrders: Order[] = [ iata_code: 'MIA', }, }, + stops: [], departing_at: '2021-08-07T17:53:00', arriving_at: '2021-08-07T20:38:00', aircraft: { @@ -369,6 +392,7 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'IND', city_name: 'Indianapolis', + iata_city_code: 'IND', city: null, }, id: 'sli_0000A6GioOQrJfsNjv7Z8C', @@ -385,6 +409,7 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'MIA', city_name: 'Miami', + iata_city_code: 'MIA', city: { type: 'city', name: 'Miami', @@ -395,6 +420,7 @@ export const mockOnHoldOrders: Order[] = [ }, conditions: { change_before_departure: null, + refund_before_departure: null, }, }, ], @@ -403,6 +429,7 @@ export const mockOnHoldOrders: Order[] = [ price_guarantee_expires_at: '2021-04-16T23:59:00Z', payment_required_by: '2021-04-16T23:59:00Z', awaiting_payment: true, + paid_at: null, }, passengers: [ { @@ -414,6 +441,8 @@ export const mockOnHoldOrders: Order[] = [ gender: 'm', family_name: 'SMITH', born_on: '1995-05-05', + email: 'john@duffel.com', + phone_number: '+447700900000', }, ], owner: { @@ -439,6 +468,8 @@ export const mockOnHoldOrders: Order[] = [ booking_reference: 'ZVNHEX', base_currency: 'GBP', base_amount: '72.00', + synced_at: '2020-04-11T15:48:11Z', + airline_initiated_changes: [], }, { available_actions: ['cancel', 'change'], @@ -463,7 +494,7 @@ export const mockOnHoldOrders: Order[] = [ ], }, ], - origin_terminal: null, + origin_terminal: 'C', origin: { time_zone: 'America/Indiana/Indianapolis', name: 'Indianapolis International Airport', @@ -474,6 +505,8 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'IND', city_name: 'Indianapolis', + iata_city_code: 'IND', + type: 'airport', city: null, }, operating_carrier_flight_number: '4341', @@ -496,8 +529,8 @@ export const mockOnHoldOrders: Order[] = [ }, id: 'seg_0000A6GiZRU4WXtdZJrivU', duration: 'PT2H49M', - distance: null, - destination_terminal: null, + distance: '424.2', + destination_terminal: '1', destination: { time_zone: 'America/New_York', name: 'Miami International Airport', @@ -508,6 +541,8 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'MIA', city_name: 'Miami', + type: 'airport', + iata_city_code: 'MIA', city: { type: 'city', name: 'Miami', @@ -516,6 +551,7 @@ export const mockOnHoldOrders: Order[] = [ iata_code: 'MIA', }, }, + stops: [], departing_at: '2021-08-07T11:55:00', arriving_at: '2021-08-07T14:44:00', aircraft: { @@ -537,6 +573,7 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'IND', city_name: 'Indianapolis', + iata_city_code: 'IND', city: null, }, id: 'sli_0000A6GiZRWYNJshh11hnE', @@ -553,6 +590,7 @@ export const mockOnHoldOrders: Order[] = [ iata_country_code: 'US', iata_code: 'MIA', city_name: 'Miami', + iata_city_code: 'MIA', city: { type: 'city', name: 'Miami', @@ -561,7 +599,10 @@ export const mockOnHoldOrders: Order[] = [ iata_code: 'MIA', }, }, - conditions: { change_before_departure: null }, + conditions: { + change_before_departure: null, + refund_before_departure: null, + }, }, ], services: [], @@ -569,6 +610,7 @@ export const mockOnHoldOrders: Order[] = [ price_guarantee_expires_at: '2021-04-16T23:59:00Z', payment_required_by: '2021-04-16T23:59:00Z', awaiting_payment: true, + paid_at: null, }, passengers: [ { @@ -580,6 +622,8 @@ export const mockOnHoldOrders: Order[] = [ gender: 'm', family_name: 'SMITH', born_on: '1995-05-05', + email: 'john@duffel.com', + phone_number: '+442080160509', }, ], owner: { @@ -605,6 +649,8 @@ export const mockOnHoldOrders: Order[] = [ booking_reference: 'RTEMPK', base_currency: 'GBP', base_amount: '93.00', + synced_at: '2020-04-11T15:48:11Z', + airline_initiated_changes: [], }, ] diff --git a/src/booking/PartialOfferRequests/mockPartialOfferRequest.ts b/src/booking/PartialOfferRequests/mockPartialOfferRequest.ts index 47e14008..00cc2671 100644 --- a/src/booking/PartialOfferRequests/mockPartialOfferRequest.ts +++ b/src/booking/PartialOfferRequests/mockPartialOfferRequest.ts @@ -41,26 +41,8 @@ export const mockPartialOfferRequest: OfferRequest = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, destination_type: 'airport', destination: { @@ -80,26 +62,8 @@ export const mockPartialOfferRequest: OfferRequest = { id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, - airports: [ - { - time_zone: 'Europe/London', - name: 'Heathrow', - longitude: -141.951519, - latitude: 64.068865, - id: 'arp_lhr_gb', - icao_code: 'EGLL', - iata_country_code: 'GB', - iata_code: 'LHR', - city_name: 'London', - city: { - name: 'London', - id: 'cit_lon_gb', - iata_country_code: 'GB', - iata_code: 'LON', - }, - }, - ], }, departure_date: '2020-04-24', }, diff --git a/src/notifications/Webhooks/mockWebhooks.ts b/src/notifications/Webhooks/mockWebhooks.ts index df722437..d20bf965 100644 --- a/src/notifications/Webhooks/mockWebhooks.ts +++ b/src/notifications/Webhooks/mockWebhooks.ts @@ -54,6 +54,7 @@ export const mockWebhooksListResponse: WebhooksListResponse[] = [ ] export const mockWebhooksCreateResponse: WebhooksCreateResponse = { + // eslint-disable-next-line spellcheck/spell-checker secret: 'QKfUULLQh+8SegYmIsF6kA==', url: 'https://www.example.com:4000/webhooks', updated_at: '2020-04-11T15:48:11.642Z', diff --git a/src/supportingResources/Airports/AirportsTypes.ts b/src/supportingResources/Airports/AirportsTypes.ts index 00d01faf..03148ef9 100644 --- a/src/supportingResources/Airports/AirportsTypes.ts +++ b/src/supportingResources/Airports/AirportsTypes.ts @@ -9,7 +9,7 @@ export interface Airport { * The metropolitan area where the airport is located. * Only present for airports which are registered with IATA as belonging to a metropolitan area. */ - city?: City | null + city: City | null /** * The name of the city (or cities separated by a `/`) where the airport is located */ @@ -17,7 +17,7 @@ export interface Airport { /** * The three-character IATA code for the airport */ - iata_code?: string + iata_code: string | null /** * The ISO 3166-1 alpha-2 code for the country where the city is located * @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 @@ -28,11 +28,11 @@ export interface Airport { * The 3-letter IATA code for the city where the place is located. * Only present for airports which are registered with IATA as belonging to a [metropolitan area](https://portal.iata.org/faq/articles/en_US/FAQ/How-do-I-create-a-new-Metropolitan-Area). */ - iata_city_code?: string | null + iata_city_code: string | null /** * The four-character ICAO code for the airport */ - icao_code?: string + icao_code: string /** * Duffel's unique identifier for the airport */ @@ -53,4 +53,8 @@ export interface Airport { * The time zone of the airport, specified by name from the [tz database](https://en.wikipedia.org/wiki/Tz_database) */ time_zone: string + /** + * The type of the place + */ + type: 'airport' } diff --git a/src/supportingResources/Airports/mockAirport.ts b/src/supportingResources/Airports/mockAirport.ts index 4dccceb5..aa632b50 100644 --- a/src/supportingResources/Airports/mockAirport.ts +++ b/src/supportingResources/Airports/mockAirport.ts @@ -10,10 +10,13 @@ export const mockAirport: Airport = { iata_country_code: 'GB', iata_code: 'LHR', city_name: 'London', + iata_city_code: 'LON', + type: 'airport', city: { name: 'London', id: 'cit_lon_gb', iata_country_code: 'GB', iata_code: 'LON', + type: 'city', }, } diff --git a/src/types/shared.ts b/src/types/shared.ts index ac591ab0..ae1363bc 100644 --- a/src/types/shared.ts +++ b/src/types/shared.ts @@ -6,10 +6,6 @@ import { Airport } from '../supportingResources/Airports/AirportsTypes' * @link https://portal.iata.org/faq/articles/en_US/FAQ/How-do-I-create-a-new-Metropolitan-Area */ export interface City { - /** - * The type of the place - */ - type?: 'city' /** * The three-character IATA code for the city * @example "LON" @@ -31,6 +27,14 @@ export interface City { * @example "London" */ name: string + /** + * "The airports associated to a city. This will only be provided where the `type` is `city`." + */ + airports?: Airport[] + /** + * The type of the place + */ + type: 'city' } /** @@ -41,7 +45,7 @@ export type CabinClass = 'first' | 'business' | 'premium_economy' | 'economy' /** * The type of the passenger */ -export type DuffelPassengerType = 'adult' | 'child' | 'infant_without_seat' +export type PassengerType = 'adult' | 'child' | 'infant_without_seat' /** * The passenger's title @@ -59,14 +63,66 @@ export type DuffelPassengerGender = 'm' | 'f' */ export type PassengerIdentityDocumentType = 'passport' | 'tax_id' +export type Place = (Airport & { type: 'airport' }) | (City & { type: 'city' }) + /** * The type of the origin or destination */ -export type PlaceType = 'airport' | 'city' +export type PlaceType = Place['type'] + +export type FlightsConditionAllowed = { + /** + * The currency of the `penalty_amount` as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code. + * This will be in a currency determined by the airline, which is not necessarily the same as the currency of the order or offer. + * If this is `null` then `penalty_amount` will also be `null`. + * + * @example "GBP" + */ + penalty_currency: string + /** + * If the modification is `allowed` then this is the amount payable to apply the modification to all passengers. + * If there is no penalty, the value will be zero. If the modification isn't `allowed` or the penalty is not known then this field will be `null`. + * If this is `null` then the `penalty_currency` will also be null. + * + * @example "100.00" + */ + penalty_amount: string + /** + * Whether this kind of modification is allowed post-booking + * + * @example "true" + */ + allowed: true +} + +export type FlightsConditionNotAllowed = { + /** + * The currency of the `penalty_amount` as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code. + * This will be in a currency determined by the airline, which is not necessarily the same as the currency of the order or offer. + * If this is `null` then `penalty_amount` will also be `null`. + * + * @example "GBP" + */ + penalty_currency: null + /** + * If the modification is `allowed` then this is the amount payable to apply the modification to all passengers. + * If there is no penalty, the value will be zero. If the modification isn't `allowed` or the penalty is not known then this field will be `null`. + * If this is `null` then the `penalty_currency` will also be null. + * + * @example "100.00" + */ + penalty_amount: null + /** + * Whether this kind of modification is allowed post-booking + * + * @example "true" + */ + allowed: false +} -export type Place = - | (Airport & { type?: 'airport'; airports?: Airport[] | null }) - | (City & { type?: 'city' }) +export type FlightsCondition = + | FlightsConditionAllowed + | FlightsConditionNotAllowed /** * The conditions associated with this offer, describing the kinds of modifications you can make post-booking and any penalties that will apply to those modifications. @@ -81,28 +137,7 @@ export type FlightsConditions = { * If any of the slices on the order or offer can't be refunded then the `allowed` property will be `false`. * If the airline hasn't provided any information about whether this order or offer can be refunded then this property will be `null`. */ - refund_before_departure?: { - /** - * The currency of the `penalty_amount` as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code. - * This will be in a currency determined by the airline, which is not necessarily the same as the currency of the order or offer. - * If this is `null` then `penalty_amount` will also be `null`. - * @example "GBP" - */ - penalty_currency?: string | null - /** - * If the modification is `allowed` then this is the amount payable to apply the modification to all passengers. - * If there is no penalty, the value will be zero. If the modification isn't `allowed` or the penalty is not known then this field will be `null`. - * If this is `null` then the `penalty_currency` will also be null. - * @example "100.00" - */ - penalty_amount?: string | null - /** - * Whether this kind of modification is allowed post-booking - * - * @example "true" - */ - allowed: boolean - } | null + refund_before_departure: FlightsCondition | null /** * Whether the whole order or offer can be changed before the departure of the first slice. @@ -112,28 +147,7 @@ export type FlightsConditions = { * In this case you should refer to the slices conditions to determine if any part of the order or offer is changeable. * If the airline hasn't provided any information about whether this order or offer can be changed then this property will be `null`. */ - change_before_departure?: { - /** - * The currency of the `penalty_amount` as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code. - * This will be in a currency determined by the airline, which is not necessarily the same as the currency of the order or offer. - * If this is `null` then `penalty_amount` will also be `null`. - * @example "GBP" - */ - penalty_currency?: string | null - /** - * If the modification is `allowed` then this is the amount payable to apply the modification to all passengers. - * If there is no penalty, the value will be zero. If the modification isn't `allowed` or the penalty is not known then this field will be `null`. - * If this is `null` then the `penalty_currency` will also be null. - * @example "100.00" - */ - penalty_amount?: string | null - /** - * Whether this kind of modification is allowed post-booking - * - * @example "true" - */ - allowed: boolean - } | null + change_before_departure: FlightsCondition | null } /** @@ -151,17 +165,17 @@ export type OfferSliceConditions = FlightsConditions & { /** * Whether passengers are able to select a seat prior to check in. */ - advance_seat_selection: boolean + advance_seat_selection: boolean | null /** * Whether passengers are given preferential boarding over others passengers in their cabin. */ - priority_boarding: boolean + priority_boarding: boolean | null /** * Whether passengers are given access to a fast track lane during check in. */ - priority_check_in: boolean + priority_check_in: boolean | null } /**