diff --git a/src/booking/Offers/Offers.spec.ts b/src/booking/Offers/Offers.spec.ts index 700270a7..042f6825 100644 --- a/src/booking/Offers/Offers.spec.ts +++ b/src/booking/Offers/Offers.spec.ts @@ -134,4 +134,28 @@ describe('offers', () => { expect(response.data).toStrictEqual(mockOfferPriced) }) + + test('should get all fares for same itinerary', async () => { + const firstClassSlices = mockOffer.slices.map((slice) => { + return { + ...slice, + fare_brand_name: 'First', + } + }) + const mockFirstClassOffer = { + ...mockOffer, + id: 'off_0000B50zZOir8zhPjDwwGi', + slices: firstClassSlices, + } + const offers = [mockOffer, mockFirstClassOffer] + nock(/(.*)/) + .post(`/air/offers/${mockOffer.id}/upsell`) + .reply(200, { data: offers }) + + const response = await new Offers( + new Client({ token: 'mockToken' }), + ).upsellFares(mockOffer.id) + + expect(response.data).toStrictEqual(offers) + }) }) diff --git a/src/booking/Offers/Offers.ts b/src/booking/Offers/Offers.ts index c9365d1b..754842b6 100644 --- a/src/booking/Offers/Offers.ts +++ b/src/booking/Offers/Offers.ts @@ -114,4 +114,16 @@ export class Offers extends Resource { path: `${this.path}/${offerId}/actions/price`, data: params, }) + + /** + * Retrieve all fare brands given a basic fare offer. Applicable only for some airlines. All of the returned offers have the same itinerary. + * @param {string} offerId - Duffel's unique identifier for the offer + */ + public upsellFares = async ( + offerId: string, + ): Promise> => + this.request({ + method: 'POST', + path: `${this.path}/${offerId}/upsell`, + }) }