Skip to content

Commit e0ad604

Browse files
Merge pull request #1142 from BozhidarTsvetkov/addOffersUpsell
feat(offers): upsell endpoint for all fare brands
2 parents 81734bb + 6d800c9 commit e0ad604

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/booking/Offers/Offers.spec.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff 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
})

src/booking/Offers/Offers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)