@duffel/api 4.21.6 → 4.22.1
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/Cars/Bookings/Bookings.d.ts +45 -0
- package/dist/Cars/Bookings/Bookings.spec.d.ts +1 -0
- package/dist/Cars/Bookings/index.d.ts +1 -0
- package/dist/Cars/Cars.d.ts +20 -0
- package/dist/Cars/Cars.spec.d.ts +1 -0
- package/dist/Cars/CarsTypes.d.ts +185 -0
- package/dist/Cars/Quotes/Quotes.d.ts +16 -0
- package/dist/Cars/Quotes/Quotes.spec.d.ts +1 -0
- package/dist/Cars/Quotes/index.d.ts +1 -0
- package/dist/Cars/mocks.d.ts +17 -0
- package/dist/DuffelPayments/PaymentIntents/mockPaymentIntents.d.ts +3 -0
- package/dist/DuffelPayments/Refunds/mockRefunds.d.ts +2 -0
- package/dist/Places/Suggestions/mockSuggestions.d.ts +2 -0
- package/dist/Stays/mocks.d.ts +11 -0
- package/dist/booking/AirlineInitiatedChanges/mockAirlineInitiatedChanges.d.ts +3 -0
- package/dist/booking/BatchOfferRequests/mockBatchOfferRequest.d.ts +4 -0
- package/dist/booking/Identity/ComponentClientKey/mockComponentClientKey.d.ts +2 -0
- package/dist/booking/OfferRequests/mockOfferRequest.d.ts +3 -0
- package/dist/booking/Offers/mockOffer.d.ts +14 -0
- package/dist/booking/Offers/mockPartialOffer.d.ts +13 -0
- package/dist/booking/OrderCancellations/mockOrderCancellations.d.ts +2 -0
- package/dist/booking/OrderChangeOffers/mockOrderChangeOffer.d.ts +2 -0
- package/dist/booking/OrderChangeRequests/mockOrderChangeRequests.d.ts +4 -0
- package/dist/booking/OrderChanges/mockOrderChanges.d.ts +2 -0
- package/dist/booking/Orders/mockOrders.d.ts +6 -0
- package/dist/booking/PartialOfferRequests/mockPartialOfferRequest.d.ts +3 -0
- package/dist/booking/Payments/mockPayment.d.ts +2 -0
- package/dist/booking/SeatMaps/mockSeatMap.d.ts +2 -0
- 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/notifications/Webhooks/mockWebhooks.d.ts +24 -0
- package/dist/supportingResources/Aircraft/mockAircraft.d.ts +2 -0
- package/dist/supportingResources/Airlines/mockAirline.d.ts +2 -0
- package/dist/supportingResources/Airports/mockAirport.d.ts +2 -0
- package/dist/typings.d.ts +289 -0
- package/package.json +12 -11
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Client } from '../../Client';
|
|
2
|
+
import { CarsBooking } from '../CarsTypes';
|
|
3
|
+
import { Resource } from '../../Resource';
|
|
4
|
+
import { DuffelResponse } from '../../types';
|
|
5
|
+
export interface CarsBookingPayload {
|
|
6
|
+
quote_id: string;
|
|
7
|
+
driver: {
|
|
8
|
+
given_name: string;
|
|
9
|
+
family_name: string;
|
|
10
|
+
email: string;
|
|
11
|
+
phone_number: string;
|
|
12
|
+
date_of_birth: string;
|
|
13
|
+
user_id?: string;
|
|
14
|
+
};
|
|
15
|
+
inbound_flight_number?: string;
|
|
16
|
+
supplier_loyalty_programme_account_number?: string;
|
|
17
|
+
payment?: {
|
|
18
|
+
method: 'card';
|
|
19
|
+
card_id: string;
|
|
20
|
+
};
|
|
21
|
+
metadata?: Record<string, string>;
|
|
22
|
+
users?: string[];
|
|
23
|
+
}
|
|
24
|
+
export declare class Bookings extends Resource {
|
|
25
|
+
/**
|
|
26
|
+
* Endpoint path
|
|
27
|
+
*/
|
|
28
|
+
path: string;
|
|
29
|
+
constructor(client: Client);
|
|
30
|
+
/**
|
|
31
|
+
* Create a booking from a quote
|
|
32
|
+
* @param {object} payload - The booking payload, including quote id and driver information
|
|
33
|
+
*/
|
|
34
|
+
create: (payload: CarsBookingPayload) => Promise<DuffelResponse<CarsBooking>>;
|
|
35
|
+
/**
|
|
36
|
+
* Get a booking by ID
|
|
37
|
+
* @param {string} bookingId - The ID of the booking
|
|
38
|
+
*/
|
|
39
|
+
get: (bookingId: string) => Promise<DuffelResponse<CarsBooking>>;
|
|
40
|
+
/**
|
|
41
|
+
* Cancel a booking
|
|
42
|
+
* @param {string} bookingId - The ID of the booking to cancel
|
|
43
|
+
*/
|
|
44
|
+
cancel: (bookingId: string) => Promise<DuffelResponse<CarsBooking>>;
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Bookings';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Client } from '../Client';
|
|
2
|
+
import { CarsSearchParams, CarsSearch } from './CarsTypes';
|
|
3
|
+
import { Resource } from '../Resource';
|
|
4
|
+
import { DuffelResponse } from '../types';
|
|
5
|
+
import { Bookings } from './Bookings';
|
|
6
|
+
import { Quotes } from './Quotes';
|
|
7
|
+
export declare class Cars extends Resource {
|
|
8
|
+
/**
|
|
9
|
+
* Endpoint path
|
|
10
|
+
*/
|
|
11
|
+
path: string;
|
|
12
|
+
bookings: Bookings;
|
|
13
|
+
quotes: Quotes;
|
|
14
|
+
constructor(client: Client);
|
|
15
|
+
/**
|
|
16
|
+
* Search for available rental cars
|
|
17
|
+
* @param {object} params - The search parameters
|
|
18
|
+
*/
|
|
19
|
+
search: (params: CarsSearchParams) => Promise<DuffelResponse<CarsSearch>>;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export interface CarsGeographicCoordinates {
|
|
2
|
+
latitude: number;
|
|
3
|
+
longitude: number;
|
|
4
|
+
}
|
|
5
|
+
export interface CarsSearchLocation {
|
|
6
|
+
radius?: number;
|
|
7
|
+
geographic_coordinates: CarsGeographicCoordinates;
|
|
8
|
+
}
|
|
9
|
+
export interface CarsSearchDriver {
|
|
10
|
+
age: number;
|
|
11
|
+
residence_country_code: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CarsSearchParams {
|
|
14
|
+
pickup_date: string;
|
|
15
|
+
pickup_time: string;
|
|
16
|
+
dropoff_date: string;
|
|
17
|
+
dropoff_time: string;
|
|
18
|
+
pickup_location: CarsSearchLocation;
|
|
19
|
+
dropoff_location: CarsSearchLocation;
|
|
20
|
+
driver: CarsSearchDriver;
|
|
21
|
+
}
|
|
22
|
+
export type CarsPaymentType = 'postpaid' | 'guarantee' | 'prepaid';
|
|
23
|
+
export type CarsMileageUnit = 'kilometres' | 'miles';
|
|
24
|
+
export type CarsMileage = {
|
|
25
|
+
type: 'unlimited';
|
|
26
|
+
} | {
|
|
27
|
+
type: 'limited';
|
|
28
|
+
unit: CarsMileageUnit;
|
|
29
|
+
limit: number;
|
|
30
|
+
};
|
|
31
|
+
export interface CarsSupplier {
|
|
32
|
+
name: string;
|
|
33
|
+
logo_url: string | null;
|
|
34
|
+
}
|
|
35
|
+
export type CarsCategory = 'mini' | 'mini_elite' | 'economy' | 'economy_elite' | 'compact' | 'compact_elite' | 'intermediate' | 'intermediate_elite' | 'standard' | 'standard_elite' | 'fullsize' | 'fullsize_elite' | 'premium' | 'premium_elite' | 'luxury' | 'luxury_elite' | 'special';
|
|
36
|
+
export type CarsVehicleType = 'two_door' | 'two_or_four_door' | 'four_door' | 'wagon_estate' | 'passenger_van' | 'limousine' | 'sport' | 'convertible' | 'suv' | 'open_air_all_terrain' | 'special' | 'pickup_regular_cab' | 'pickup_extended_cab' | 'special_offer_car' | 'coupe' | 'monospace' | 'recreational_vehicle' | 'two_wheel_vehicle';
|
|
37
|
+
export type CarsTransmission = 'manual' | 'automatic';
|
|
38
|
+
export type CarsFuel = 'unspecified_fuel' | 'diesel' | 'hybrid' | 'electric' | 'lpg' | 'hydrogen' | 'multi_fuel' | 'petrol';
|
|
39
|
+
export interface CarsBaggage {
|
|
40
|
+
large: number;
|
|
41
|
+
small: number;
|
|
42
|
+
}
|
|
43
|
+
export interface CarsImage {
|
|
44
|
+
url: string;
|
|
45
|
+
}
|
|
46
|
+
export interface Car {
|
|
47
|
+
name: string;
|
|
48
|
+
/**
|
|
49
|
+
* The ACRISS or SIPP code for this car. A four-letter code describing the car's attributes.
|
|
50
|
+
*/
|
|
51
|
+
code: string;
|
|
52
|
+
category: CarsCategory;
|
|
53
|
+
type: CarsVehicleType;
|
|
54
|
+
transmission: CarsTransmission;
|
|
55
|
+
fuel: CarsFuel;
|
|
56
|
+
air_conditioning: boolean;
|
|
57
|
+
max_passengers: number | null;
|
|
58
|
+
baggage: CarsBaggage | null;
|
|
59
|
+
images: CarsImage[] | null;
|
|
60
|
+
}
|
|
61
|
+
export type CarsLocationAccess = 'in_terminal' | 'shuttle' | 'meet_and_greet' | 'call_for_pickup';
|
|
62
|
+
export interface CarsLocationAdditionalInformation {
|
|
63
|
+
title: string;
|
|
64
|
+
text: string;
|
|
65
|
+
}
|
|
66
|
+
export interface CarsLocationOpeningHours {
|
|
67
|
+
from: string;
|
|
68
|
+
to: string;
|
|
69
|
+
}
|
|
70
|
+
export interface CarsLocationAddress {
|
|
71
|
+
line_one: string | null;
|
|
72
|
+
city_name: string | null;
|
|
73
|
+
postal_code: string | null;
|
|
74
|
+
region: string | null;
|
|
75
|
+
country_code: string;
|
|
76
|
+
}
|
|
77
|
+
export interface CarsLocation {
|
|
78
|
+
name: string;
|
|
79
|
+
geographic_coordinates: CarsGeographicCoordinates;
|
|
80
|
+
address: CarsLocationAddress;
|
|
81
|
+
phone_number: string | null;
|
|
82
|
+
access: CarsLocationAccess | null;
|
|
83
|
+
additional_information: CarsLocationAdditionalInformation[];
|
|
84
|
+
opening_hours: CarsLocationOpeningHours[];
|
|
85
|
+
}
|
|
86
|
+
export interface CarsRate {
|
|
87
|
+
id: string;
|
|
88
|
+
base_amount: string | null;
|
|
89
|
+
base_currency: string | null;
|
|
90
|
+
total_amount: string;
|
|
91
|
+
total_currency: string;
|
|
92
|
+
payment_type: CarsPaymentType;
|
|
93
|
+
mileage: CarsMileage;
|
|
94
|
+
supplier: CarsSupplier;
|
|
95
|
+
car: Car;
|
|
96
|
+
pickup_location: CarsLocation;
|
|
97
|
+
dropoff_location: CarsLocation;
|
|
98
|
+
}
|
|
99
|
+
export interface CarsSearch {
|
|
100
|
+
id: string;
|
|
101
|
+
live_mode: boolean;
|
|
102
|
+
created_at: string;
|
|
103
|
+
pickup_date: string;
|
|
104
|
+
pickup_time: string;
|
|
105
|
+
dropoff_date: string;
|
|
106
|
+
dropoff_time: string;
|
|
107
|
+
pickup_location: CarsSearchLocation;
|
|
108
|
+
dropoff_location: CarsSearchLocation;
|
|
109
|
+
driver: CarsSearchDriver;
|
|
110
|
+
rates: CarsRate[];
|
|
111
|
+
}
|
|
112
|
+
export interface CarsCharge {
|
|
113
|
+
amount: string;
|
|
114
|
+
currency: string;
|
|
115
|
+
description: string | null;
|
|
116
|
+
}
|
|
117
|
+
export interface CarsCondition {
|
|
118
|
+
title: string;
|
|
119
|
+
text: string;
|
|
120
|
+
}
|
|
121
|
+
export interface CarsPrivacyPolicy {
|
|
122
|
+
title: string;
|
|
123
|
+
text: string;
|
|
124
|
+
}
|
|
125
|
+
export interface CarsQuote {
|
|
126
|
+
id: string;
|
|
127
|
+
live_mode: boolean;
|
|
128
|
+
rate_id: string;
|
|
129
|
+
search_id: string;
|
|
130
|
+
base_amount: string | null;
|
|
131
|
+
base_currency: string;
|
|
132
|
+
total_amount: string;
|
|
133
|
+
total_currency: string;
|
|
134
|
+
charges: CarsCharge[] | null;
|
|
135
|
+
payment_type: CarsPaymentType;
|
|
136
|
+
mileage: CarsMileage;
|
|
137
|
+
supplier: CarsSupplier;
|
|
138
|
+
car: Car;
|
|
139
|
+
conditions: CarsCondition[];
|
|
140
|
+
privacy_policies: CarsPrivacyPolicy[] | null;
|
|
141
|
+
pickup_location: CarsLocation;
|
|
142
|
+
dropoff_location: CarsLocation;
|
|
143
|
+
pickup_date: string;
|
|
144
|
+
pickup_time: string;
|
|
145
|
+
dropoff_date: string;
|
|
146
|
+
dropoff_time: string;
|
|
147
|
+
}
|
|
148
|
+
export type CarsBookingStatus = 'confirmed' | 'cancelled';
|
|
149
|
+
export interface CarsBookingDriver {
|
|
150
|
+
given_name: string;
|
|
151
|
+
family_name: string;
|
|
152
|
+
date_of_birth: string;
|
|
153
|
+
email: string;
|
|
154
|
+
phone_number: string;
|
|
155
|
+
user_id: string | null;
|
|
156
|
+
}
|
|
157
|
+
export interface CarsBooking {
|
|
158
|
+
id: string;
|
|
159
|
+
live_mode: boolean;
|
|
160
|
+
reference: string;
|
|
161
|
+
confirmed_at: string | null;
|
|
162
|
+
cancelled_at: string | null;
|
|
163
|
+
status: CarsBookingStatus;
|
|
164
|
+
driver: CarsBookingDriver;
|
|
165
|
+
quote_id: string;
|
|
166
|
+
base_amount: string | null;
|
|
167
|
+
base_currency: string;
|
|
168
|
+
total_amount: string;
|
|
169
|
+
total_currency: string;
|
|
170
|
+
charges: CarsCharge[] | null;
|
|
171
|
+
payment_type: CarsPaymentType;
|
|
172
|
+
mileage: CarsMileage;
|
|
173
|
+
supplier: CarsSupplier;
|
|
174
|
+
metadata: Record<string, string> | null;
|
|
175
|
+
users: string[];
|
|
176
|
+
car: Car;
|
|
177
|
+
conditions: CarsCondition[];
|
|
178
|
+
privacy_policies: CarsPrivacyPolicy[] | null;
|
|
179
|
+
pickup_location: CarsLocation;
|
|
180
|
+
dropoff_location: CarsLocation;
|
|
181
|
+
pickup_date: string;
|
|
182
|
+
pickup_time: string;
|
|
183
|
+
dropoff_date: string;
|
|
184
|
+
dropoff_time: string;
|
|
185
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Client } from '../../Client';
|
|
2
|
+
import { CarsQuote } from '../CarsTypes';
|
|
3
|
+
import { Resource } from '../../Resource';
|
|
4
|
+
import { DuffelResponse } from '../../types';
|
|
5
|
+
export declare class Quotes extends Resource {
|
|
6
|
+
/**
|
|
7
|
+
* Endpoint path
|
|
8
|
+
*/
|
|
9
|
+
path: string;
|
|
10
|
+
constructor(client: Client);
|
|
11
|
+
/**
|
|
12
|
+
* Create a quote for the selected rate
|
|
13
|
+
* @param {string} rateId - The ID of the rate to create a quote for
|
|
14
|
+
*/
|
|
15
|
+
create: (rateId: string) => Promise<DuffelResponse<CarsQuote>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Quotes';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Car, CarsBooking, CarsBookingDriver, CarsCharge, CarsCondition, CarsLocation, CarsMileage, CarsPrivacyPolicy, CarsQuote, CarsRate, CarsSearch, CarsSearchParams, CarsSupplier } from './CarsTypes';
|
|
2
|
+
import { CarsBookingPayload } from './Bookings/Bookings';
|
|
3
|
+
export declare const MOCK_CAR: Car;
|
|
4
|
+
export declare const MOCK_SUPPLIER: CarsSupplier;
|
|
5
|
+
export declare const MOCK_MILEAGE: CarsMileage;
|
|
6
|
+
export declare const MOCK_LOCATION: CarsLocation;
|
|
7
|
+
export declare const MOCK_DROPOFF_LOCATION: CarsLocation;
|
|
8
|
+
export declare const MOCK_CONDITION: CarsCondition;
|
|
9
|
+
export declare const MOCK_PRIVACY_POLICY: CarsPrivacyPolicy;
|
|
10
|
+
export declare const MOCK_CHARGE: CarsCharge;
|
|
11
|
+
export declare const MOCK_RATE: CarsRate;
|
|
12
|
+
export declare const MOCK_SEARCH_PARAMS: CarsSearchParams;
|
|
13
|
+
export declare const MOCK_SEARCH: CarsSearch;
|
|
14
|
+
export declare const MOCK_DRIVER: CarsBookingDriver;
|
|
15
|
+
export declare const MOCK_QUOTE: CarsQuote;
|
|
16
|
+
export declare const MOCK_BOOKING: CarsBooking;
|
|
17
|
+
export declare const MOCK_CREATE_BOOKING_PAYLOAD: CarsBookingPayload;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StaysAccommodation, StaysAccommodationBrand, StaysAccommodationReviewResponse, StaysAccommodationSuggestion, StaysBooking, StaysLoyaltyProgramme, StaysQuote, StaysSearchResult } from './StaysTypes';
|
|
2
|
+
import { StaysBookingPayload } from './Bookings/Bookings';
|
|
3
|
+
export declare const MOCK_BRAND: StaysAccommodationBrand;
|
|
4
|
+
export declare const MOCK_ACCOMMODATION: StaysAccommodation;
|
|
5
|
+
export declare const MOCK_REVIEW_RESPONSE: StaysAccommodationReviewResponse;
|
|
6
|
+
export declare const MOCK_SEARCH_RESULT: StaysSearchResult;
|
|
7
|
+
export declare const MOCK_BOOKING: StaysBooking;
|
|
8
|
+
export declare const MOCK_CREATE_BOOKING_PAYLOAD: StaysBookingPayload;
|
|
9
|
+
export declare const MOCK_QUOTE: StaysQuote;
|
|
10
|
+
export declare const MOCK_ACCOMMODATION_SUGGESTION: StaysAccommodationSuggestion;
|
|
11
|
+
export declare const MOCK_LOYALTY_PROGRAMMES: StaysLoyaltyProgramme[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CreateBatchOfferRequest, CreateBatchOfferRequestResponse, BatchOfferRequest } from '../../types';
|
|
2
|
+
export declare const mockCreateBatchOfferRequest: CreateBatchOfferRequest;
|
|
3
|
+
export declare const mockBatchOfferRequest: BatchOfferRequest;
|
|
4
|
+
export declare const mocCreatedBatchOfferRequest: CreateBatchOfferRequestResponse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Offer, OfferPriced } from '../../types';
|
|
2
|
+
export declare const mockOffer: Offer;
|
|
3
|
+
export declare const mockUpdatedOffer: {
|
|
4
|
+
type: string;
|
|
5
|
+
loyalty_programme_accounts: {
|
|
6
|
+
airline_iata_code: string;
|
|
7
|
+
account_number: string;
|
|
8
|
+
}[];
|
|
9
|
+
id: string;
|
|
10
|
+
given_name: string;
|
|
11
|
+
family_name: string;
|
|
12
|
+
age: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const mockOfferPriced: OfferPriced;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Offer } from '../../types';
|
|
2
|
+
export declare const mockPartialOffer: Offer;
|
|
3
|
+
export declare const mockUpdatedOffer: {
|
|
4
|
+
type: string;
|
|
5
|
+
loyalty_programme_accounts: {
|
|
6
|
+
airline_iata_code: string;
|
|
7
|
+
account_number: string;
|
|
8
|
+
}[];
|
|
9
|
+
id: string;
|
|
10
|
+
given_name: string;
|
|
11
|
+
family_name: string;
|
|
12
|
+
age: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { CreateOrderChangeRequest, OrderChangeRequestResponse } from '../../types';
|
|
2
|
+
export declare const mockOrderChangeRequest: OrderChangeRequestResponse;
|
|
3
|
+
export declare const mockOrderChangeRequestAltered: OrderChangeRequestResponse;
|
|
4
|
+
export declare const mockCreateChangeRequest: CreateOrderChangeRequest;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AddServices, CreateOrder, Order, OrderAvailableService } from '../../types';
|
|
2
|
+
export declare const mockCreateOrderRequest: CreateOrder;
|
|
3
|
+
export declare const mockOrder: Order;
|
|
4
|
+
export declare const mockOnHoldOrders: Order[];
|
|
5
|
+
export declare const mockServices: OrderAvailableService[];
|
|
6
|
+
export declare const mockAddServicesRequest: AddServices;
|
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={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}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.21.5"};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.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 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 x 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 S 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"}}class A 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.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 W 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 S(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 I 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 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.path="payments/three_d_secure_sessions"}}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: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 V 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 U 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 B extends n{constructor(t){super(t),this.path="identity",this.customerUsers=new H(t),this.customerUserGroups=new V(t),this.componentClientKeys=new U(t)}}function z(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 L{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 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 x(this.client),this.stays=new W(this.client),this.three_d_secure_sessions=new D(this.client),this.identity=new B(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new I(this.cardsClient)}}const M=y,F=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some((t=>t.maximum_quantity>0))||z(s)},J=z;export{L as Duffel,M as DuffelError,J as hasAvailableSeatService,F 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,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.22.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 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.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 x 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 S 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 S(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 L 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 B(t),this.customerUserGroups=new z(t),this.componentClientKeys=new L(t)}}function F(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 x(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 M(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)||F(s)},Q=F;export{J as Duffel,K as DuffelError,Q as hasAvailableSeatService,N as hasService};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|