Skip to content

Commit c8b5b6f

Browse files
authored
Merge pull request #1057 from duffelhq/igorp1/tsp-428-fix-change-related-types-in-library-update-components
fix: updates order change broken types
2 parents 0979c68 + da40ea1 commit c8b5b6f

File tree

6 files changed

+133
-97
lines changed

6 files changed

+133
-97
lines changed

src/booking/OrderChangeOffers/OrderChangeOfferTypes.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { OfferSliceSegment } from '../Offers/OfferTypes'
2-
import { PlaceType, Place } from '../../types'
1+
import {
2+
OfferSliceSegment,
3+
OfferSliceSegmentPassengerBaggage,
4+
} from '../Offers/OfferTypes'
5+
import { PlaceType, Place, CabinClass } from '../../types'
36

47
/**
58
* @link https://duffel.com/docs/api/order-change-offers/schema
@@ -137,5 +140,32 @@ export interface OrderChangeOfferSlice {
137140
/**
138141
* The segments - that is, specific flights - that the airline is offering to get the passengers from the `origin` to the `destination`
139142
*/
140-
segments: Array<Omit<OfferSliceSegment, 'passengers'>>
143+
segments: Array<
144+
Pick<
145+
OfferSliceSegment,
146+
| 'aircraft'
147+
| 'arriving_at'
148+
| 'departing_at'
149+
| 'destination'
150+
| 'destination_terminal'
151+
| 'distance'
152+
| 'duration'
153+
| 'id'
154+
| 'marketing_carrier'
155+
| 'marketing_carrier_flight_number'
156+
| 'operating_carrier'
157+
| 'operating_carrier_flight_number'
158+
| 'origin'
159+
| 'origin_terminal'
160+
> & {
161+
/** 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) */
162+
passengers: Array<{
163+
baggages: OfferSliceSegmentPassengerBaggage[]
164+
cabin_class: CabinClass | null
165+
cabin_class_marketing_name: string | null
166+
passenger_id: string
167+
seat: { designator: string; disclosure: string; name: string }
168+
}>
169+
}
170+
>
141171
}

src/booking/OrderChangeOffers/mockOrderChangeOffer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const mockOrderChangeOffer: OrderChangeOffer = {
77
{
88
segments: [
99
{
10-
stops: [],
10+
passengers: [],
1111
origin_terminal: 'B',
1212
origin: {
1313
time_zone: 'Europe/London',
@@ -136,7 +136,7 @@ export const mockOrderChangeOffer: OrderChangeOffer = {
136136
{
137137
segments: [
138138
{
139-
stops: [],
139+
passengers: [],
140140
origin_terminal: 'B',
141141
origin: {
142142
time_zone: 'Europe/London',

src/booking/OrderChangeRequests/OrderChangeRequestsTypes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { OrderChangeOfferSlices } from '../OrderChangeOffers/OrderChangeOfferTyp
44
export interface OrderChangeSliceResponse {
55
remove: {
66
slice_id: string
7-
}
7+
}[]
88
add: {
99
/**
1010
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date on which the passengers want to depart
@@ -21,8 +21,8 @@ export interface OrderChangeSliceResponse {
2121
/**
2222
* The cabin that the passengers want to travel in
2323
*/
24-
cabin_class: CabinClass
25-
}
24+
cabin_class: CabinClass | null
25+
}[]
2626
}
2727

2828
export interface OrderChangeOffers {
@@ -122,7 +122,7 @@ export interface CreateOrderChangeRequest {
122122
/**
123123
* The cabin that the passengers want to travel in
124124
*/
125-
cabin_class: CabinClass
125+
cabin_class?: CabinClass | null
126126
/**
127127
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date on which the passengers want to depart
128128
*/

src/booking/OrderChangeRequests/OrderRequestChanges.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ describe('OrderChangeRequests', () => {
3131
const response = await new OrderChangeRequests(
3232
new Client({ token: 'mockToken' }),
3333
).create(mockCreateChangeRequest)
34-
expect(response.data?.slices.remove.slice_id).toBe(
34+
expect(response.data?.slices.remove[0].slice_id).toBe(
3535
mockCreateChangeRequest.slices.remove[0].slice_id,
3636
)
37-
expect(response.data?.slices.add.destination.iata_code).toBe(
37+
expect(response.data?.slices.add[0].destination.iata_code).toBe(
3838
mockCreateChangeRequest.slices.add[0].destination,
3939
)
4040
})

src/booking/OrderChangeRequests/mockOrderChangeRequests.ts

Lines changed: 90 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -5,53 +5,57 @@ import {
55

66
export const mockOrderChangeRequest: OrderChangeRequestResponse = {
77
slices: {
8-
remove: {
9-
slice_id: 'sli_00009htYpSCXrwaB9Dn123',
10-
},
11-
add: {
12-
origin: {
13-
type: 'airport',
14-
time_zone: 'Europe/London',
15-
name: 'Heathrow',
16-
longitude: -141.951519,
17-
latitude: 64.068865,
18-
id: 'arp_lhr_gb',
19-
icao_code: 'EGLL',
20-
iata_country_code: 'GB',
21-
iata_code: 'LHR',
22-
iata_city_code: 'LON',
23-
city_name: 'London',
24-
city: {
25-
name: 'London',
26-
id: 'cit_lon_gb',
8+
remove: [
9+
{
10+
slice_id: 'sli_00009htYpSCXrwaB9Dn123',
11+
},
12+
],
13+
add: [
14+
{
15+
origin: {
16+
type: 'airport',
17+
time_zone: 'Europe/London',
18+
name: 'Heathrow',
19+
longitude: -141.951519,
20+
latitude: 64.068865,
21+
id: 'arp_lhr_gb',
22+
icao_code: 'EGLL',
2723
iata_country_code: 'GB',
28-
iata_code: 'LON',
29-
type: 'city',
24+
iata_code: 'LHR',
25+
iata_city_code: 'LON',
26+
city_name: 'London',
27+
city: {
28+
name: 'London',
29+
id: 'cit_lon_gb',
30+
iata_country_code: 'GB',
31+
iata_code: 'LON',
32+
type: 'city',
33+
},
3034
},
31-
},
32-
destination: {
33-
type: 'airport',
34-
time_zone: 'Europe/London',
35-
name: 'Heathrow',
36-
longitude: -141.951519,
37-
latitude: 64.068865,
38-
id: 'arp_lhr_gb',
39-
icao_code: 'EGLL',
40-
iata_country_code: 'GB',
41-
iata_code: 'LHR',
42-
iata_city_code: 'LON',
43-
city_name: 'London',
44-
city: {
45-
name: 'London',
46-
id: 'cit_lon_gb',
35+
destination: {
36+
type: 'airport',
37+
time_zone: 'Europe/London',
38+
name: 'Heathrow',
39+
longitude: -141.951519,
40+
latitude: 64.068865,
41+
id: 'arp_lhr_gb',
42+
icao_code: 'EGLL',
4743
iata_country_code: 'GB',
48-
iata_code: 'LON',
49-
type: 'city',
44+
iata_code: 'LHR',
45+
iata_city_code: 'LON',
46+
city_name: 'London',
47+
city: {
48+
name: 'London',
49+
id: 'cit_lon_gb',
50+
iata_country_code: 'GB',
51+
iata_code: 'LON',
52+
type: 'city',
53+
},
5054
},
55+
departure_date: '2020-04-24',
56+
cabin_class: 'economy',
5157
},
52-
departure_date: '2020-04-24',
53-
cabin_class: 'economy',
54-
},
58+
],
5559
},
5660
order_id: 'ord_0000A3bQ8FJIQoEfuC07n6',
5761
order_change_offers: [
@@ -62,7 +66,7 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = {
6266
{
6367
segments: [
6468
{
65-
stops: [],
69+
passengers: [],
6670
origin_terminal: 'B',
6771
origin: {
6872
time_zone: 'Europe/London',
@@ -191,8 +195,8 @@ export const mockOrderChangeRequest: OrderChangeRequestResponse = {
191195
{
192196
segments: [
193197
{
198+
passengers: [],
194199
origin_terminal: 'B',
195-
stops: [],
196200
origin: {
197201
time_zone: 'Europe/London',
198202
name: 'Heathrow',
@@ -338,50 +342,52 @@ export const mockOrderChangeRequestAltered: OrderChangeRequestResponse = {
338342
...mockOrderChangeRequest,
339343
slices: {
340344
...mockOrderChangeRequest.slices,
341-
add: {
342-
origin: {
343-
type: 'airport',
344-
time_zone: 'Europe/London',
345-
name: 'Heathrow',
346-
longitude: -141.951519,
347-
latitude: 64.068865,
348-
id: 'arp_lhr_gb',
349-
icao_code: 'EGLL',
350-
iata_country_code: 'GB',
351-
iata_code: 'LHR',
352-
iata_city_code: 'LON',
353-
city_name: 'London',
354-
city: {
355-
name: 'London',
356-
id: 'cit_lon_gb',
345+
add: [
346+
{
347+
origin: {
348+
type: 'airport',
349+
time_zone: 'Europe/London',
350+
name: 'Heathrow',
351+
longitude: -141.951519,
352+
latitude: 64.068865,
353+
id: 'arp_lhr_gb',
354+
icao_code: 'EGLL',
357355
iata_country_code: 'GB',
358-
iata_code: 'LON',
359-
type: 'city',
356+
iata_code: 'LHR',
357+
iata_city_code: 'LON',
358+
city_name: 'London',
359+
city: {
360+
name: 'London',
361+
id: 'cit_lon_gb',
362+
iata_country_code: 'GB',
363+
iata_code: 'LON',
364+
type: 'city',
365+
},
360366
},
361-
},
362-
destination: {
363-
type: 'airport',
364-
time_zone: 'America/New_York',
365-
name: 'John F. Kennedy International Airport',
366-
longitude: -73.778519,
367-
latitude: 40.640556,
368-
id: 'arp_jfk_us',
369-
icao_code: 'KJFK',
370-
iata_country_code: 'US',
371-
iata_code: 'JFK',
372-
iata_city_code: 'NYC',
373-
city_name: 'New York',
374-
city: {
375-
type: 'city',
376-
name: 'New York',
377-
id: 'cit_nyc_us',
367+
destination: {
368+
type: 'airport',
369+
time_zone: 'America/New_York',
370+
name: 'John F. Kennedy International Airport',
371+
longitude: -73.778519,
372+
latitude: 40.640556,
373+
id: 'arp_jfk_us',
374+
icao_code: 'KJFK',
378375
iata_country_code: 'US',
379-
iata_code: 'NYC',
376+
iata_code: 'JFK',
377+
iata_city_code: 'NYC',
378+
city_name: 'New York',
379+
city: {
380+
type: 'city',
381+
name: 'New York',
382+
id: 'cit_nyc_us',
383+
iata_country_code: 'US',
384+
iata_code: 'NYC',
385+
},
380386
},
387+
departure_date: '2020-04-24',
388+
cabin_class: 'economy',
381389
},
382-
departure_date: '2020-04-24',
383-
cabin_class: 'economy',
384-
},
390+
],
385391
},
386392
}
387393

@@ -390,7 +396,7 @@ export const mockCreateChangeRequest: CreateOrderChangeRequest = {
390396
slices: {
391397
remove: [
392398
{
393-
slice_id: mockOrderChangeRequest.slices.remove.slice_id,
399+
slice_id: mockOrderChangeRequest.slices.remove[0].slice_id,
394400
},
395401
],
396402
add: [

src/booking/OrderChanges/mockOrderChanges.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const mockOrderChange: OrderChange = {
66
{
77
segments: [
88
{
9-
stops: [],
9+
passengers: [],
1010
origin_terminal: 'B',
1111
origin: {
1212
time_zone: 'Europe/London',
@@ -135,7 +135,7 @@ export const mockOrderChange: OrderChange = {
135135
{
136136
segments: [
137137
{
138-
stops: [],
138+
passengers: [],
139139
origin_terminal: 'B',
140140
origin: {
141141
time_zone: 'Europe/London',

0 commit comments

Comments
 (0)