File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -134,4 +134,28 @@ describe('offers', () => {
134134
135135 expect ( response . data ) . toStrictEqual ( mockOfferPriced )
136136 } )
137+
138+ test ( 'should get all fares for same itinerary' , async ( ) => {
139+ const firstClassSlices = mockOffer . slices . map ( ( slice ) => {
140+ return {
141+ ...slice ,
142+ fare_brand_name : 'First' ,
143+ }
144+ } )
145+ const mockFirstClassOffer = {
146+ ...mockOffer ,
147+ id : 'off_0000B50zZOir8zhPjDwwGi' ,
148+ slices : firstClassSlices ,
149+ }
150+ const offers = [ mockOffer , mockFirstClassOffer ]
151+ nock ( / ( .* ) / )
152+ . post ( `/air/offers/${ mockOffer . id } /upsell` )
153+ . reply ( 200 , { data : offers } )
154+
155+ const response = await new Offers (
156+ new Client ( { token : 'mockToken' } ) ,
157+ ) . upsellFares ( mockOffer . id )
158+
159+ expect ( response . data ) . toStrictEqual ( offers )
160+ } )
137161} )
Original file line number Diff line number Diff line change @@ -114,4 +114,16 @@ export class Offers extends Resource {
114114 path : `${ this . path } /${ offerId } /actions/price` ,
115115 data : params ,
116116 } )
117+
118+ /**
119+ * Retrieve all fare brands given a basic fare offer. Applicable only for some airlines. All of the returned offers have the same itinerary.
120+ * @param {string } offerId - Duffel's unique identifier for the offer
121+ */
122+ public upsellFares = async (
123+ offerId : string ,
124+ ) : Promise < DuffelResponse < Offer [ ] > > =>
125+ this . request ( {
126+ method : 'POST' ,
127+ path : `${ this . path } /${ offerId } /upsell` ,
128+ } )
117129}
You can’t perform that action at this time.
0 commit comments