@duffel/api 2.14.4 → 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
  }
@@ -494,17 +476,12 @@ type Child = {
494
476
  age: number;
495
477
  };
496
478
  export type Guest = Adult | Child;
497
- type OccupancyCriteria = {
498
- rooms: number;
499
- } & ({
500
- adults: number;
501
- } | {
502
- guests: Array<Guest>;
503
- });
504
- type CommonStaysSearchParams = {
479
+ interface CommonStaysSearchParams {
505
480
  check_in_date: string;
506
481
  check_out_date: string;
507
- } & OccupancyCriteria;
482
+ rooms: number;
483
+ guests: Array<Guest>;
484
+ }
508
485
  export type LocationParams = {
509
486
  radius: number;
510
487
  geographic_coordinates: {
@@ -527,9 +504,10 @@ export interface StaysSearchResult {
527
504
  check_in_date: string;
528
505
  check_out_date: string;
529
506
  accommodation: StaysAccommodation;
530
- adults: number;
531
507
  rooms: number;
532
508
  guests: Array<Guest>;
509
+ cheapest_rate_total_amount: string;
510
+ cheapest_rate_currency: string;
533
511
  }
534
512
  export interface StaysLoyaltyProgramme {
535
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.4"};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.4"};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
  }
@@ -822,17 +804,12 @@ declare module '@duffel/api/Stays/StaysTypes' {
822
804
  age: number;
823
805
  };
824
806
  export type Guest = Adult | Child;
825
- type OccupancyCriteria = {
826
- rooms: number;
827
- } & ({
828
- adults: number;
829
- } | {
830
- guests: Array<Guest>;
831
- });
832
- type CommonStaysSearchParams = {
807
+ interface CommonStaysSearchParams {
833
808
  check_in_date: string;
834
809
  check_out_date: string;
835
- } & OccupancyCriteria;
810
+ rooms: number;
811
+ guests: Array<Guest>;
812
+ }
836
813
  export type LocationParams = {
837
814
  radius: number;
838
815
  geographic_coordinates: {
@@ -855,9 +832,10 @@ declare module '@duffel/api/Stays/StaysTypes' {
855
832
  check_in_date: string;
856
833
  check_out_date: string;
857
834
  accommodation: StaysAccommodation;
858
- adults: number;
859
835
  rooms: number;
860
836
  guests: Array<Guest>;
837
+ cheapest_rate_total_amount: string;
838
+ cheapest_rate_currency: string;
861
839
  }
862
840
  export interface StaysLoyaltyProgramme {
863
841
  reference: StaysLoyaltyProgrammeReference;
@@ -1977,17 +1955,12 @@ declare module '@duffel/api/booking/OfferRequests/OfferRequestsTypes' {
1977
1955
  }
1978
1956
 
1979
1957
  declare module '@duffel/api/booking/Offers/OfferTypes' {
1980
- 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';
1981
1959
  /**
1982
1960
  * Each offer represents flights you can buy from an airline at a particular price that meet your search criteria.
1983
1961
  * @link https://duffel.com/docs/api/offers/schema
1984
1962
  */
1985
1963
  export interface Offer {
1986
- /**
1987
- * The types of identity documents that may be provided for the passengers when creating an order based on this offer.
1988
- * If this is `[]`, then you must not provide identity documents.
1989
- */
1990
- allowed_passenger_identity_document_types: PassengerIdentityDocumentType[];
1991
1964
  /**
1992
1965
  * The services that can be booked along with the offer but are not included by default, for example an additional checked bag.
1993
1966
  * This field is only returned in the Get single offer endpoint.
@@ -2085,7 +2058,21 @@ declare module '@duffel/api/booking/Offers/OfferTypes' {
2085
2058
  * Partial offers are only ever returned through the multi-step search flow.
2086
2059
  */
2087
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[];
2088
2074
  }
2075
+ export type OfferSupportedPassengerIdentityDocumentTypes = 'passport' | 'tax_id' | 'known_traveler_number' | 'passenger_redress_number';
2089
2076
  export interface OfferAvailableServiceBaggageMetadata {
2090
2077
  /**
2091
2078
  * The maximum weight that the baggage can have in kilograms.
@@ -2263,6 +2250,11 @@ declare module '@duffel/api/booking/Offers/OfferTypes' {
2263
2250
  * Optionally providing one has been deprecated.
2264
2251
  */
2265
2252
  id: string;
2253
+ /**
2254
+ * The fare type of the passenger
2255
+ * Example: "contract_bulk"
2256
+ */
2257
+ fare_type: CreateOfferRequestPassengerFareType | null;
2266
2258
  }
2267
2259
  export interface OfferSlice {
2268
2260
  /**
@@ -2596,15 +2588,19 @@ declare module '@duffel/api/booking/OrderCancellations/OrderCancellationsTypes'
2596
2588
  */
2597
2589
  order_id: string;
2598
2590
  /**
2599
- * 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.
2600
2595
  */
2601
- refund_amount: string;
2596
+ refund_amount: string | null;
2602
2597
  /**
2603
- * The currency of the `refund_amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
2604
- * 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).
2605
- * 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.
2606
2602
  */
2607
- refund_currency: string;
2603
+ refund_currency: string | null;
2608
2604
  /**
2609
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.
2610
2606
  */
@@ -3158,13 +3154,6 @@ declare module '@duffel/api/booking/Orders/OrdersTypes' {
3158
3154
  * @example "+442080160509"
3159
3155
  */
3160
3156
  phone_number: string;
3161
- /**
3162
- * @deprecated This type is here just for the backward-compatibility until the field is officially removed from the API
3163
- *
3164
- * The type of the passenger
3165
- * @example "adult", "child", or "infant_without_seat"
3166
- */
3167
- type?: DuffelPassengerType;
3168
3157
  }
3169
3158
  export interface OrderSliceSegment {
3170
3159
  /**
@@ -3235,10 +3224,6 @@ declare module '@duffel/api/booking/Orders/OrdersTypes' {
3235
3224
  distance?: string | null;
3236
3225
  }
3237
3226
  export interface OrderSlice {
3238
- /**
3239
- * Whether this slice can be changed. This can only be true for paid orders.
3240
- */
3241
- changeable: boolean | null;
3242
3227
  /**
3243
3228
  * The conditions associated with this slice, describing the kinds of modifications you can make and any penalties that will apply to those modifications.
3244
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.
@@ -3433,7 +3418,19 @@ declare module '@duffel/api/booking/Orders/OrdersTypes' {
3433
3418
  * The airline-initiated changes for this order.
3434
3419
  */
3435
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[];
3436
3432
  }
3433
+ export type OrderAvailableAction = 'cancel' | 'change' | 'update';
3437
3434
  export interface CreateOrder {
3438
3435
  /**
3439
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.4",
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",