@duffel/api 1.21.0 → 1.23.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.
@@ -1,7 +1,7 @@
1
1
  import { Client } from 'Client';
2
- import { Resource } from '../Resource';
3
- import { DuffelResponse } from '../types';
4
- interface GenerateLinkParameters {
2
+ import { Resource } from '../../Resource';
3
+ import { DuffelResponse } from '../../types';
4
+ interface SessionParameters {
5
5
  /**
6
6
  * A tracking reference for the booking that may be created within this Duffel Links session
7
7
  */
@@ -43,21 +43,21 @@ interface GenerateLinkParameters {
43
43
  */
44
44
  checkout_display_text?: string;
45
45
  }
46
- interface GeneratedLink {
46
+ interface Session {
47
47
  /**
48
48
  * The Duffel Links url that contains the specified configuration
49
49
  */
50
50
  url: string;
51
51
  }
52
- export declare class Links extends Resource {
52
+ export declare class Sessions extends Resource {
53
53
  /**
54
54
  * Endpoint path
55
55
  */
56
56
  path: string;
57
57
  constructor(client: Client);
58
58
  /**
59
- * Generate a Duffel Link per the configuration
59
+ * Create a Duffel Links Session per the configuration
60
60
  */
61
- generateLink: (data: GenerateLinkParameters) => Promise<DuffelResponse<GeneratedLink>>;
61
+ create: (data: SessionParameters) => Promise<DuffelResponse<Session>>;
62
62
  }
63
63
  export {};
@@ -0,0 +1 @@
1
+ export * from './Sessions';
@@ -1 +1 @@
1
- export * from './Links';
1
+ export * from './Sessions';
@@ -0,0 +1,63 @@
1
+ import { Client } from '../../Client';
2
+ import { Resource } from '../../Resource';
3
+ import { AirlineInitiatedChangeAvailableAction, DuffelResponse, Order } from '../../types';
4
+ import { AirlineInitiatedChange } from './AirlineInitiatedChangesTypes';
5
+ /**
6
+ * Sometimes there can be changes to your order initiated by the airline, for
7
+ * example a flight being delayed. We record every one of these changes so that
8
+ * you can view them all or for an order. You can filter changes for a specific
9
+ * order using the `order_id` parameter.
10
+ *
11
+ * Each airline-initiated change contains an `added` and `removed` field. `added`
12
+ * contains the updated slices following the change. These slices and their
13
+ * segments may have a new ID based on the change. `removed` contains a list of
14
+ * slices and their segments as they were before the change.
15
+ */
16
+ export declare class AirlineInitiatedChanges extends Resource {
17
+ /**
18
+ * Endpoint path
19
+ */
20
+ path: string;
21
+ constructor(client: Client);
22
+ /**
23
+ * This endpoint is only available to those airline-initiated changes that
24
+ * Duffel cannot accept on behalf of the customer. Duffel is unable to accept
25
+ * an airline-initiated change when these two conditions are true: the order
26
+ * was booked with the merchant's IATA number and Duffel is unable to accept
27
+ * the airline-initiated change programatically. In this case you, the
28
+ * customer, are responsible to resolve airline-initiated changes concerning
29
+ * this order (e.g. by contacting the airline directly). Once these have been
30
+ * resolved, you need to inform us of the action taken so we can mark it
31
+ * accordingly in our system.
32
+ *
33
+ * @param {AirlineInitiatedChange['id']} id - Duffel's unique identifier for
34
+ * the airline-initiated change
35
+ *
36
+ * @param action_taken - The action taken in response to this
37
+ * airline-initiated change. Accepted, cancelled and changed reflect your
38
+ * action in accepting the change, cancelling the order or changing the order
39
+ * respectively.
40
+ *
41
+ * @link https://duffel.com/docs/api/v1/airline-initiated-changes/update-airline-initiated-changes
42
+ */
43
+ update: (id: AirlineInitiatedChange['id'], action_taken: AirlineInitiatedChangeAvailableAction) => Promise<DuffelResponse<AirlineInitiatedChange>>;
44
+ /**
45
+ * Once there is an airline-initiated change you can choose to accept it.
46
+ *
47
+ * @param {AirlineInitiatedChange['id']} id - Duffel's unique identifier for
48
+ * the airline-initiated change
49
+ *
50
+ * @link https://duffel.com/docs/api/v1/airline-initiated-changes/accept-airline-initiated-changes
51
+ */
52
+ accept: (id: AirlineInitiatedChange['id']) => Promise<DuffelResponse<AirlineInitiatedChange>>;
53
+ /**
54
+ * Retrieves a list of all airline-initiated changes.
55
+ *
56
+ * @param order_id - Filters airline-initiated changes by their order ID.
57
+ * Value must be a valid order ID. Check the [Order schema](https://duffel.com/docs/api/orders/schema#orders-schema-id)
58
+ * for details.
59
+ *
60
+ * @link https://duffel.com/docs/api/v1/airline-initiated-changes/get-airline-initiated-changes
61
+ */
62
+ list: (order_id: Order['id']) => Promise<DuffelResponse<Order['airline_initiated_changes']>>;
63
+ }
@@ -0,0 +1,57 @@
1
+ import { OrderSlice } from 'types';
2
+ export declare type AirlineInitiatedChangeActionTaken = 'accepted' | 'cancelled' | 'changed';
3
+ export declare type AirlineInitiatedChangeAvailableAction = 'accept' | 'cancel' | 'change' | 'update';
4
+ export interface AirlineInitiatedChange {
5
+ /**
6
+ * The action taken in response to this airline-initiated change. Accepted,
7
+ * cancelled and changed reflect your action in accepting the change,
8
+ * cancelling the order or changing the order respectively.
9
+ */
10
+ action_taken: AirlineInitiatedChangeActionTaken | null;
11
+ /**
12
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which an
13
+ * action was taken.
14
+ */
15
+ action_taken_at: string | null;
16
+ /**
17
+ * List of updated (slices and segments)[https://duffel.com/docs/api/orders/schema#orders-schema-slices]
18
+ * following the change. These slices and segments may each have a new ID as a
19
+ * result of the changes.
20
+ */
21
+ added: OrderSlice[];
22
+ /**
23
+ * The available actions you can take on this Airline-Initiated Change through
24
+ * our API.`"update"` means that you can use the update endpoint for an
25
+ * Airline-Initiated Change.
26
+ */
27
+ available_actions: AirlineInitiatedChangeAvailableAction[];
28
+ /**
29
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which we
30
+ * detected the airline-initiated change.
31
+ */
32
+ created_at: string;
33
+ /**
34
+ * Duffel's unique identifier for the airline-initiated change.
35
+ */
36
+ id: string;
37
+ /**
38
+ * Duffel's unique identifier for the order.
39
+ */
40
+ order_id: string;
41
+ /**
42
+ * List of (slices and segments)[https://duffel.com/docs/api/orders/schema#orders-schema-slices]
43
+ * as they were before the change.
44
+ */
45
+ removed: OrderSlice[];
46
+ /**
47
+ * The associated Travel Agent Ticket, if any, for this Airline-Initiated
48
+ * Change. This value will be present for Airline-Initiated changes that take
49
+ * some time to be processed.
50
+ */
51
+ travel_agent_ticket: any | null;
52
+ /**
53
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which
54
+ * the airline-initiated change was last updated.
55
+ */
56
+ updated_at: string;
57
+ }
@@ -105,19 +105,19 @@ export interface Offer {
105
105
  }
106
106
  export interface OfferAvailableServiceBaggageMetadata {
107
107
  /**
108
- * The maximum weight that the baggage can have in kilograms
108
+ * The maximum weight that the baggage can have in kilograms.
109
109
  */
110
110
  maximum_weight_kg: number | null;
111
111
  /**
112
- * The maximum height that the baggage can have in centimetres
112
+ * The maximum height that the baggage can have in centimetres.
113
113
  */
114
114
  maximum_height_cm: number | null;
115
115
  /**
116
- * The maximum length that the baggage can have in centimetres
116
+ * The maximum length that the baggage can have in centimetres.
117
117
  */
118
118
  maximum_length_cm: number | null;
119
119
  /**
120
- * The maximum depth that the baggage can have in centimetres
120
+ * The maximum depth that the baggage can have in centimetres.
121
121
  */
122
122
  maximum_depth_cm: number | null;
123
123
  /**
@@ -125,70 +125,110 @@ export interface OfferAvailableServiceBaggageMetadata {
125
125
  */
126
126
  type: BaggageType;
127
127
  }
128
- export interface PaymentRequirements {
128
+ export interface OfferAvailableServiceCFARMetadata {
129
129
  /**
130
- * The ISO 8601 datetime by which you must pay for this order.
131
- * At this time, if still unpaid, the reserved space on the flight(s)
132
- * will be released and you will have to create a new order.
133
- * This will be null only for orders where `awaiting_payment` is `false`.
130
+ * The amount the customer will receive back if the service is used, in
131
+ * `offer.total_currency`.
134
132
  */
135
- payment_required_by?: string | null;
133
+ refund_amount: string;
136
134
  /**
137
- * The ISO 8601 datetime at which the price associated
138
- * with the order will no longer be guaranteed by the airline
139
- * and the order will need to be repriced before payment.
140
- * This can be null when there is no price guarantee.
135
+ * Information to display to customers.
141
136
  */
142
- price_guarantee_expires_at?: string | null;
137
+ merchant_copy: string;
143
138
  /**
144
- * Whether immediate payment is required or not
139
+ * URL with the T&Cs for customers.
145
140
  */
146
- requires_instant_payment: boolean;
147
- }
148
- export interface OfferAvailableServiceMetadataMap {
149
- baggage: OfferAvailableServiceBaggageMetadata;
141
+ terms_and_conditions_url: string;
142
+ type: 'cancel_for_any_reason';
150
143
  }
151
- export declare type OfferAvailableServiceType = keyof OfferAvailableServiceMetadataMap;
152
- export interface OfferAvailableService<T_ServiceType extends OfferAvailableServiceType = 'baggage'> {
144
+ export interface OfferAvailableServiceCommon {
153
145
  /**
154
- * Duffel's unique identifier for the service
146
+ * Duffel's unique identifier for the service.
155
147
  */
156
148
  id: string;
157
149
  /**
158
- * The maximum quantity of this service that can be booked with an order
150
+ * The maximum quantity of this service that can be booked with an order.
159
151
  */
160
152
  maximum_quantity: number;
161
153
  /**
162
- * An object containing metadata about the service, like the maximum weight and dimensions of the baggage.
163
- */
164
- metadata?: OfferAvailableServiceMetadataMap[T_ServiceType];
165
- /**
166
- * The list of passenger `id`s the service applies to.
167
- * If you add this service to an order it will apply to all the passengers in this list.
168
- * For services where the type is `baggage`, this list will include only a single passenger.
154
+ * The list of passenger `id`s the service applies to. If you add this
155
+ * service to an order it will apply to all the passengers in this list.
156
+ * For services where the type is `baggage`, this list will include only a
157
+ * single passenger.
169
158
  */
170
159
  passenger_ids: string[];
171
160
  /**
172
- * The list of segment ids the service applies to.
173
- * If you add this service to an order it will apply to all the segments in this list.
174
- * For services where the type is baggage, depending on the airline,
175
- * this list includes all the segments of all slices or all the segments of a single slice.
161
+ * The list of segment `id`s the service applies to. If you add this
162
+ * service to an order it will apply to all the segments in this list. For
163
+ * services where the type is `baggage`, depending on the airline, this
164
+ * list includes all the segments of all slices or all the segments of a
165
+ * single slice.
176
166
  */
177
167
  segment_ids: string[];
178
168
  /**
179
- * The total price of the service for all passengers and segments it applies to, including taxes
169
+ * The total price of the service for all passengers and segments it
170
+ * applies to, including taxes. This price is for a single unit of the
171
+ * service.
180
172
  */
181
173
  total_amount: string;
182
174
  /**
183
- * The currency of the `total_amount`, as an ISO 4217 currency code
175
+ * The currency of the `total_amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
176
+ * currency code. It will match your organisation's billing currency unless
177
+ * you’re using Duffel as an accredited IATA agent, in which case it will be
178
+ * in the currency provided by the airline (which will usually be based on the
179
+ * country where your IATA agency is registered).
184
180
  */
185
181
  total_currency: string;
182
+ }
183
+ export interface OfferAvailableServiceBaggage extends OfferAvailableServiceCommon {
184
+ /**
185
+ * The metadata varies by the type of service. It includes further data
186
+ * about the service. For example, for baggages, it may have data about
187
+ * size and weight restrictions.
188
+ */
189
+ metadata: OfferAvailableServiceBaggageMetadata;
186
190
  /**
187
191
  * The type of the service.
188
- * For now we only return services of type baggage but we will return other types in the future.
189
- * We won't consider adding new service types a break change.
190
192
  */
191
- type: T_ServiceType;
193
+ type: 'baggage';
194
+ }
195
+ export interface OfferAvailableServiceCFAR extends OfferAvailableServiceCommon {
196
+ /**
197
+ * The metadata varies by the type of service. It includes further data
198
+ * about the service. For example, for baggages, it may have data about
199
+ * size and weight restrictions.
200
+ */
201
+ metadata: OfferAvailableServiceCFARMetadata;
202
+ /**
203
+ * The type of the service.
204
+ */
205
+ type: 'cancel_for_any_reason';
206
+ }
207
+ export declare type OfferAvailableService = OfferAvailableServiceBaggage | OfferAvailableServiceCFAR;
208
+ export interface PaymentRequirements {
209
+ /**
210
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime by which
211
+ * you must pay for this order. At this time, if still unpaid, the reserved
212
+ * space on the flight(s) will be released and you will have to create a new
213
+ * order. This will be null only for orders where `awaiting_payment` is
214
+ * `false`.
215
+ */
216
+ payment_required_by: string | null;
217
+ /**
218
+ * The ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the
219
+ * price associated with the order will no longer be guaranteed by the airline
220
+ * and may change before payment. This will be null when
221
+ * `requires_instant_payment` is `true`.
222
+ */
223
+ price_guarantee_expires_at: string | null;
224
+ /**
225
+ * When payment is required at the time of booking this will be true and
226
+ * `payment_required_by` and `price_guarantee_expires_at` will be `null`. When
227
+ * payment can be made at a time after booking, this will be `false` and the
228
+ * time limits on the payment will be provided in `payment_required_by` and
229
+ * `price_guarantee_expires_at`.
230
+ */
231
+ requires_instant_payment: boolean;
192
232
  }
193
233
  export interface OfferPassenger {
194
234
  /**
@@ -1,46 +1,4 @@
1
- import { Aircraft, Airline, CabinClass, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, FlightsConditions, LoyaltyProgrammeAccount, OfferAvailableService, OfferAvailableServiceBaggageMetadata, PassengerIdentityDocumentType, PaymentType, Place, PlaceType } from '../../types';
2
- export declare type AvailableActionType = 'accept' | 'cancel' | 'change' | 'update';
3
- export declare type ActionTakenType = 'accepted' | 'cancelled' | 'changed' | null;
4
- export interface AirlineInitiatedChange {
5
- /**
6
- * Duffel's unique identifier for the airline-initiated change
7
- */
8
- id: string;
9
- /**
10
- * Duffel's unique identifier for the order
11
- */
12
- order_id: string;
13
- /**
14
- * List of updated slices and segments following the change
15
- */
16
- added: OrderSlice[];
17
- /**
18
- * List of slices and segments as they were before the change
19
- */
20
- removed: OrderSlice[];
21
- /**
22
- * The action taken in response to this airline-initiated change
23
- */
24
- action_taken: ActionTakenType;
25
- /**
26
- * The ISO 8601 datetime at which an action was taken
27
- */
28
- action_taken_at: string | null;
29
- /**
30
- * The available actions you can take on this Airline-Initiated Change through our API.
31
- * 'update' means that you can use the update endpoint for an Airline-Initiated Change.
32
- */
33
- available_actions: AvailableActionType[];
34
- /**
35
- * The ISO 8601 datetime at which the Payment Intent was created
36
- */
37
- created_at: string;
38
- /**
39
- * The ISO 8601 datetime at which the airline-initiated change was last updated
40
- */
41
- updated_at: string;
42
- }
43
- export declare type AirlineInitiatedChanges = AirlineInitiatedChange[];
1
+ import { Aircraft, Airline, AirlineInitiatedChange, CabinClass, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, FlightsConditions, LoyaltyProgrammeAccount, OfferAvailableServiceBaggage, OfferAvailableServiceBaggageMetadata, PassengerIdentityDocumentType, PaymentType, Place, PlaceType } from '../../types';
44
2
  /**
45
3
  * An object containing metadata about the service, like the designator of the seat.
46
4
  */
@@ -494,7 +452,7 @@ export interface Order {
494
452
  /**
495
453
  * The airline-initiated changes for this order.
496
454
  */
497
- airline_initiated_changes?: AirlineInitiatedChanges;
455
+ airline_initiated_changes?: AirlineInitiatedChange[];
498
456
  }
499
457
  export interface CreateOrder {
500
458
  /**
@@ -539,4 +497,4 @@ export interface AddServices {
539
497
  payment: OrderPayment;
540
498
  add_services: Pick<OrderService, 'id' | 'quantity'>[];
541
499
  }
542
- export declare type OrderAvailableService = OfferAvailableService;
500
+ export declare type OrderAvailableService = OfferAvailableServiceBaggage;
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { Config, DuffelError as _DuffelError } from './Client';
4
4
  import { Aircraft, Airlines, Airports } from './supportingResources';
5
5
  import { Suggestions } from './Places/Suggestions';
6
6
  import { Refunds } from './DuffelPayments/Refunds';
7
- import { Links } from './Links';
7
+ import { Sessions } from './Links';
8
8
  export interface DuffelAPIClient {
9
9
  aircraft: Aircraft;
10
10
  airlines: Airlines;
@@ -24,7 +24,7 @@ export declare class Duffel {
24
24
  aircraft: Aircraft;
25
25
  airlines: Airlines;
26
26
  airports: Airports;
27
- links: Links;
27
+ links: Sessions;
28
28
  offerRequests: OfferRequests;
29
29
  offers: Offers;
30
30
  orders: Orders;
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import t from"node-fetch";import{URL as e,URLSearchParams as s}from"url";function i(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)e.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(s[i[h]]=t[i[h]])}return s}function h(t,e,s,i){return new(s||(s=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 e;t.done?h(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(e){return new Promise((function(s,i){a.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=h[t](e)).value instanceof r?Promise.resolve(s.value.v).then(c,p):u(a[0][2],s)}catch(t){u(a[0][3],t)}var s}function c(t){o("next",t)}function p(t){o("throw",t)}function u(t,e){t(e),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.20.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class n{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),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 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:e}=t,s=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends n{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class u 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 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=>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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),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 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=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m 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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}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="air/payments"}}class g extends n{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),this.path="air/partial_offer_requests"}}class q 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"}}class $ extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}class y{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:r,data:a,params:n,compress:o=!0})=>h(this,void 0,void 0,(function*(){var h;let c,p;const u=new e(r,this.basePath),d={"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(n){const t=new s;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),u.search=t.toString()}a&&(c=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",u.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(u.href,{method:i,headers:d,body:c,compress:o}),l=f.headers.get("content-type");if(p=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in p&&p.errors)throw new $(Object.assign(Object.assign({},p),{headers:f.headers}));return Object.assign(Object.assign({},p),{headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v1",this.debug=n,this.source=o}paginatedRequest({path:t,params:e}){return a(this,arguments,(function*(){let s=yield r(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield r({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield r(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield r({data:t})}}))}}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}/${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 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.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 G 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 w 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 E extends n{constructor(t){super(t),this.generateLink=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/generate_link`,data:t})})),this.path="links"}}class _{constructor(t){this.client=new y(t),this.aircraft=new T(this.client),this.airlines=new O(this.client),this.airports=new b(this.client),this.links=new E(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new d(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new u(this.client),this.payments=new v(this.client),this.seatMaps=new q(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new G(this.client),this.refunds=new w(this.client)}}const P=$;export{_ as Duffel,P as DuffelError};
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(c,p):u(a[0][2],e)}catch(t){u(a[0][3],t)}var e}function c(t){o("next",t)}function p(t){o("throw",t)}function u(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.21.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class n{constructor(t){this.request=({method:t,path:s,data:e,params:i})=>h(this,void 0,void 0,(function*(){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 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}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),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.path="air/offers"}}class u 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 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=>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 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=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m 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 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="air/payments"}}class g 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*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),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 q 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"}}class $ extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}}class y{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:r,data:a,params:n,compress:o=!0})=>h(this,void 0,void 0,(function*(){var h;let c,p;const u=new s(r,this.basePath),d={"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(n){const t=new e;Object.entries(n).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())})),u.search=t.toString()}a&&(c=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",u.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(u.href,{method:i,headers:d,body:c,compress:o}),l=f.headers.get("content-type");if(p=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in p&&p.errors)throw new $(Object.assign(Object.assign({},p),{headers:f.headers}));return Object.assign(Object.assign({},p),{headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v1",this.debug=n,this.source=o}paginatedRequest({path:t,params:s}){return a(this,arguments,(function*(){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield r({data:t})}}))}}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}/${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 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.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 G 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 w 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 E 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 _{constructor(t){this.client=new y(t),this.aircraft=new T(this.client),this.airlines=new O(this.client),this.airports=new b(this.client),this.links=new E(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new d(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new u(this.client),this.payments=new v(this.client),this.seatMaps=new q(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new G(this.client),this.refunds=new w(this.client)}}const P=$;export{_ as Duffel,P as DuffelError};
2
2
  //# sourceMappingURL=index.es.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("node-fetch"),e=require("url");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);function r(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function h(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function n(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),h=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){h.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):p(h[0][2],s)}catch(t){p(h[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}}!function(){const t={npm_package_version:"1.20.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class o{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class u extends o{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 c extends o{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:e}=t,s=r(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class d extends o{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 o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),this.path="air/orders"}}class l extends o{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 o{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 v extends o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class g extends o{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 q extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),this.path="air/partial_offer_requests"}}class $ extends o{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"}}class y extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}class T{constructor({token:t,basePath:s,apiVersion:r,debug:a,source:n}){this.request=({method:t,path:s,data:r,params:a,compress:n=!0})=>h(this,void 0,void 0,(function*(){var h;let o,u;const c=new e.URL(s,this.basePath),p={"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.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),c.search=t.toString()}r&&(o=JSON.stringify({data:Object.assign({},r)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",c.href),console.info("Method: ",t),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const d=yield i.default(c.href,{method:t,headers:p,body:o,compress:n}),f=d.headers.get("content-type");if(u=f&&f.includes("json")?yield d.json():yield d.text(),!d.ok||"errors"in u&&u.errors)throw new y(Object.assign(Object.assign({},u),{headers:d.headers}));return Object.assign(Object.assign({},u),{headers:d.headers})})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=r||"v1",this.debug=a,this.source=n}paginatedRequest({path:t,params:e}){return n(this,arguments,(function*(){let s=yield a(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield a({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield a(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield a({data:t})}}))}}class O extends o{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 o{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 _ extends o{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 E extends o{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 o{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 w extends o{constructor(t){super(t),this.generateLink=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/generate_link`,data:t})})),this.path="links"}}const P=y;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new O(this.client),this.airlines=new b(this.client),this.airports=new _(this.client),this.links=new w(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new g(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new u(this.client),this.partialOfferRequests=new q(this.client),this.suggestions=new E(this.client),this.refunds=new G(this.client)}},exports.DuffelError=P;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("node-fetch"),e=require("url");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);function r(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function h(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function n(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),h=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){h.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):p(h[0][2],s)}catch(t){p(h[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}}!function(){const t={npm_package_version:"1.21.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class o{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class u extends o{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 c extends o{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:e}=t,s=r(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class d extends o{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 o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),this.path="air/orders"}}class l extends o{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 o{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 v extends o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class q extends o{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 g extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),this.path="air/partial_offer_requests"}}class $ extends o{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"}}class y extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}class T{constructor({token:t,basePath:s,apiVersion:r,debug:a,source:n}){this.request=({method:t,path:s,data:r,params:a,compress:n=!0})=>h(this,void 0,void 0,(function*(){var h;let o,u;const c=new e.URL(s,this.basePath),p={"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.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),c.search=t.toString()}r&&(o=JSON.stringify({data:Object.assign({},r)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",c.href),console.info("Method: ",t),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const d=yield i.default(c.href,{method:t,headers:p,body:o,compress:n}),f=d.headers.get("content-type");if(u=f&&f.includes("json")?yield d.json():yield d.text(),!d.ok||"errors"in u&&u.errors)throw new y(Object.assign(Object.assign({},u),{headers:d.headers}));return Object.assign(Object.assign({},u),{headers:d.headers})})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=r||"v1",this.debug=a,this.source=n}paginatedRequest({path:t,params:e}){return n(this,arguments,(function*(){let s=yield a(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield a({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield a(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield a({data:t})}}))}}class O extends o{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 o{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 o{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 G extends o{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 _ extends o{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 w extends o{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"}}const P=y;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new O(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.links=new w(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new u(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new G(this.client),this.refunds=new _(this.client)}},exports.DuffelError=P;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,62 @@
1
1
  import { Headers } from 'node-fetch';
2
2
 
3
+ declare type AirlineInitiatedChangeActionTaken = 'accepted' | 'cancelled' | 'changed';
4
+ declare type AirlineInitiatedChangeAvailableAction = 'accept' | 'cancel' | 'change' | 'update';
5
+ interface AirlineInitiatedChange {
6
+ /**
7
+ * The action taken in response to this airline-initiated change. Accepted,
8
+ * cancelled and changed reflect your action in accepting the change,
9
+ * cancelling the order or changing the order respectively.
10
+ */
11
+ action_taken: AirlineInitiatedChangeActionTaken | null;
12
+ /**
13
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which an
14
+ * action was taken.
15
+ */
16
+ action_taken_at: string | null;
17
+ /**
18
+ * List of updated (slices and segments)[https://duffel.com/docs/api/orders/schema#orders-schema-slices]
19
+ * following the change. These slices and segments may each have a new ID as a
20
+ * result of the changes.
21
+ */
22
+ added: OrderSlice[];
23
+ /**
24
+ * The available actions you can take on this Airline-Initiated Change through
25
+ * our API.`"update"` means that you can use the update endpoint for an
26
+ * Airline-Initiated Change.
27
+ */
28
+ available_actions: AirlineInitiatedChangeAvailableAction[];
29
+ /**
30
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which we
31
+ * detected the airline-initiated change.
32
+ */
33
+ created_at: string;
34
+ /**
35
+ * Duffel's unique identifier for the airline-initiated change.
36
+ */
37
+ id: string;
38
+ /**
39
+ * Duffel's unique identifier for the order.
40
+ */
41
+ order_id: string;
42
+ /**
43
+ * List of (slices and segments)[https://duffel.com/docs/api/orders/schema#orders-schema-slices]
44
+ * as they were before the change.
45
+ */
46
+ removed: OrderSlice[];
47
+ /**
48
+ * The associated Travel Agent Ticket, if any, for this Airline-Initiated
49
+ * Change. This value will be present for Airline-Initiated changes that take
50
+ * some time to be processed.
51
+ */
52
+ travel_agent_ticket: any | null;
53
+ /**
54
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which
55
+ * the airline-initiated change was last updated.
56
+ */
57
+ updated_at: string;
58
+ }
59
+
3
60
  /**
4
61
  * Each offer represents flights you can buy from an airline at a particular price that meet your search criteria.
5
62
  * @link https://duffel.com/docs/api/offers/schema
@@ -106,19 +163,19 @@ interface Offer {
106
163
  }
107
164
  interface OfferAvailableServiceBaggageMetadata {
108
165
  /**
109
- * The maximum weight that the baggage can have in kilograms
166
+ * The maximum weight that the baggage can have in kilograms.
110
167
  */
111
168
  maximum_weight_kg: number | null;
112
169
  /**
113
- * The maximum height that the baggage can have in centimetres
170
+ * The maximum height that the baggage can have in centimetres.
114
171
  */
115
172
  maximum_height_cm: number | null;
116
173
  /**
117
- * The maximum length that the baggage can have in centimetres
174
+ * The maximum length that the baggage can have in centimetres.
118
175
  */
119
176
  maximum_length_cm: number | null;
120
177
  /**
121
- * The maximum depth that the baggage can have in centimetres
178
+ * The maximum depth that the baggage can have in centimetres.
122
179
  */
123
180
  maximum_depth_cm: number | null;
124
181
  /**
@@ -126,70 +183,110 @@ interface OfferAvailableServiceBaggageMetadata {
126
183
  */
127
184
  type: BaggageType;
128
185
  }
129
- interface PaymentRequirements {
186
+ interface OfferAvailableServiceCFARMetadata {
130
187
  /**
131
- * The ISO 8601 datetime by which you must pay for this order.
132
- * At this time, if still unpaid, the reserved space on the flight(s)
133
- * will be released and you will have to create a new order.
134
- * This will be null only for orders where `awaiting_payment` is `false`.
188
+ * The amount the customer will receive back if the service is used, in
189
+ * `offer.total_currency`.
135
190
  */
136
- payment_required_by?: string | null;
191
+ refund_amount: string;
137
192
  /**
138
- * The ISO 8601 datetime at which the price associated
139
- * with the order will no longer be guaranteed by the airline
140
- * and the order will need to be repriced before payment.
141
- * This can be null when there is no price guarantee.
193
+ * Information to display to customers.
142
194
  */
143
- price_guarantee_expires_at?: string | null;
195
+ merchant_copy: string;
144
196
  /**
145
- * Whether immediate payment is required or not
197
+ * URL with the T&Cs for customers.
146
198
  */
147
- requires_instant_payment: boolean;
199
+ terms_and_conditions_url: string;
200
+ type: 'cancel_for_any_reason';
148
201
  }
149
- interface OfferAvailableServiceMetadataMap {
150
- baggage: OfferAvailableServiceBaggageMetadata;
151
- }
152
- declare type OfferAvailableServiceType = keyof OfferAvailableServiceMetadataMap;
153
- interface OfferAvailableService<T_ServiceType extends OfferAvailableServiceType = 'baggage'> {
202
+ interface OfferAvailableServiceCommon {
154
203
  /**
155
- * Duffel's unique identifier for the service
204
+ * Duffel's unique identifier for the service.
156
205
  */
157
206
  id: string;
158
207
  /**
159
- * The maximum quantity of this service that can be booked with an order
208
+ * The maximum quantity of this service that can be booked with an order.
160
209
  */
161
210
  maximum_quantity: number;
162
211
  /**
163
- * An object containing metadata about the service, like the maximum weight and dimensions of the baggage.
164
- */
165
- metadata?: OfferAvailableServiceMetadataMap[T_ServiceType];
166
- /**
167
- * The list of passenger `id`s the service applies to.
168
- * If you add this service to an order it will apply to all the passengers in this list.
169
- * For services where the type is `baggage`, this list will include only a single passenger.
212
+ * The list of passenger `id`s the service applies to. If you add this
213
+ * service to an order it will apply to all the passengers in this list.
214
+ * For services where the type is `baggage`, this list will include only a
215
+ * single passenger.
170
216
  */
171
217
  passenger_ids: string[];
172
218
  /**
173
- * The list of segment ids the service applies to.
174
- * If you add this service to an order it will apply to all the segments in this list.
175
- * For services where the type is baggage, depending on the airline,
176
- * this list includes all the segments of all slices or all the segments of a single slice.
219
+ * The list of segment `id`s the service applies to. If you add this
220
+ * service to an order it will apply to all the segments in this list. For
221
+ * services where the type is `baggage`, depending on the airline, this
222
+ * list includes all the segments of all slices or all the segments of a
223
+ * single slice.
177
224
  */
178
225
  segment_ids: string[];
179
226
  /**
180
- * The total price of the service for all passengers and segments it applies to, including taxes
227
+ * The total price of the service for all passengers and segments it
228
+ * applies to, including taxes. This price is for a single unit of the
229
+ * service.
181
230
  */
182
231
  total_amount: string;
183
232
  /**
184
- * The currency of the `total_amount`, as an ISO 4217 currency code
233
+ * The currency of the `total_amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)
234
+ * currency code. It will match your organisation's billing currency unless
235
+ * you’re using Duffel as an accredited IATA agent, in which case it will be
236
+ * in the currency provided by the airline (which will usually be based on the
237
+ * country where your IATA agency is registered).
185
238
  */
186
239
  total_currency: string;
240
+ }
241
+ interface OfferAvailableServiceBaggage extends OfferAvailableServiceCommon {
242
+ /**
243
+ * The metadata varies by the type of service. It includes further data
244
+ * about the service. For example, for baggages, it may have data about
245
+ * size and weight restrictions.
246
+ */
247
+ metadata: OfferAvailableServiceBaggageMetadata;
248
+ /**
249
+ * The type of the service.
250
+ */
251
+ type: 'baggage';
252
+ }
253
+ interface OfferAvailableServiceCFAR extends OfferAvailableServiceCommon {
254
+ /**
255
+ * The metadata varies by the type of service. It includes further data
256
+ * about the service. For example, for baggages, it may have data about
257
+ * size and weight restrictions.
258
+ */
259
+ metadata: OfferAvailableServiceCFARMetadata;
187
260
  /**
188
261
  * The type of the service.
189
- * For now we only return services of type baggage but we will return other types in the future.
190
- * We won't consider adding new service types a break change.
191
262
  */
192
- type: T_ServiceType;
263
+ type: 'cancel_for_any_reason';
264
+ }
265
+ declare type OfferAvailableService = OfferAvailableServiceBaggage | OfferAvailableServiceCFAR;
266
+ interface PaymentRequirements {
267
+ /**
268
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime by which
269
+ * you must pay for this order. At this time, if still unpaid, the reserved
270
+ * space on the flight(s) will be released and you will have to create a new
271
+ * order. This will be null only for orders where `awaiting_payment` is
272
+ * `false`.
273
+ */
274
+ payment_required_by: string | null;
275
+ /**
276
+ * The ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the
277
+ * price associated with the order will no longer be guaranteed by the airline
278
+ * and may change before payment. This will be null when
279
+ * `requires_instant_payment` is `true`.
280
+ */
281
+ price_guarantee_expires_at: string | null;
282
+ /**
283
+ * When payment is required at the time of booking this will be true and
284
+ * `payment_required_by` and `price_guarantee_expires_at` will be `null`. When
285
+ * payment can be made at a time after booking, this will be `false` and the
286
+ * time limits on the payment will be provided in `payment_required_by` and
287
+ * `price_guarantee_expires_at`.
288
+ */
289
+ requires_instant_payment: boolean;
193
290
  }
194
291
  interface OfferPassenger {
195
292
  /**
@@ -968,48 +1065,6 @@ interface ConfirmOrderChangePayment {
968
1065
  type: PaymentType;
969
1066
  }
970
1067
 
971
- declare type AvailableActionType = 'accept' | 'cancel' | 'change' | 'update';
972
- declare type ActionTakenType = 'accepted' | 'cancelled' | 'changed' | null;
973
- interface AirlineInitiatedChange {
974
- /**
975
- * Duffel's unique identifier for the airline-initiated change
976
- */
977
- id: string;
978
- /**
979
- * Duffel's unique identifier for the order
980
- */
981
- order_id: string;
982
- /**
983
- * List of updated slices and segments following the change
984
- */
985
- added: OrderSlice[];
986
- /**
987
- * List of slices and segments as they were before the change
988
- */
989
- removed: OrderSlice[];
990
- /**
991
- * The action taken in response to this airline-initiated change
992
- */
993
- action_taken: ActionTakenType;
994
- /**
995
- * The ISO 8601 datetime at which an action was taken
996
- */
997
- action_taken_at: string | null;
998
- /**
999
- * The available actions you can take on this Airline-Initiated Change through our API.
1000
- * 'update' means that you can use the update endpoint for an Airline-Initiated Change.
1001
- */
1002
- available_actions: AvailableActionType[];
1003
- /**
1004
- * The ISO 8601 datetime at which the Payment Intent was created
1005
- */
1006
- created_at: string;
1007
- /**
1008
- * The ISO 8601 datetime at which the airline-initiated change was last updated
1009
- */
1010
- updated_at: string;
1011
- }
1012
- declare type AirlineInitiatedChanges = AirlineInitiatedChange[];
1013
1068
  /**
1014
1069
  * An object containing metadata about the service, like the designator of the seat.
1015
1070
  */
@@ -1463,7 +1518,7 @@ interface Order {
1463
1518
  /**
1464
1519
  * The airline-initiated changes for this order.
1465
1520
  */
1466
- airline_initiated_changes?: AirlineInitiatedChanges;
1521
+ airline_initiated_changes?: AirlineInitiatedChange[];
1467
1522
  }
1468
1523
  interface CreateOrder {
1469
1524
  /**
@@ -1508,7 +1563,7 @@ interface AddServices {
1508
1563
  payment: OrderPayment;
1509
1564
  add_services: Pick<OrderService, 'id' | 'quantity'>[];
1510
1565
  }
1511
- declare type OrderAvailableService = OfferAvailableService;
1566
+ declare type OrderAvailableService = OfferAvailableServiceBaggage;
1512
1567
 
1513
1568
  /**
1514
1569
  * To pay for an unpaid order you've previously created, you'll need to create a payment for it.
@@ -2865,7 +2920,7 @@ declare class Refunds extends Resource {
2865
2920
  create: (params: CreateRefund) => Promise<DuffelResponse<Refund>>;
2866
2921
  }
2867
2922
 
2868
- interface GenerateLinkParameters {
2923
+ interface SessionParameters {
2869
2924
  /**
2870
2925
  * A tracking reference for the booking that may be created within this Duffel Links session
2871
2926
  */
@@ -2907,22 +2962,22 @@ interface GenerateLinkParameters {
2907
2962
  */
2908
2963
  checkout_display_text?: string;
2909
2964
  }
2910
- interface GeneratedLink {
2965
+ interface Session {
2911
2966
  /**
2912
2967
  * The Duffel Links url that contains the specified configuration
2913
2968
  */
2914
2969
  url: string;
2915
2970
  }
2916
- declare class Links extends Resource {
2971
+ declare class Sessions extends Resource {
2917
2972
  /**
2918
2973
  * Endpoint path
2919
2974
  */
2920
2975
  path: string;
2921
2976
  constructor(client: Client);
2922
2977
  /**
2923
- * Generate a Duffel Link per the configuration
2978
+ * Create a Duffel Links Session per the configuration
2924
2979
  */
2925
- generateLink: (data: GenerateLinkParameters) => Promise<DuffelResponse<GeneratedLink>>;
2980
+ create: (data: SessionParameters) => Promise<DuffelResponse<Session>>;
2926
2981
  }
2927
2982
 
2928
2983
  interface DuffelAPIClient {
@@ -2944,7 +2999,7 @@ declare class Duffel {
2944
2999
  aircraft: Aircraft;
2945
3000
  airlines: Airlines;
2946
3001
  airports: Airports;
2947
- links: Links;
3002
+ links: Sessions;
2948
3003
  offerRequests: OfferRequests;
2949
3004
  offers: Offers;
2950
3005
  orders: Orders;
@@ -2962,4 +3017,4 @@ declare class Duffel {
2962
3017
  }
2963
3018
  declare const DuffelError: typeof DuffelError$1;
2964
3019
 
2965
- export { ActionTakenType, AddServices, Aircraft$1 as Aircraft, Airline, AirlineInitiatedChange, AirlineInitiatedChanges, Airport, ApiResponseError, ApiResponseMeta, AvailableActionType, BaggageType, CabinClass, City, ConfirmOrderChangePayment, CreateOfferRequest, CreateOfferRequestQueryParameters, CreateOrder, CreateOrderCancellation, CreateOrderChangeParameters, CreateOrderChangeRequest, CreateOrderPassenger, CreatePayment, CreatePaymentIntent, Duffel, DuffelAPIClient, DuffelError, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, DuffelResponse, FlightsConditions, ListOffersParams, ListOrderCancellationsParams, ListParamsOrders, LoyaltyProgrammeAccount, LoyaltyProgrammeAccounts, Offer, OfferAvailableService, OfferAvailableServiceBaggageMetadata, OfferAvailableServiceMetadataMap, OfferAvailableServiceType, OfferPassenger, OfferRequest, OfferRequestPassenger, OfferRequestSlice, OfferSlice, OfferSliceSegment, OfferSliceSegmentPassenger, OfferSliceSegmentPassengerBaggage, Order, OrderAvailableService, OrderCancellation, OrderChange, OrderChangeOffer, OrderChangeOfferSlice, OrderChangeOfferSlices, OrderChangeOffers$1 as OrderChangeOffers, OrderChangeRequestResponse, OrderChangeSliceResponse, OrderDocument, OrderDocumentsType, OrderPassenger, OrderPassengerIdentityDocument, OrderPayment, OrderPaymentStatus, OrderSegmentPassenger, OrderSegmentPassengerBaggage, OrderService, OrderServiceBaggageMetadata, OrderSlice, OrderSliceSegment, PaginationMeta, PassengerIdentityDocumentType, Payment, PaymentIntent, PaymentRequirements, PaymentType, Place, PlaceType, Places, SDKOptions, Seat, SeatMap, SeatMapCabin, SeatMapCabinRow, SeatMapCabinRowSection, SeatMapCabinRowSectionAvailableService, SeatMapCabinRowSectionElement, SeatMapCabinRowSectionElementAmenity, SeatMapCabinRowSectionElementBassinet, SeatMapCabinRowSectionElementCloset, SeatMapCabinRowSectionElementEmpty, SeatMapCabinRowSectionElementExitRow, SeatMapCabinRowSectionElementGalley, SeatMapCabinRowSectionElementLavatory, SeatMapCabinRowSectionElementSeat, SeatMapCabinRowSectionElementStairs, SeatMapCabinRowSectionElementType, UpdateOffer, UpdateSingleOrder };
3020
+ export { AddServices, Aircraft$1 as Aircraft, Airline, AirlineInitiatedChange, AirlineInitiatedChangeActionTaken, AirlineInitiatedChangeAvailableAction, Airport, ApiResponseError, ApiResponseMeta, BaggageType, CabinClass, City, ConfirmOrderChangePayment, CreateOfferRequest, CreateOfferRequestQueryParameters, CreateOrder, CreateOrderCancellation, CreateOrderChangeParameters, CreateOrderChangeRequest, CreateOrderPassenger, CreatePayment, CreatePaymentIntent, Duffel, DuffelAPIClient, DuffelError, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, DuffelResponse, FlightsConditions, ListOffersParams, ListOrderCancellationsParams, ListParamsOrders, LoyaltyProgrammeAccount, LoyaltyProgrammeAccounts, Offer, OfferAvailableService, OfferAvailableServiceBaggage, OfferAvailableServiceBaggageMetadata, OfferAvailableServiceCFAR, OfferAvailableServiceCFARMetadata, OfferAvailableServiceCommon, OfferPassenger, OfferRequest, OfferRequestPassenger, OfferRequestSlice, OfferSlice, OfferSliceSegment, OfferSliceSegmentPassenger, OfferSliceSegmentPassengerBaggage, Order, OrderAvailableService, OrderCancellation, OrderChange, OrderChangeOffer, OrderChangeOfferSlice, OrderChangeOfferSlices, OrderChangeOffers$1 as OrderChangeOffers, OrderChangeRequestResponse, OrderChangeSliceResponse, OrderDocument, OrderDocumentsType, OrderPassenger, OrderPassengerIdentityDocument, OrderPayment, OrderPaymentStatus, OrderSegmentPassenger, OrderSegmentPassengerBaggage, OrderService, OrderServiceBaggageMetadata, OrderSlice, OrderSliceSegment, PaginationMeta, PassengerIdentityDocumentType, Payment, PaymentIntent, PaymentRequirements, PaymentType, Place, PlaceType, Places, SDKOptions, Seat, SeatMap, SeatMapCabin, SeatMapCabinRow, SeatMapCabinRowSection, SeatMapCabinRowSectionAvailableService, SeatMapCabinRowSectionElement, SeatMapCabinRowSectionElementAmenity, SeatMapCabinRowSectionElementBassinet, SeatMapCabinRowSectionElementCloset, SeatMapCabinRowSectionElementEmpty, SeatMapCabinRowSectionElementExitRow, SeatMapCabinRowSectionElementGalley, SeatMapCabinRowSectionElementLavatory, SeatMapCabinRowSectionElementSeat, SeatMapCabinRowSectionElementStairs, SeatMapCabinRowSectionElementType, UpdateOffer, UpdateSingleOrder };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duffel/api",
3
- "version": "1.21.0",
3
+ "version": "1.23.0",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",