@duffel/api 2.14.3 → 2.15.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.
@@ -110,10 +110,6 @@ export interface StaysRate {
110
110
  * The currency of the total_amount, as an ISO 4217 currency code
111
111
  */
112
112
  total_currency: string;
113
- /**
114
- Deprecated. Refer to available_payment_methods instead.
115
- */
116
- payment_method: StaysPaymentType;
117
113
  /**
118
114
  * The methods available for payment of this rate.
119
115
 
@@ -241,17 +237,9 @@ export interface StaysAccommodation {
241
237
  check_in_after_time: string;
242
238
  } | null;
243
239
  /**
244
- * Deprecated: Instructions to access the accommodation in the booking
240
+ * The key collection details for the accommodation.
245
241
  */
246
242
  key_collection: StaysBookingKeyCollection | null;
247
- /**
248
- * The total currency for the cheapest rate for this accommodation, as an ISO 4217 currency code. If rooms data is available, this is equivalent to the cheapest rate for the cheapest room.
249
- */
250
- cheapest_rate_currency: string;
251
- /**
252
- * The total amount for the cheapest rate for this accommodation. If rooms data is available, this is equivalent to the cheapest rate for the cheapest room.
253
- */
254
- cheapest_rate_total_amount: string;
255
243
  /**
256
244
  * The accommodation’s description
257
245
  */
@@ -309,7 +297,7 @@ export interface StaysQuote {
309
297
  /**
310
298
  * The id of the stay quote.
311
299
  *
312
- * Example: "quo_0000AS0NZdKjjnnHZmSUbI"
300
+ * @example: "quo_0000AS0NZdKjjnnHZmSUbI"
313
301
  */
314
302
  id: string;
315
303
  /**
@@ -402,12 +390,6 @@ export interface StaysQuote {
402
390
  * The loyalty programme that this quote supports.
403
391
  */
404
392
  supported_loyalty_programme: StaysLoyaltyProgrammeReference | null;
405
- /**
406
- * A client key to authenticate with Duffel's Card Component when creating a tokenised card.
407
- * This value will be `null` if your organisation does not have this feature enabled,
408
- */
409
- card_component_key: string | null;
410
- adults: number;
411
393
  rooms: number;
412
394
  guests: Array<Guest>;
413
395
  }
@@ -420,6 +402,14 @@ export interface StaysBooking {
420
402
  * The ID of the booking
421
403
  */
422
404
  id: string;
405
+ /**
406
+ * The email of the lead guest of the booking
407
+ */
408
+ email: string;
409
+ /**
410
+ * The phone number of the lead guest of the booking
411
+ */
412
+ phone_number: string;
423
413
  /**
424
414
  * The accommodation object for the booking
425
415
  */
@@ -486,17 +476,12 @@ type Child = {
486
476
  age: number;
487
477
  };
488
478
  export type Guest = Adult | Child;
489
- type OccupancyCriteria = {
490
- rooms: number;
491
- } & ({
492
- adults: number;
493
- } | {
494
- guests: Array<Guest>;
495
- });
496
- type CommonStaysSearchParams = {
479
+ interface CommonStaysSearchParams {
497
480
  check_in_date: string;
498
481
  check_out_date: string;
499
- } & OccupancyCriteria;
482
+ rooms: number;
483
+ guests: Array<Guest>;
484
+ }
500
485
  export type LocationParams = {
501
486
  radius: number;
502
487
  geographic_coordinates: {
@@ -519,9 +504,10 @@ export interface StaysSearchResult {
519
504
  check_in_date: string;
520
505
  check_out_date: string;
521
506
  accommodation: StaysAccommodation;
522
- adults: number;
523
507
  rooms: number;
524
508
  guests: Array<Guest>;
509
+ cheapest_rate_total_amount: string;
510
+ cheapest_rate_currency: string;
525
511
  }
526
512
  export interface StaysLoyaltyProgramme {
527
513
  reference: StaysLoyaltyProgrammeReference;
@@ -1,14 +1,9 @@
1
- import { CabinClass, FlightsConditions, LoyaltyProgrammeAccount, PassengerIdentityDocumentType, Place, PlaceType, Aircraft, Airline, Airport, PaginationMeta, DuffelPassengerType, OfferSliceConditions } from '../../types';
1
+ import { Aircraft, Airline, Airport, CabinClass, CreateOfferRequestPassengerFareType, DuffelPassengerType, FlightsConditions, LoyaltyProgrammeAccount, OfferSliceConditions, PaginationMeta, Place, PlaceType } from '../../types';
2
2
  /**
3
3
  * Each offer represents flights you can buy from an airline at a particular price that meet your search criteria.
4
4
  * @link https://duffel.com/docs/api/offers/schema
5
5
  */
6
6
  export interface Offer {
7
- /**
8
- * The types of identity documents that may be provided for the passengers when creating an order based on this offer.
9
- * If this is `[]`, then you must not provide identity documents.
10
- */
11
- allowed_passenger_identity_document_types: PassengerIdentityDocumentType[];
12
7
  /**
13
8
  * The services that can be booked along with the offer but are not included by default, for example an additional checked bag.
14
9
  * This field is only returned in the Get single offer endpoint.
@@ -106,7 +101,21 @@ export interface Offer {
106
101
  * Partial offers are only ever returned through the multi-step search flow.
107
102
  */
108
103
  partial: boolean;
104
+ /**
105
+ * A list of airline IATA codes whose loyalty programmes are supported when booking the offer.
106
+ * Loyalty programmes present within the offer passengers that are not present in this field shall be ignored at booking.
107
+ * If this is an empty list ([]), no loyalty programmes are supported for the offer and shall be ignored if provided.
108
+ * @example: ["AF","KL","DL"]
109
+ */
110
+ supported_loyalty_programmes: string[];
111
+ /**
112
+ * The types of identity documents supported by the airline and may be provided for the
113
+ * passengers when creating an order based on this offer. Currently, possible types are `passport`,
114
+ * `tax_id`, `known_traveler_number`, and `passenger_redress_number`.
115
+ */
116
+ supported_passenger_identity_document_types: OfferSupportedPassengerIdentityDocumentTypes[];
109
117
  }
118
+ export type OfferSupportedPassengerIdentityDocumentTypes = 'passport' | 'tax_id' | 'known_traveler_number' | 'passenger_redress_number';
110
119
  export interface OfferAvailableServiceBaggageMetadata {
111
120
  /**
112
121
  * The maximum weight that the baggage can have in kilograms.
@@ -284,6 +293,11 @@ export interface OfferPassenger {
284
293
  * Optionally providing one has been deprecated.
285
294
  */
286
295
  id: string;
296
+ /**
297
+ * The fare type of the passenger
298
+ * Example: "contract_bulk"
299
+ */
300
+ fare_type: CreateOfferRequestPassengerFareType | null;
287
301
  }
288
302
  export interface OfferSlice {
289
303
  /**
@@ -37,15 +37,19 @@ export interface OrderCancellation {
37
37
  */
38
38
  order_id: string;
39
39
  /**
40
- * The amount that will be returned to the original payment method if the order is cancelled, determined according to the fare conditions. This may be `0.00` if the fare is non-refundable. It will include the refund amount of the flights and the services booked.
40
+ * The amount that will be returned to the original payment method if the order is cancelled, determined according
41
+ * to the fare conditions. This may be 0.00 if the fare is non-refundable. It will include the refund amount
42
+ * of the flights and the services booked. This may be null in cases where the refund amount is unknown.
43
+ * This only applies in cases where we are unable to get a refund quote from the carrier.
41
44
  */
42
- refund_amount: string;
45
+ refund_amount: string | null;
43
46
  /**
44
- * The currency of the `refund_amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
45
- * It will match your organisation's billing currency unless you're using Duffel as an accredited IATA agent, in which case it will be in the currency provided by the airline (which will usually be based on the country where your IATA agency is registered).
46
- * For pay later orders that are awaiting payment, the refund amount will always be 0.00.
47
+ * The currency of the refund_amount, as an ISO 4217 currency code.
48
+ * It will match your organisation's billing currency unless youre using Duffel as an accredited IATA agent,
49
+ * in which case it will be in the currency provided by the airline (which will usually be based on the
50
+ * country where your IATA agency is registered). For hold orders that are awaiting payment, the refund amount will always be 0.00.
47
51
  */
48
- refund_currency: string;
52
+ refund_currency: string | null;
49
53
  /**
50
54
  * Where the refund, once confirmed, will be sent. `card` is currently a restricted feature. `awaiting_payment` is for pay later orders where no payment has been made yet.
51
55
  */
@@ -178,13 +178,6 @@ export interface CreateOrderPassenger extends Omit<OrderPassenger, 'type'> {
178
178
  * @example "+442080160509"
179
179
  */
180
180
  phone_number: string;
181
- /**
182
- * @deprecated This type is here just for the backward-compatibility until the field is officially removed from the API
183
- *
184
- * The type of the passenger
185
- * @example "adult", "child", or "infant_without_seat"
186
- */
187
- type?: DuffelPassengerType;
188
181
  }
189
182
  export interface OrderSliceSegment {
190
183
  /**
@@ -255,10 +248,6 @@ export interface OrderSliceSegment {
255
248
  distance?: string | null;
256
249
  }
257
250
  export interface OrderSlice {
258
- /**
259
- * Whether this slice can be changed. This can only be true for paid orders.
260
- */
261
- changeable: boolean | null;
262
251
  /**
263
252
  * The conditions associated with this slice, describing the kinds of modifications you can make and any penalties that will apply to those modifications.
264
253
  * This condition is applied only to this slice and to all the passengers associated with this order - for information at the order level (e.g. "what happens if I want to change all the slices?") refer to the `conditions` at the top level. If a particular kind of modification is allowed, you may not always be able to take action through the Duffel API. In some cases, you may need to contact the Duffel support team or the airline directly.
@@ -453,7 +442,19 @@ export interface Order {
453
442
  * The airline-initiated changes for this order.
454
443
  */
455
444
  airline_initiated_changes?: AirlineInitiatedChange[];
445
+ /**
446
+ * The available actions you can take on this order through our API.
447
+ * It's a list of zero or more of the following values:
448
+ *
449
+ * "cancel": You can cancel the order.
450
+ * "change": You can can change the order's slices.
451
+ * "update": You can update some of the order's fields.
452
+ *
453
+ * @example: ["cancel","update"]
454
+ */
455
+ available_actions: OrderAvailableAction[];
456
456
  }
457
+ export type OrderAvailableAction = 'cancel' | 'change' | 'update';
457
458
  export interface CreateOrder {
458
459
  /**
459
460
  * The `id`s of the offers you want to book. You must specify an array containing exactly one selected offer.
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:"2.14.3"};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=({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 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.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 d 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 p 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 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=>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 v extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>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 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.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*(){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 $ 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 T=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,u;let c,d;const p=new s(r,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(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())})),p.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: ",p.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(p.href,{method:i,headers:l,body:c,compress:o});(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 T(Object.assign(Object.assign({},d),{headers:f.headers}));return Object.assign(Object.assign({},d),{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 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/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 _ 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 E 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 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="links/sessions"}}class P 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,{active:s,events:e,url:i})=>h(this,void 0,void 0,(function*(){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=({events:t,url:s})=>h(this,void 0,void 0,(function*(){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.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.path="stays/accommodation"}}class x 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 j 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=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),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 R 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="stays/quotes"}}class k 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 A 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.loyaltyProgrammes=new x(t),this.searchResults=new k(t),this.quotes=new R(t),this.bookings=new j(t)}}class C 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="vault/cards"}}class I{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new b(this.client),this.airports=new _(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new G(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new l(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new v(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new p(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new E(this.client),this.refunds=new w(this.client),this.webhooks=new P(this.client),this.stays=new A(this.client),this.cardsClient=new y(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new C(this.cardsClient)}}const W=T;export{I as Duffel,W 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(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:"3.0.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=({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 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.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 d 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 p 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 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=>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 v extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>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 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.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*(){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 $ 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 T=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,u;let c,d;const p=new s(r,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(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())})),p.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: ",p.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(p.href,{method:i,headers:l,body:c,compress:o});(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 T(Object.assign(Object.assign({},d),{headers:f.headers}));return Object.assign(Object.assign({},d),{headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v2",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 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/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 _ 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 E 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 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="links/sessions"}}class P 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,{active:s,events:e,url:i})=>h(this,void 0,void 0,(function*(){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=({events:t,url:s})=>h(this,void 0,void 0,(function*(){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.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.path="stays/accommodation"}}class x 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 j 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=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),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 R 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="stays/quotes"}}class k 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 A 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.loyaltyProgrammes=new x(t),this.searchResults=new k(t),this.quotes=new R(t),this.bookings=new j(t)}}class C 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="vault/cards"}}class I{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new b(this.client),this.airports=new _(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new G(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new l(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new v(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new p(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new E(this.client),this.refunds=new w(this.client),this.webhooks=new P(this.client),this.stays=new A(this.client),this.cardsClient=new y(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new C(this.cardsClient)}}const W=T;export{I as Duffel,W as DuffelError};
2
2
  //# sourceMappingURL=index.es.js.map
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("node-fetch"),s=require("url");function e(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 i(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 h(t){return this instanceof h?(this.v=t,this):new h(t)}function r(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[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=r[t](s)).value instanceof h?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:"2.14.3"};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 a{constructor(t){this.request=({method:t,path:s,data:e,params:h})=>i(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:h})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class n extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class o extends a{constructor(t){super(t),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>i(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 u extends a{constructor(t){super(t),this.get=t=>i(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=>i(this,void 0,void 0,(function*(){const{return_offers:s,supplier_timeout:i}=t,h=e(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!=i&&{supplier_timeout:i})})})),this.path="air/offer_requests"}}class c extends a{constructor(t){super(t),this.get=(t,s)=>i(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,i=e(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,i=e(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.update=(t,s,e)=>i(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 d extends a{constructor(t){super(t),this.get=t=>i(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=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class p extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>i(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=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class l extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class f extends a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,s)=>i(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 m extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class q extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>i(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,i=e(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.getFaresById=(t,s)=>i(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 g extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let $=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class T{constructor({token:e,basePath:h,apiVersion:r,debug:a,source:n}){this.request=({method:e,path:h,data:r,params:a,compress:n=!0})=>i(this,void 0,void 0,(function*(){var i,o;let u,c;const d=new s.URL(h,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 s.URLSearchParams;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())})),d.search=t.toString()}r&&(u=JSON.stringify({data:Object.assign({},r)})),(null===(i=this.debug)||void 0===i?void 0:i.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",e),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const l=yield t(d.href,{method:e,headers:p,body:u,compress:n});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const f=l.headers.get("content-type");if(c=f&&f.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in c&&c.errors)throw new $(Object.assign(Object.assign({},c),{headers:l.headers}));return Object.assign(Object.assign({},c),{headers:l.headers})})),this.token=e,this.basePath=h||"https://api.duffel.com",this.apiVersion=r||"v1",this.debug=a,this.source=n}paginatedRequest({path:t,params:s}){return r(this,arguments,(function*(){let e=yield h(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield h({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield h(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield h({data:t})}}))}}class y extends a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class _ extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class w extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class G extends a{constructor(t){super(t),this.redeliver=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})})),this.delete=t=>i(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:s,events:e,url:h})=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:h}})})),this.list=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})})),this.create=({events:t,url:s})=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class P extends a{constructor(t){super(t),this.suggestions=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.path="stays/accommodation"}}class S extends a{constructor(t){super(t),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/loyalty_programmes"}}class x extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.cancel=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})})),this.path="stays/bookings"}}class j extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})})),this.path="stays/quotes"}}class R extends a{constructor(t){super(t),this.fetchAllRates=t=>i(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 k extends a{constructor(t){super(t),this.search=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.accommodation=new P(t),this.loyaltyProgrammes=new S(t),this.searchResults=new R(t),this.quotes=new j(t),this.bookings=new x(t)}}class A extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="vault/cards"}}const C=$;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new y(this.client),this.airlines=new O(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new w(this.client),this.offerRequests=new u(this.client),this.offers=new c(this.client),this.orders=new p(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new f(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new m(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new n(this.client),this.partialOfferRequests=new q(this.client),this.suggestions=new E(this.client),this.refunds=new _(this.client),this.webhooks=new G(this.client),this.stays=new k(this.client),this.cardsClient=new T(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new A(this.cardsClient)}},exports.DuffelError=C;
1
+ "use strict";var t=require("node-fetch"),s=require("url");function e(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 i(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 h(t){return this instanceof h?(this.v=t,this):new h(t)}function r(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[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=r[t](s)).value instanceof h?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:"3.0.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 a{constructor(t){this.request=({method:t,path:s,data:e,params:h})=>i(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:h})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class n extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class o extends a{constructor(t){super(t),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>i(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 u extends a{constructor(t){super(t),this.get=t=>i(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=>i(this,void 0,void 0,(function*(){const{return_offers:s,supplier_timeout:i}=t,h=e(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!=i&&{supplier_timeout:i})})})),this.path="air/offer_requests"}}class c extends a{constructor(t){super(t),this.get=(t,s)=>i(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,i=e(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,i=e(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.update=(t,s,e)=>i(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 d extends a{constructor(t){super(t),this.get=t=>i(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=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class p extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>i(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=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class l extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class f extends a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,s)=>i(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 m extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class q extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>i(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,i=e(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.getFaresById=(t,s)=>i(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 g extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let $=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class T{constructor({token:e,basePath:h,apiVersion:r,debug:a,source:n}){this.request=({method:e,path:h,data:r,params:a,compress:n=!0})=>i(this,void 0,void 0,(function*(){var i,o;let u,c;const d=new s.URL(h,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 s.URLSearchParams;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())})),d.search=t.toString()}r&&(u=JSON.stringify({data:Object.assign({},r)})),(null===(i=this.debug)||void 0===i?void 0:i.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",e),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const l=yield t(d.href,{method:e,headers:p,body:u,compress:n});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const f=l.headers.get("content-type");if(c=f&&f.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in c&&c.errors)throw new $(Object.assign(Object.assign({},c),{headers:l.headers}));return Object.assign(Object.assign({},c),{headers:l.headers})})),this.token=e,this.basePath=h||"https://api.duffel.com",this.apiVersion=r||"v2",this.debug=a,this.source=n}paginatedRequest({path:t,params:s}){return r(this,arguments,(function*(){let e=yield h(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield h({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield h(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield h({data:t})}}))}}class y extends a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.get=t=>i(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 a{constructor(t){super(t),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class _ extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class w extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class G extends a{constructor(t){super(t),this.redeliver=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})})),this.delete=t=>i(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:s,events:e,url:h})=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:h}})})),this.list=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})})),this.create=({events:t,url:s})=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class P extends a{constructor(t){super(t),this.suggestions=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.path="stays/accommodation"}}class S extends a{constructor(t){super(t),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/loyalty_programmes"}}class x extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.cancel=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})})),this.path="stays/bookings"}}class j extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})})),this.path="stays/quotes"}}class R extends a{constructor(t){super(t),this.fetchAllRates=t=>i(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 k extends a{constructor(t){super(t),this.search=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.accommodation=new P(t),this.loyaltyProgrammes=new S(t),this.searchResults=new R(t),this.quotes=new j(t),this.bookings=new x(t)}}class A extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="vault/cards"}}const C=$;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new y(this.client),this.airlines=new O(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new w(this.client),this.offerRequests=new u(this.client),this.offers=new c(this.client),this.orders=new p(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new f(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new m(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new n(this.client),this.partialOfferRequests=new q(this.client),this.suggestions=new E(this.client),this.refunds=new _(this.client),this.webhooks=new G(this.client),this.stays=new k(this.client),this.cardsClient=new T(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new A(this.cardsClient)}},exports.DuffelError=C;
2
2
  //# sourceMappingURL=index.js.map
package/dist/typings.d.ts CHANGED
@@ -438,10 +438,6 @@ declare module '@duffel/api/Stays/StaysTypes' {
438
438
  * The currency of the total_amount, as an ISO 4217 currency code
439
439
  */
440
440
  total_currency: string;
441
- /**
442
- Deprecated. Refer to available_payment_methods instead.
443
- */
444
- payment_method: StaysPaymentType;
445
441
  /**
446
442
  * The methods available for payment of this rate.
447
443
 
@@ -569,17 +565,9 @@ declare module '@duffel/api/Stays/StaysTypes' {
569
565
  check_in_after_time: string;
570
566
  } | null;
571
567
  /**
572
- * Deprecated: Instructions to access the accommodation in the booking
568
+ * The key collection details for the accommodation.
573
569
  */
574
570
  key_collection: StaysBookingKeyCollection | null;
575
- /**
576
- * The total currency for the cheapest rate for this accommodation, as an ISO 4217 currency code. If rooms data is available, this is equivalent to the cheapest rate for the cheapest room.
577
- */
578
- cheapest_rate_currency: string;
579
- /**
580
- * The total amount for the cheapest rate for this accommodation. If rooms data is available, this is equivalent to the cheapest rate for the cheapest room.
581
- */
582
- cheapest_rate_total_amount: string;
583
571
  /**
584
572
  * The accommodation’s description
585
573
  */
@@ -637,7 +625,7 @@ declare module '@duffel/api/Stays/StaysTypes' {
637
625
  /**
638
626
  * The id of the stay quote.
639
627
  *
640
- * Example: "quo_0000AS0NZdKjjnnHZmSUbI"
628
+ * @example: "quo_0000AS0NZdKjjnnHZmSUbI"
641
629
  */
642
630
  id: string;
643
631
  /**
@@ -730,12 +718,6 @@ declare module '@duffel/api/Stays/StaysTypes' {
730
718
  * The loyalty programme that this quote supports.
731
719
  */
732
720
  supported_loyalty_programme: StaysLoyaltyProgrammeReference | null;
733
- /**
734
- * A client key to authenticate with Duffel's Card Component when creating a tokenised card.
735
- * This value will be `null` if your organisation does not have this feature enabled,
736
- */
737
- card_component_key: string | null;
738
- adults: number;
739
721
  rooms: number;
740
722
  guests: Array<Guest>;
741
723
  }
@@ -748,6 +730,14 @@ declare module '@duffel/api/Stays/StaysTypes' {
748
730
  * The ID of the booking
749
731
  */
750
732
  id: string;
733
+ /**
734
+ * The email of the lead guest of the booking
735
+ */
736
+ email: string;
737
+ /**
738
+ * The phone number of the lead guest of the booking
739
+ */
740
+ phone_number: string;
751
741
  /**
752
742
  * The accommodation object for the booking
753
743
  */
@@ -814,17 +804,12 @@ declare module '@duffel/api/Stays/StaysTypes' {
814
804
  age: number;
815
805
  };
816
806
  export type Guest = Adult | Child;
817
- type OccupancyCriteria = {
818
- rooms: number;
819
- } & ({
820
- adults: number;
821
- } | {
822
- guests: Array<Guest>;
823
- });
824
- type CommonStaysSearchParams = {
807
+ interface CommonStaysSearchParams {
825
808
  check_in_date: string;
826
809
  check_out_date: string;
827
- } & OccupancyCriteria;
810
+ rooms: number;
811
+ guests: Array<Guest>;
812
+ }
828
813
  export type LocationParams = {
829
814
  radius: number;
830
815
  geographic_coordinates: {
@@ -847,9 +832,10 @@ declare module '@duffel/api/Stays/StaysTypes' {
847
832
  check_in_date: string;
848
833
  check_out_date: string;
849
834
  accommodation: StaysAccommodation;
850
- adults: number;
851
835
  rooms: number;
852
836
  guests: Array<Guest>;
837
+ cheapest_rate_total_amount: string;
838
+ cheapest_rate_currency: string;
853
839
  }
854
840
  export interface StaysLoyaltyProgramme {
855
841
  reference: StaysLoyaltyProgrammeReference;
@@ -1969,17 +1955,12 @@ declare module '@duffel/api/booking/OfferRequests/OfferRequestsTypes' {
1969
1955
  }
1970
1956
 
1971
1957
  declare module '@duffel/api/booking/Offers/OfferTypes' {
1972
- import { CabinClass, FlightsConditions, LoyaltyProgrammeAccount, PassengerIdentityDocumentType, Place, PlaceType, Aircraft, Airline, Airport, PaginationMeta, DuffelPassengerType, OfferSliceConditions } from '@duffel/api/types';
1958
+ import { Aircraft, Airline, Airport, CabinClass, CreateOfferRequestPassengerFareType, DuffelPassengerType, FlightsConditions, LoyaltyProgrammeAccount, OfferSliceConditions, PaginationMeta, Place, PlaceType } from '@duffel/api/types';
1973
1959
  /**
1974
1960
  * Each offer represents flights you can buy from an airline at a particular price that meet your search criteria.
1975
1961
  * @link https://duffel.com/docs/api/offers/schema
1976
1962
  */
1977
1963
  export interface Offer {
1978
- /**
1979
- * The types of identity documents that may be provided for the passengers when creating an order based on this offer.
1980
- * If this is `[]`, then you must not provide identity documents.
1981
- */
1982
- allowed_passenger_identity_document_types: PassengerIdentityDocumentType[];
1983
1964
  /**
1984
1965
  * The services that can be booked along with the offer but are not included by default, for example an additional checked bag.
1985
1966
  * This field is only returned in the Get single offer endpoint.
@@ -2077,7 +2058,21 @@ declare module '@duffel/api/booking/Offers/OfferTypes' {
2077
2058
  * Partial offers are only ever returned through the multi-step search flow.
2078
2059
  */
2079
2060
  partial: boolean;
2061
+ /**
2062
+ * A list of airline IATA codes whose loyalty programmes are supported when booking the offer.
2063
+ * Loyalty programmes present within the offer passengers that are not present in this field shall be ignored at booking.
2064
+ * If this is an empty list ([]), no loyalty programmes are supported for the offer and shall be ignored if provided.
2065
+ * @example: ["AF","KL","DL"]
2066
+ */
2067
+ supported_loyalty_programmes: string[];
2068
+ /**
2069
+ * The types of identity documents supported by the airline and may be provided for the
2070
+ * passengers when creating an order based on this offer. Currently, possible types are `passport`,
2071
+ * `tax_id`, `known_traveler_number`, and `passenger_redress_number`.
2072
+ */
2073
+ supported_passenger_identity_document_types: OfferSupportedPassengerIdentityDocumentTypes[];
2080
2074
  }
2075
+ export type OfferSupportedPassengerIdentityDocumentTypes = 'passport' | 'tax_id' | 'known_traveler_number' | 'passenger_redress_number';
2081
2076
  export interface OfferAvailableServiceBaggageMetadata {
2082
2077
  /**
2083
2078
  * The maximum weight that the baggage can have in kilograms.
@@ -2255,6 +2250,11 @@ declare module '@duffel/api/booking/Offers/OfferTypes' {
2255
2250
  * Optionally providing one has been deprecated.
2256
2251
  */
2257
2252
  id: string;
2253
+ /**
2254
+ * The fare type of the passenger
2255
+ * Example: "contract_bulk"
2256
+ */
2257
+ fare_type: CreateOfferRequestPassengerFareType | null;
2258
2258
  }
2259
2259
  export interface OfferSlice {
2260
2260
  /**
@@ -2588,15 +2588,19 @@ declare module '@duffel/api/booking/OrderCancellations/OrderCancellationsTypes'
2588
2588
  */
2589
2589
  order_id: string;
2590
2590
  /**
2591
- * The amount that will be returned to the original payment method if the order is cancelled, determined according to the fare conditions. This may be `0.00` if the fare is non-refundable. It will include the refund amount of the flights and the services booked.
2591
+ * The amount that will be returned to the original payment method if the order is cancelled, determined according
2592
+ * to the fare conditions. This may be 0.00 if the fare is non-refundable. It will include the refund amount
2593
+ * of the flights and the services booked. This may be null in cases where the refund amount is unknown.
2594
+ * This only applies in cases where we are unable to get a refund quote from the carrier.
2592
2595
  */
2593
- refund_amount: string;
2596
+ refund_amount: string | null;
2594
2597
  /**
2595
- * The currency of the `refund_amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
2596
- * It will match your organisation's billing currency unless you're using Duffel as an accredited IATA agent, in which case it will be in the currency provided by the airline (which will usually be based on the country where your IATA agency is registered).
2597
- * For pay later orders that are awaiting payment, the refund amount will always be 0.00.
2598
+ * The currency of the refund_amount, as an ISO 4217 currency code.
2599
+ * It will match your organisation's billing currency unless youre using Duffel as an accredited IATA agent,
2600
+ * in which case it will be in the currency provided by the airline (which will usually be based on the
2601
+ * country where your IATA agency is registered). For hold orders that are awaiting payment, the refund amount will always be 0.00.
2598
2602
  */
2599
- refund_currency: string;
2603
+ refund_currency: string | null;
2600
2604
  /**
2601
2605
  * Where the refund, once confirmed, will be sent. `card` is currently a restricted feature. `awaiting_payment` is for pay later orders where no payment has been made yet.
2602
2606
  */
@@ -3150,13 +3154,6 @@ declare module '@duffel/api/booking/Orders/OrdersTypes' {
3150
3154
  * @example "+442080160509"
3151
3155
  */
3152
3156
  phone_number: string;
3153
- /**
3154
- * @deprecated This type is here just for the backward-compatibility until the field is officially removed from the API
3155
- *
3156
- * The type of the passenger
3157
- * @example "adult", "child", or "infant_without_seat"
3158
- */
3159
- type?: DuffelPassengerType;
3160
3157
  }
3161
3158
  export interface OrderSliceSegment {
3162
3159
  /**
@@ -3227,10 +3224,6 @@ declare module '@duffel/api/booking/Orders/OrdersTypes' {
3227
3224
  distance?: string | null;
3228
3225
  }
3229
3226
  export interface OrderSlice {
3230
- /**
3231
- * Whether this slice can be changed. This can only be true for paid orders.
3232
- */
3233
- changeable: boolean | null;
3234
3227
  /**
3235
3228
  * The conditions associated with this slice, describing the kinds of modifications you can make and any penalties that will apply to those modifications.
3236
3229
  * This condition is applied only to this slice and to all the passengers associated with this order - for information at the order level (e.g. "what happens if I want to change all the slices?") refer to the `conditions` at the top level. If a particular kind of modification is allowed, you may not always be able to take action through the Duffel API. In some cases, you may need to contact the Duffel support team or the airline directly.
@@ -3425,7 +3418,19 @@ declare module '@duffel/api/booking/Orders/OrdersTypes' {
3425
3418
  * The airline-initiated changes for this order.
3426
3419
  */
3427
3420
  airline_initiated_changes?: AirlineInitiatedChange[];
3421
+ /**
3422
+ * The available actions you can take on this order through our API.
3423
+ * It's a list of zero or more of the following values:
3424
+ *
3425
+ * "cancel": You can cancel the order.
3426
+ * "change": You can can change the order's slices.
3427
+ * "update": You can update some of the order's fields.
3428
+ *
3429
+ * @example: ["cancel","update"]
3430
+ */
3431
+ available_actions: OrderAvailableAction[];
3428
3432
  }
3433
+ export type OrderAvailableAction = 'cancel' | 'change' | 'update';
3429
3434
  export interface CreateOrder {
3430
3435
  /**
3431
3436
  * The `id`s of the offers you want to book. You must specify an array containing exactly one selected offer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duffel/api",
3
- "version": "2.14.3",
3
+ "version": "2.15.0",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -65,7 +65,7 @@
65
65
  },
66
66
  "devDependencies": {
67
67
  "@babel/core": "7.25.2",
68
- "@babel/preset-env": "7.25.3",
68
+ "@babel/preset-env": "7.25.4",
69
69
  "@babel/preset-typescript": "7.24.7",
70
70
  "@commitlint/cli": "17.8.1",
71
71
  "@commitlint/config-angular": "17.8.1",