@duffel/api 4.25.0 → 4.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Stays/NegotiatedRates/NegotiatedRates.d.ts +42 -0
- package/dist/Stays/NegotiatedRates/NegotiatedRates.spec.d.ts +1 -0
- package/dist/Stays/NegotiatedRates/index.d.ts +1 -0
- package/dist/Stays/Stays.d.ts +2 -0
- package/dist/Stays/StaysTypes.d.ts +129 -1
- package/dist/Stays/mocks.d.ts +3 -1
- package/dist/booking/OfferRequests/OfferRequests.d.ts +7 -2
- package/dist/booking/OfferRequests/OfferRequestsTypes.d.ts +126 -1
- package/dist/booking/OfferRequests/mockOfferRequest.d.ts +2 -1
- package/dist/index.es.js +1 -1
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/typings.d.ts +313 -4
- package/package.json +11 -9
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Client } from '../../Client';
|
|
2
|
+
import { StaysNegotiatedRate, StaysNegotiatedRateCreatePayload, StaysNegotiatedRateUpdatePayload } from '../StaysTypes';
|
|
3
|
+
import { Resource } from '../../Resource';
|
|
4
|
+
import { DuffelResponse, PaginationMeta } from '../../types';
|
|
5
|
+
export declare class NegotiatedRates extends Resource {
|
|
6
|
+
/**
|
|
7
|
+
* Endpoint path
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
constructor(client: Client);
|
|
11
|
+
/**
|
|
12
|
+
* Create a negotiated rate.
|
|
13
|
+
* You must provide either chain_id or accommodation_id, but not both.
|
|
14
|
+
* @param {object} payload - The negotiated rate payload
|
|
15
|
+
*/
|
|
16
|
+
create: (payload: StaysNegotiatedRateCreatePayload) => Promise<DuffelResponse<StaysNegotiatedRate>>;
|
|
17
|
+
/**
|
|
18
|
+
* Get a negotiated rate by ID
|
|
19
|
+
* @param {string} id - The ID of the negotiated rate
|
|
20
|
+
*/
|
|
21
|
+
get: (id: string) => Promise<DuffelResponse<StaysNegotiatedRate>>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a negotiated rate
|
|
24
|
+
* @param {string} id - The ID of the negotiated rate
|
|
25
|
+
* @param {object} payload - The update payload
|
|
26
|
+
*/
|
|
27
|
+
update: (id: string, payload: StaysNegotiatedRateUpdatePayload) => Promise<DuffelResponse<StaysNegotiatedRate>>;
|
|
28
|
+
/**
|
|
29
|
+
* List negotiated rates
|
|
30
|
+
* @param {Object} [options] - Pagination options (optional: limit, after, before)
|
|
31
|
+
*/
|
|
32
|
+
list: (options?: PaginationMeta) => Promise<DuffelResponse<StaysNegotiatedRate[]>>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieves a generator of all negotiated rates. The results may be returned in any order.
|
|
35
|
+
*/
|
|
36
|
+
listWithGenerator: () => AsyncGenerator<DuffelResponse<StaysNegotiatedRate>, void, unknown>;
|
|
37
|
+
/**
|
|
38
|
+
* Delete a negotiated rate
|
|
39
|
+
* @param {string} id - The ID of the negotiated rate
|
|
40
|
+
*/
|
|
41
|
+
delete: (id: string) => Promise<DuffelResponse<StaysNegotiatedRate>>;
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './NegotiatedRates';
|
package/dist/Stays/Stays.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { Accommodation } from './Accommodation';
|
|
|
6
6
|
import { Brands } from './Brands';
|
|
7
7
|
import { LoyaltyProgrammes } from './LoyaltyProgrammes';
|
|
8
8
|
import { Bookings } from './Bookings';
|
|
9
|
+
import { NegotiatedRates } from './NegotiatedRates';
|
|
9
10
|
import { Quotes } from './Quotes';
|
|
10
11
|
import { SearchResults } from './SearchResults';
|
|
11
12
|
export declare class Stays extends Resource {
|
|
@@ -16,6 +17,7 @@ export declare class Stays extends Resource {
|
|
|
16
17
|
accommodation: Accommodation;
|
|
17
18
|
loyaltyProgrammes: LoyaltyProgrammes;
|
|
18
19
|
brands: Brands;
|
|
20
|
+
negotiatedRates: NegotiatedRates;
|
|
19
21
|
searchResults: SearchResults;
|
|
20
22
|
quotes: Quotes;
|
|
21
23
|
bookings: Bookings;
|
|
@@ -206,7 +206,11 @@ export interface StaysAmenity {
|
|
|
206
206
|
}
|
|
207
207
|
export interface StaysChain {
|
|
208
208
|
/**
|
|
209
|
-
*
|
|
209
|
+
* Duffel ID for this chain
|
|
210
|
+
*/
|
|
211
|
+
id: string;
|
|
212
|
+
/**
|
|
213
|
+
* The hotel chain's name
|
|
210
214
|
*/
|
|
211
215
|
name: string;
|
|
212
216
|
}
|
|
@@ -629,4 +633,128 @@ export type ListParamsBookings = {
|
|
|
629
633
|
*/
|
|
630
634
|
user_id?: string;
|
|
631
635
|
};
|
|
636
|
+
/**
|
|
637
|
+
* A negotiated rate that enables passing rate access codes for stays accommodation.
|
|
638
|
+
* Can be associated with either a chain or specific accommodations, but not both.
|
|
639
|
+
*/
|
|
640
|
+
export interface StaysNegotiatedRate {
|
|
641
|
+
/**
|
|
642
|
+
* The ID of the Negotiated Rate
|
|
643
|
+
*
|
|
644
|
+
* Example: "nre_0000AvtkNoC81yBytDM9PE"
|
|
645
|
+
*/
|
|
646
|
+
id: string;
|
|
647
|
+
/**
|
|
648
|
+
* The rate access code to be utilised when using this negotiated rate
|
|
649
|
+
*
|
|
650
|
+
* Example: "DUFFEL"
|
|
651
|
+
*/
|
|
652
|
+
rate_access_code: string;
|
|
653
|
+
/**
|
|
654
|
+
* The display name of the negotiated rate
|
|
655
|
+
*
|
|
656
|
+
* Example: "2025 Negotiated Rate"
|
|
657
|
+
*/
|
|
658
|
+
display_name: string;
|
|
659
|
+
/**
|
|
660
|
+
* Whether this negotiated rate is for live mode. When false, it is for test mode
|
|
661
|
+
*
|
|
662
|
+
* Example: false
|
|
663
|
+
*/
|
|
664
|
+
live_mode: boolean;
|
|
665
|
+
/**
|
|
666
|
+
* The ID of the hotel chain this negotiated rate is valid for.
|
|
667
|
+
* Mutually exclusive with accommodation_ids.
|
|
668
|
+
*
|
|
669
|
+
* Example: "chn_0000B6QFxO9EOY5cqw5kYK"
|
|
670
|
+
*/
|
|
671
|
+
chain_id: string | null;
|
|
672
|
+
/**
|
|
673
|
+
* The accommodation ids this negotiated rate is valid for use with.
|
|
674
|
+
* Mutually exclusive with chain_id.
|
|
675
|
+
*
|
|
676
|
+
* Example: ["acc_0000AWr2VsUNIF1Vl91xg0"]
|
|
677
|
+
*/
|
|
678
|
+
accommodation_ids: string[] | null;
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* Payload for creating a negotiated rate associated with a chain.
|
|
682
|
+
* You must provide either chain_id or accommodation_ids, but not both.
|
|
683
|
+
*/
|
|
684
|
+
export interface StaysNegotiatedRateCreatePayloadWithChain {
|
|
685
|
+
/**
|
|
686
|
+
* The rate access code to be utilised when using this negotiated rate
|
|
687
|
+
*
|
|
688
|
+
* Example: "DUFFEL"
|
|
689
|
+
*/
|
|
690
|
+
rate_access_code: string;
|
|
691
|
+
/**
|
|
692
|
+
* The display name of the negotiated rate
|
|
693
|
+
*
|
|
694
|
+
* Example: "2025 Negotiated Rate"
|
|
695
|
+
*/
|
|
696
|
+
display_name: string;
|
|
697
|
+
/**
|
|
698
|
+
* The ID of the hotel chain this negotiated rate is valid for
|
|
699
|
+
*
|
|
700
|
+
* Example: "chn_0000B6QFxO9EOY5cqw5kYK"
|
|
701
|
+
*/
|
|
702
|
+
chain_id: string;
|
|
703
|
+
}
|
|
704
|
+
/**
|
|
705
|
+
* Payload for creating a negotiated rate associated with accommodations.
|
|
706
|
+
* You must provide either chain_id or accommodation_ids, but not both.
|
|
707
|
+
*/
|
|
708
|
+
export interface StaysNegotiatedRateCreatePayloadWithAccommodations {
|
|
709
|
+
/**
|
|
710
|
+
* The rate access code to be utilised when using this negotiated rate
|
|
711
|
+
*
|
|
712
|
+
* Example: "DUFFEL"
|
|
713
|
+
*/
|
|
714
|
+
rate_access_code: string;
|
|
715
|
+
/**
|
|
716
|
+
* The display name of the negotiated rate
|
|
717
|
+
*
|
|
718
|
+
* Example: "2025 Negotiated Rate"
|
|
719
|
+
*/
|
|
720
|
+
display_name: string;
|
|
721
|
+
/**
|
|
722
|
+
* The accommodation ids this negotiated rate is valid for use with
|
|
723
|
+
*
|
|
724
|
+
* Example: ["acc_0000AWr2VsUNIF1Vl91xg0"]
|
|
725
|
+
*/
|
|
726
|
+
accommodation_ids: string[];
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Payload for creating a negotiated rate.
|
|
730
|
+
* You must provide either chain_id or accommodation_ids, but not both.
|
|
731
|
+
*/
|
|
732
|
+
export type StaysNegotiatedRateCreatePayload = StaysNegotiatedRateCreatePayloadWithChain | StaysNegotiatedRateCreatePayloadWithAccommodations;
|
|
733
|
+
/**
|
|
734
|
+
* Payload for updating a negotiated rate.
|
|
735
|
+
* You can update the display_name and change the association to chain_id or accommodation_ids.
|
|
736
|
+
* If updating the association, you must provide only one of chain_id or accommodation_ids.
|
|
737
|
+
*/
|
|
738
|
+
export interface StaysNegotiatedRateUpdatePayload {
|
|
739
|
+
/**
|
|
740
|
+
* The display name of the negotiated rate
|
|
741
|
+
*
|
|
742
|
+
* Example: "2025 Negotiated Rate"
|
|
743
|
+
*/
|
|
744
|
+
display_name?: string;
|
|
745
|
+
/**
|
|
746
|
+
* The ID of the hotel chain this negotiated rate is valid for.
|
|
747
|
+
* Setting this will remove any existing accommodation_ids association.
|
|
748
|
+
*
|
|
749
|
+
* Example: "chn_0000B6QFxO9EOY5cqw5kYK"
|
|
750
|
+
*/
|
|
751
|
+
chain_id?: string;
|
|
752
|
+
/**
|
|
753
|
+
* The accommodation ids this negotiated rate is valid for use with.
|
|
754
|
+
* Setting this will remove any existing chain_id association.
|
|
755
|
+
*
|
|
756
|
+
* Example: ["acc_0000AWr2VsUNIF1Vl91xg0"]
|
|
757
|
+
*/
|
|
758
|
+
accommodation_ids?: string[];
|
|
759
|
+
}
|
|
632
760
|
export {};
|
package/dist/Stays/mocks.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { StaysAccommodation, StaysAccommodationBrand, StaysAccommodationReviewResponse, StaysAccommodationSuggestion, StaysBooking, StaysLoyaltyProgramme, StaysQuote, StaysSearchResult } from './StaysTypes';
|
|
1
|
+
import { StaysAccommodation, StaysAccommodationBrand, StaysAccommodationReviewResponse, StaysAccommodationSuggestion, StaysBooking, StaysChain, StaysLoyaltyProgramme, StaysNegotiatedRate, StaysQuote, StaysSearchResult } from './StaysTypes';
|
|
2
2
|
import { StaysBookingPayload } from './Bookings/Bookings';
|
|
3
3
|
export declare const MOCK_BRAND: StaysAccommodationBrand;
|
|
4
|
+
export declare const MOCK_CHAIN: StaysChain;
|
|
4
5
|
export declare const MOCK_ACCOMMODATION: StaysAccommodation;
|
|
5
6
|
export declare const MOCK_REVIEW_RESPONSE: StaysAccommodationReviewResponse;
|
|
6
7
|
export declare const MOCK_SEARCH_RESULT: StaysSearchResult;
|
|
@@ -9,3 +10,4 @@ export declare const MOCK_CREATE_BOOKING_PAYLOAD: StaysBookingPayload;
|
|
|
9
10
|
export declare const MOCK_QUOTE: StaysQuote;
|
|
10
11
|
export declare const MOCK_ACCOMMODATION_SUGGESTION: StaysAccommodationSuggestion;
|
|
11
12
|
export declare const MOCK_LOYALTY_PROGRAMMES: StaysLoyaltyProgramme[];
|
|
13
|
+
export declare const MOCK_NEGOTIATED_RATE: StaysNegotiatedRate;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Client } from '../../Client';
|
|
2
2
|
import { Resource } from '../../Resource';
|
|
3
|
-
import { CreateOfferRequest, CreateOfferRequestQueryParameters, DuffelResponse, OfferRequest, PaginationMeta } from '../../types';
|
|
3
|
+
import { CreateOfferRequest, CreateOfferRequestQueryParameters, DuffelResponse, OfferRequest, OfferRequestItinerariesView, PaginationMeta } from '../../types';
|
|
4
4
|
/**
|
|
5
5
|
* To search for flights, you'll need to create an `offer request`.
|
|
6
6
|
* An offer request describes the passengers and where and when they want to travel (in the form of a list of `slices`).
|
|
@@ -35,12 +35,17 @@ export declare class OfferRequests extends Resource {
|
|
|
35
35
|
* To search for flights, you'll need to create an `offer request`.
|
|
36
36
|
* An offer request describes the passengers and where and when they want to travel (in the form of a list of `slices`).
|
|
37
37
|
* It may also include additional filters (e.g. a particular cabin to travel in).
|
|
38
|
-
* @param {Object} [options] - the parameters for making an offer requests (required: slices, passengers; optional: cabin_class, return_offers)
|
|
38
|
+
* @param {Object} [options] - the parameters for making an offer requests (required: slices, passengers; optional: cabin_class, return_offers, view, include_split_ticket)
|
|
39
39
|
* When `return_offers` is set to `true`, the offer request resource returned will include all the `offers` returned by the airlines.
|
|
40
40
|
* If set to false, the offer request resource won't include any `offers`. To retrieve the associated offers later, use the List Offers endpoint, specifying the `offer_request_id`.
|
|
41
|
+
* When `view` is set to `'itineraries'`, offers are grouped per slice into a hierarchy of itineraries and fare brands.
|
|
42
|
+
* Combine `view: 'itineraries'` with `include_split_ticket: true` to surface split-ticket candidates.
|
|
41
43
|
* @link https://duffel.com/docs/api/offer-requests/create-offer-request
|
|
44
|
+
* @link https://duffel.com/docs/guides/selling-split-ticket-itineraries
|
|
42
45
|
*/
|
|
43
46
|
create: <QueryParams extends CreateOfferRequestQueryParameters>(options: CreateOfferRequest & QueryParams) => Promise<DuffelResponse<QueryParams extends {
|
|
47
|
+
view: "itineraries";
|
|
48
|
+
} ? OfferRequestItinerariesView : QueryParams extends {
|
|
44
49
|
return_offers: false;
|
|
45
50
|
} ? Omit<OfferRequest, "offers"> : OfferRequest>>;
|
|
46
51
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Airline, CabinClass, PassengerType, Place, PlaceType } from '../../types';
|
|
2
|
-
import { Offer } from '../Offers/OfferTypes';
|
|
2
|
+
import { Offer, OfferSliceSegment } from '../Offers/OfferTypes';
|
|
3
3
|
export interface OfferRequestSlice {
|
|
4
4
|
/**
|
|
5
5
|
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date on which the passengers want to depart
|
|
@@ -227,6 +227,16 @@ export interface CreateOfferRequest {
|
|
|
227
227
|
* whereas return trips will need two.
|
|
228
228
|
*/
|
|
229
229
|
slices: CreateOfferRequestSlice[];
|
|
230
|
+
/**
|
|
231
|
+
* When set to `true` and the offer request contains more than one slice,
|
|
232
|
+
* Duffel will fire additional one-way searches per slice to find
|
|
233
|
+
* split-ticket itinerary candidates. Split-ticket offers are only returned
|
|
234
|
+
* when combined with the `view=itineraries` query parameter.
|
|
235
|
+
*
|
|
236
|
+
* Requires this capability to be enabled on your Duffel account.
|
|
237
|
+
* @link https://duffel.com/docs/guides/selling-split-ticket-itineraries
|
|
238
|
+
*/
|
|
239
|
+
include_split_ticket?: boolean;
|
|
230
240
|
}
|
|
231
241
|
export type TimeRangeFilter = {
|
|
232
242
|
from: string;
|
|
@@ -257,6 +267,18 @@ export interface CreateOfferRequestSlice {
|
|
|
257
267
|
*/
|
|
258
268
|
departure_time: TimeRangeFilter | null;
|
|
259
269
|
}
|
|
270
|
+
/**
|
|
271
|
+
* The shape of the offer request response.
|
|
272
|
+
*
|
|
273
|
+
* - `offers` (default) — a flat list of offers under `data.offers`.
|
|
274
|
+
* - `itineraries` — offers are grouped per slice into a hierarchy of
|
|
275
|
+
* itineraries and fare brands under `data.slices[].itineraries[]`. This is
|
|
276
|
+
* the view required to surface split-ticket candidates created with
|
|
277
|
+
* `include_split_ticket: true`.
|
|
278
|
+
*
|
|
279
|
+
* @link https://duffel.com/docs/guides/selling-split-ticket-itineraries
|
|
280
|
+
*/
|
|
281
|
+
export type OfferRequestView = 'offers' | 'itineraries';
|
|
260
282
|
export interface CreateOfferRequestQueryParameters {
|
|
261
283
|
/**
|
|
262
284
|
* When set to `true`, the offer request resource returned will include all the offers returned by the airlines.
|
|
@@ -265,6 +287,14 @@ export interface CreateOfferRequestQueryParameters {
|
|
|
265
287
|
* You should use this option if you want to take advantage of the pagination, sorting and filtering that the [List Offers](https://duffel.com/docs/api/offers/get-offers) endpoint provides.
|
|
266
288
|
*/
|
|
267
289
|
return_offers?: boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Controls the shape of the response. Defaults to `offers`, which returns a
|
|
292
|
+
* flat list of offers. Set to `itineraries` to receive offers grouped by
|
|
293
|
+
* slice, itinerary and fare brand — required to retrieve split-ticket
|
|
294
|
+
* candidates produced by `include_split_ticket: true`.
|
|
295
|
+
* @link https://duffel.com/docs/guides/selling-split-ticket-itineraries
|
|
296
|
+
*/
|
|
297
|
+
view?: OfferRequestView;
|
|
268
298
|
/**
|
|
269
299
|
* The maximum amount of time in milliseconds to wait for each airline search to complete.
|
|
270
300
|
* This timeout applies to the response time of the call to the airline and includes
|
|
@@ -279,4 +309,99 @@ export interface CreateOfferRequestQueryParameters {
|
|
|
279
309
|
*/
|
|
280
310
|
supplier_timeout?: number;
|
|
281
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Discriminator for offers returned under the `itineraries` view.
|
|
314
|
+
*
|
|
315
|
+
* - `single_ticket` — a single offer from one airline that covers every slice
|
|
316
|
+
* in the original offer request.
|
|
317
|
+
* - `split_ticket` — an offer that covers a single slice, intended to be
|
|
318
|
+
* combined with offers for the remaining slices (potentially from a
|
|
319
|
+
* different airline) to fulfil the journey.
|
|
320
|
+
*
|
|
321
|
+
* @link https://duffel.com/docs/guides/selling-split-ticket-itineraries
|
|
322
|
+
*/
|
|
323
|
+
export type ItineraryOfferType = 'single_ticket' | 'split_ticket';
|
|
324
|
+
/**
|
|
325
|
+
* An offer returned under the `itineraries` view.
|
|
326
|
+
*
|
|
327
|
+
* It is structurally the same as a regular {@link Offer} (minus
|
|
328
|
+
* `available_services`, which is only populated by the Get single offer
|
|
329
|
+
* endpoint) but carries a `type` discriminator describing whether the offer
|
|
330
|
+
* covers the full journey or a single slice that needs to be combined with
|
|
331
|
+
* other offers.
|
|
332
|
+
*/
|
|
333
|
+
export interface ItineraryOffer extends Omit<Offer, 'available_services'> {
|
|
334
|
+
/**
|
|
335
|
+
* Whether the offer covers every slice from a single airline
|
|
336
|
+
* (`single_ticket`) or only the slice it is nested under and needs to be
|
|
337
|
+
* combined with other offers to complete the journey (`split_ticket`).
|
|
338
|
+
*/
|
|
339
|
+
type: ItineraryOfferType;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* A fare brand grouping offers that share the same itinerary segments.
|
|
343
|
+
*/
|
|
344
|
+
export interface ItineraryBrand {
|
|
345
|
+
/**
|
|
346
|
+
* The airline's marketing name for the fare brand, e.g. "Economy Basic".
|
|
347
|
+
*/
|
|
348
|
+
fare_brand_name: string;
|
|
349
|
+
/**
|
|
350
|
+
* The offers available for this fare brand on this itinerary.
|
|
351
|
+
*/
|
|
352
|
+
offers: ItineraryOffer[];
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* One way the airline can fly a passenger from the slice's origin to its
|
|
356
|
+
* destination. A single itinerary is a fixed list of segments which may be
|
|
357
|
+
* sold under one or more fare brands.
|
|
358
|
+
*/
|
|
359
|
+
export interface Itinerary {
|
|
360
|
+
/**
|
|
361
|
+
* The segments that make up this itinerary, in the order they are flown.
|
|
362
|
+
*/
|
|
363
|
+
segments: OfferSliceSegment[];
|
|
364
|
+
/**
|
|
365
|
+
* The fare brands available for this itinerary, each carrying one or more
|
|
366
|
+
* bookable offers.
|
|
367
|
+
*/
|
|
368
|
+
brands: ItineraryBrand[];
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* A slice as represented in the `itineraries` view of an offer request.
|
|
372
|
+
*
|
|
373
|
+
* Unlike {@link OfferRequestSlice}, it does not include the `departure_date`
|
|
374
|
+
* or origin/destination type fields directly — the per-segment scheduling
|
|
375
|
+
* lives inside `itineraries[].segments[]`.
|
|
376
|
+
*/
|
|
377
|
+
export interface OfferRequestItinerariesViewSlice {
|
|
378
|
+
/**
|
|
379
|
+
* The city or airport the passengers want to depart from.
|
|
380
|
+
*/
|
|
381
|
+
origin: Place;
|
|
382
|
+
/**
|
|
383
|
+
* The city or airport the passengers want to travel to.
|
|
384
|
+
*/
|
|
385
|
+
destination: Place;
|
|
386
|
+
/**
|
|
387
|
+
* The itineraries available for this slice, each grouping offers by fare
|
|
388
|
+
* brand.
|
|
389
|
+
*/
|
|
390
|
+
itineraries: Itinerary[];
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* The response payload returned when an offer request is created with the
|
|
394
|
+
* `view=itineraries` query parameter. Offers are grouped per slice rather than
|
|
395
|
+
* returned as a flat list, which is required to surface split-ticket
|
|
396
|
+
* candidates produced by `include_split_ticket: true`.
|
|
397
|
+
*
|
|
398
|
+
* @link https://duffel.com/docs/guides/selling-split-ticket-itineraries
|
|
399
|
+
*/
|
|
400
|
+
export interface OfferRequestItinerariesView extends Omit<OfferRequest, 'slices' | 'offers'> {
|
|
401
|
+
/**
|
|
402
|
+
* The slices that make up this offer request, each carrying the itineraries
|
|
403
|
+
* and offers available for that slice.
|
|
404
|
+
*/
|
|
405
|
+
slices: OfferRequestItinerariesViewSlice[];
|
|
406
|
+
}
|
|
282
407
|
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { CreateOfferRequest, OfferRequest } from '../../types';
|
|
1
|
+
import { CreateOfferRequest, OfferRequest, OfferRequestItinerariesView } from '../../types';
|
|
2
2
|
export declare const mockCreateOfferRequest: CreateOfferRequest;
|
|
3
3
|
export declare const mockOfferRequest: OfferRequest;
|
|
4
|
+
export declare const mockItinerariesOfferRequest: OfferRequestItinerariesView;
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"node-fetch";import{URL as s,URLSearchParams as e}from"url";function i(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function h(t,s,e,i){return new(e||(e=Promise))(function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e(function(t){t(s)})).then(a,n)}o((i=i.apply(t,s||[])).next())})}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=e.apply(t,s||[]),a=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),n("next"),n("throw"),n("return",function(t){return function(s){return Promise.resolve(s).then(t,c)}}),i[Symbol.asyncIterator]=function(){return this},i;function n(t,s){h[t]&&(i[t]=function(s){return new Promise(function(e,i){a.push([t,s,e,i])>1||o(t,s)})},s&&(i[t]=s(i[t])))}function o(t,s){try{(e=h[t](s)).value instanceof r?Promise.resolve(e.value.v).then(u,c):d(a[0][2],e)}catch(t){d(a[0][3],t)}var e}function u(t){o("next",t)}function c(t){o("throw",t)}function d(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"4.24.2"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}(),"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){this.request=t=>h(this,[t],void 0,function*({method:t,path:s,data:e,params:i}){return this.client.request({method:t,path:s,data:e,params:i})}),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.confirm=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/payment_intents"}}class u extends n{constructor(t){super(t),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})}),this.accept=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})}),this.path="air/airline_initiated_changes"}}class c extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})}),this.path="air/batch_offer_requests"}}class d extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,function*(){const{return_offers:s,supplier_timeout:e}=t,h=i(t,["return_offers","supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:h,params:Object.assign(Object.assign({},null!=s&&{return_offers:s}),null!=e&&{supplier_timeout:e})})}),this.path="air/offer_requests"}}class p extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})}),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))}),this.getPriced=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/price`,data:s})}),this.upsellFares=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/upsell`})}),this.path="air/offers"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.confirm=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})}),this.path="air/order_cancellations"}}class f extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})}),this.getAvailableServices=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})}),this.addServices=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})}),this.path="air/orders"}}class v extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="air/order_change_requests"}}class m extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class q extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.confirm=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})}),this.path="air/order_changes"}}class g extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="air/payments"}}class $ extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})}),this.create=t=>h(this,void 0,void 0,function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})}),this.getFaresById=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})}),this.path="air/partial_offer_requests"}}class T extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}`,params:t})}),this.path="air/seat_maps"}}let y=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class O{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=i=>h(this,[i],void 0,function*({method:i,path:h,data:r,params:a,compress:n=!0}){var o,u;let c,d;const p=new s(h,this.basePath),l={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e;Object.entries(a).sort().filter(t=>null!==t[0]).forEach(([s,e])=>{Array.isArray(e)?e.forEach(e=>t.append(s,e.toString())):t.append(s,e.toString())}),p.search=t.toString()}r&&(c=JSON.stringify({data:Object.assign({},r)})),(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&(console.info("Endpoint: ",p.href),console.info("Method: ",i),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const f=yield t(p.href,{method:i,headers:l,body:c,compress:n});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const v=f.headers.get("content-type");if(d=v&&v.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in d&&d.errors)throw new y(Object.assign(Object.assign({},d),{status:f.status,headers:f.headers}));return Object.assign(Object.assign({},d),{status:f.status,headers:f.headers})}),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v2",this.debug=n,this.source=o}paginatedRequest(t){return a(this,arguments,function*({path:t,params:s}){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t,status:e.status});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:Object.assign(Object.assign({},s),{limit:e.meta.limit,after:e.meta.after})}));for(const t of e.data)yield yield r({data:t,status:e.status})}})}}class _ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class E extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class w extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}`,params:t})}),this.path="places/suggestions"}}class G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/refunds"}}class P extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="links/sessions"}}class S extends n{constructor(t){super(t),this.redeliver=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})}),this.ping=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})}),this.listDeliveries=t=>h(this,void 0,void 0,function*(){var s=i(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})}),this.delete=t=>h(this,void 0,void 0,function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,[t,s],void 0,function*(t,{active:s,events:e,url:i}){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:i}})}),this.list=t=>h(this,void 0,void 0,function*(){var s=i(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})}),this.create=t=>h(this,[t],void 0,function*({events:t,url:s}){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})}),this.path="air/webhooks"}}class x extends n{constructor(t){super(t),this.suggestions=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})}),this.reviews=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}/reviews`,params:s})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.path="stays/accommodation"}}class j extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=()=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path})}),this.path="stays/brands"}}class R extends n{constructor(t){super(t),this.list=()=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path})}),this.path="stays/loyalty_programmes"}}let A=class extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.cancel=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})}),this.path="stays/bookings"}},k=class extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})}),this.path="stays/quotes"}};class C extends n{constructor(t){super(t),this.fetchAllRates=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/fetch_all_rates`})}),this.path="stays/search_results"}}class I extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})}),this.path="stays",this.accommodation=new x(t),this.brands=new j(t),this.loyaltyProgrammes=new R(t),this.searchResults=new C(t),this.quotes=new k(t),this.bookings=new A(t)}}class W extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.cancel=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})}),this.path="cars/bookings"}}class D extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})}),this.path="cars/quotes"}}class H extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})}),this.path="cars",this.bookings=new W(t),this.quotes=new D(t)}}class V extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/cards"}}class U extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/three_d_secure_sessions"}}class B extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PUT",path:`${this.path}/${t}`,data:s})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.path="identity/customer/users"}}class z extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.delete=t=>h(this,void 0,void 0,function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})}),this.path="identity/customer/user_groups"}}class F extends n{constructor(t){super(t),this.create=(...t)=>h(this,[...t],void 0,function*(t={}){return this.request({method:"POST",path:this.path,data:t})}),this.path="identity/component_client_keys"}}class L extends n{constructor(t){super(t),this.path="identity",this.customerUsers=new B(t),this.customerUserGroups=new z(t),this.componentClientKeys=new F(t)}}function M(t){if(!Array.isArray(t)||0===t.length)return!1;for(const s of t)for(const t of s.cabins)for(const s of t.rows)for(const t of s.sections)for(const s of t.elements)if("seat"===s.type&&s.available_services.length>0)return!0;return!1}class J{constructor(t){this.client=new O(t),this.aircraft=new _(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new P(this.client),this.batchOfferRequests=new c(this.client),this.offerRequests=new d(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new v(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new q(this.client),this.orderCancellations=new l(this.client),this.payments=new g(this.client),this.seatMaps=new T(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new $(this.client),this.suggestions=new w(this.client),this.refunds=new G(this.client),this.webhooks=new S(this.client),this.stays=new I(this.client),this.cars=new H(this.client),this.three_d_secure_sessions=new U(this.client),this.identity=new L(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new V(this.cardsClient)}}const K=y,N=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some(t=>t.maximum_quantity>0)||M(s)},Q=M;export{J as Duffel,K as DuffelError,Q as hasAvailableSeatService,N as hasService};
|
|
1
|
+
import t from"node-fetch";import{URL as s,URLSearchParams as e}from"url";function i(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function h(t,s,e,i){return new(e||(e=Promise))(function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e(function(t){t(s)})).then(a,n)}o((i=i.apply(t,s||[])).next())})}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=e.apply(t,s||[]),a=[];return i=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),n("next"),n("throw"),n("return",function(t){return function(s){return Promise.resolve(s).then(t,d)}}),i[Symbol.asyncIterator]=function(){return this},i;function n(t,s){h[t]&&(i[t]=function(s){return new Promise(function(e,i){a.push([t,s,e,i])>1||o(t,s)})},s&&(i[t]=s(i[t])))}function o(t,s){try{(e=h[t](s)).value instanceof r?Promise.resolve(e.value.v).then(u,d):c(a[0][2],e)}catch(t){c(a[0][3],t)}var e}function u(t){o("next",t)}function d(t){o("throw",t)}function c(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"4.26.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}(),"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){this.request=t=>h(this,[t],void 0,function*({method:t,path:s,data:e,params:i}){return this.client.request({method:t,path:s,data:e,params:i})}),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.confirm=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/payment_intents"}}class u extends n{constructor(t){super(t),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})}),this.accept=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})}),this.path="air/airline_initiated_changes"}}class d extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})}),this.path="air/batch_offer_requests"}}class c extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,function*(){const{return_offers:s,supplier_timeout:e,view:h}=t,r=i(t,["return_offers","supplier_timeout","view"]);return this.request({method:"POST",path:`${this.path}/`,data:r,params:Object.assign(Object.assign(Object.assign({},null!=s&&{return_offers:s}),null!=e&&{supplier_timeout:e}),null!=h&&{view:h})})}),this.path="air/offer_requests"}}class p extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})}),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))}),this.getPriced=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/price`,data:s})}),this.upsellFares=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/upsell`})}),this.path="air/offers"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.confirm=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})}),this.path="air/order_cancellations"}}class v extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})}),this.getAvailableServices=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})}),this.addServices=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})}),this.path="air/orders"}}class f extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="air/order_change_requests"}}class m extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class q extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.confirm=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})}),this.path="air/order_changes"}}class g extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="air/payments"}}class $ extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})}),this.create=t=>h(this,void 0,void 0,function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})}),this.getFaresById=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})}),this.path="air/partial_offer_requests"}}class T extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}`,params:t})}),this.path="air/seat_maps"}}let y=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class O{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=i=>h(this,[i],void 0,function*({method:i,path:h,data:r,params:a,compress:n=!0}){var o,u;let d,c;const p=new s(h,this.basePath),l={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e;Object.entries(a).sort().filter(t=>null!==t[0]).forEach(([s,e])=>{Array.isArray(e)?e.forEach(e=>t.append(s,e.toString())):t.append(s,e.toString())}),p.search=t.toString()}r&&(d=JSON.stringify({data:Object.assign({},r)})),(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&(console.info("Endpoint: ",p.href),console.info("Method: ",i),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const v=yield t(p.href,{method:i,headers:l,body:d,compress:n});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&v.headers.get("x-request-id")&&console.info("Request ID: ",v.headers.get("x-request-id"));const f=v.headers.get("content-type");if(c=f&&f.includes("json")?yield v.json():yield v.text(),!v.ok||"errors"in c&&c.errors)throw new y(Object.assign(Object.assign({},c),{status:v.status,headers:v.headers}));return Object.assign(Object.assign({},c),{status:v.status,headers:v.headers})}),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v2",this.debug=n,this.source=o}paginatedRequest(t){return a(this,arguments,function*({path:t,params:s}){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t,status:e.status});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:Object.assign(Object.assign({},s),{limit:e.meta.limit,after:e.meta.after})}));for(const t of e.data)yield yield r({data:t,status:e.status})}})}}class _ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class E extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class w extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}`,params:t})}),this.path="places/suggestions"}}class G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/refunds"}}class P extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="links/sessions"}}class S extends n{constructor(t){super(t),this.redeliver=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})}),this.ping=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})}),this.listDeliveries=t=>h(this,void 0,void 0,function*(){var s=i(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})}),this.delete=t=>h(this,void 0,void 0,function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,[t,s],void 0,function*(t,{active:s,events:e,url:i}){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:i}})}),this.list=t=>h(this,void 0,void 0,function*(){var s=i(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})}),this.create=t=>h(this,[t],void 0,function*({events:t,url:s}){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})}),this.path="air/webhooks"}}class x extends n{constructor(t){super(t),this.suggestions=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})}),this.reviews=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}/reviews`,params:s})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.path="stays/accommodation"}}class j extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=()=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path})}),this.path="stays/brands"}}class R extends n{constructor(t){super(t),this.list=()=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path})}),this.path="stays/loyalty_programmes"}}let A=class extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.cancel=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})}),this.path="stays/bookings"}};class k extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.delete=t=>h(this,void 0,void 0,function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})}),this.path="stays/negotiated_rates"}}let C=class extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})}),this.path="stays/quotes"}};class W extends n{constructor(t){super(t),this.fetchAllRates=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/fetch_all_rates`})}),this.path="stays/search_results"}}class I extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})}),this.path="stays",this.accommodation=new x(t),this.brands=new j(t),this.loyaltyProgrammes=new R(t),this.negotiatedRates=new k(t),this.searchResults=new W(t),this.quotes=new C(t),this.bookings=new A(t)}}class D extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.cancel=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})}),this.path="cars/bookings"}}class H extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})}),this.path="cars/quotes"}}class V extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})}),this.path="cars",this.bookings=new D(t),this.quotes=new H(t)}}class U extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/cards"}}class B extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.path="payments/three_d_secure_sessions"}}class L extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PUT",path:`${this.path}/${t}`,data:s})}),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.path="identity/customer/users"}}class z extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:this.path,params:t})}),this.create=t=>h(this,void 0,void 0,function*(){return this.request({method:"POST",path:this.path,data:t})}),this.delete=t=>h(this,void 0,void 0,function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})}),this.get=t=>h(this,void 0,void 0,function*(){return this.request({method:"GET",path:`${this.path}/${t}`})}),this.update=(t,s)=>h(this,void 0,void 0,function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})}),this.path="identity/customer/user_groups"}}class F extends n{constructor(t){super(t),this.create=(...t)=>h(this,[...t],void 0,function*(t={}){return this.request({method:"POST",path:this.path,data:t})}),this.path="identity/component_client_keys"}}class M extends n{constructor(t){super(t),this.path="identity",this.customerUsers=new L(t),this.customerUserGroups=new z(t),this.componentClientKeys=new F(t)}}function J(t){if(!Array.isArray(t)||0===t.length)return!1;for(const s of t)for(const t of s.cabins)for(const s of t.rows)for(const t of s.sections)for(const s of t.elements)if("seat"===s.type&&s.available_services.length>0)return!0;return!1}class K{constructor(t){this.client=new O(t),this.aircraft=new _(this.client),this.airlines=new E(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new P(this.client),this.batchOfferRequests=new d(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new v(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new q(this.client),this.orderCancellations=new l(this.client),this.payments=new g(this.client),this.seatMaps=new T(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new $(this.client),this.suggestions=new w(this.client),this.refunds=new G(this.client),this.webhooks=new S(this.client),this.stays=new I(this.client),this.cars=new V(this.client),this.three_d_secure_sessions=new B(this.client),this.identity=new M(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new U(this.cardsClient)}}const N=y,Q=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some(t=>t.maximum_quantity>0)||J(s)},X=J;export{K as Duffel,N as DuffelError,X as hasAvailableSeatService,Q as hasService};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|