@duffel/api 2.6.8 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ export interface StaysRateCancellationTimeline {
44
44
  currency: string;
45
45
  }
46
46
  export type StaysLoyaltyProgramme = 'wyndham_rewards' | 'choice_privileges' | 'marriott_bonvoy' | 'best_western_rewards' | 'world_of_hyatt' | 'hilton_honors' | 'ihg_one_rewards' | 'leaders_club' | 'stash_rewards' | 'omni_select_guest' | 'i_prefer' | 'accor_live_limitless' | 'my_6' | 'jumeirah_one' | 'global_hotel_alliance_discovery' | 'duffel_hotel_group_rewards';
47
+ export type StaysPaymentType = 'balance' | 'card';
47
48
  export interface StaysRate {
48
49
  /**
49
50
  * The currency of the base_amount, as an ISO 4217 currency code.
@@ -110,9 +111,17 @@ export interface StaysRate {
110
111
  */
111
112
  total_currency: string;
112
113
  /**
113
- * The method available for payment of this rate. A rate with the `balance` payment type will be paid for using your Duffel Balance, and a rate with the `card` payment type will be paid for with card details provided at time of booking.
114
+ Deprecated. Refer to available_payment_methods instead.
115
+ */
116
+ payment_method: StaysPaymentType;
117
+ /**
118
+ * The methods available for payment of this rate.
119
+
120
+ A rate with the `balance` payment type can be paid for using your Duffel Balance.
121
+
122
+ A rate with the `card` payment type can be paid for with card details provided at time of booking.
114
123
  */
115
- payment_method: 'balance' | 'card';
124
+ available_payment_methods: StaysPaymentType[];
116
125
  /**
117
126
  * The loyalty programme that this rate supports.
118
127
  * If the rate does not support a loyalty programme, this will be null.
@@ -50,7 +50,7 @@ interface CreateOfferRequestPassengerCommon {
50
50
  */
51
51
  loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
52
52
  }
53
- interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
53
+ export interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
54
54
  age?: never;
55
55
  fare_type?: never;
56
56
  /**
@@ -61,7 +61,7 @@ interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCo
61
61
  */
62
62
  type: Extract<DuffelPassengerType, 'adult'>;
63
63
  }
64
- interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
64
+ export interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
65
65
  /**
66
66
  * The age of the passenger on the `departure_date` of the final slice. e.g.
67
67
  * if you a searching for a round trip and the passenger is 15 years old at
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.6.7"};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}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class 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 f extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class 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.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*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ 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 O{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),f={"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 l=yield t(p.href,{method:i,headers:f,body:c,compress:o});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const v=l.headers.get("content-type");if(d=v&&v.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in d&&d.errors)throw new T(Object.assign(Object.assign({},d),{headers:l.headers}));return Object.assign(Object.assign({},d),{headers:l.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 y extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class E extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class w extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class _ 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.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 x 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 j 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 R 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.searchResults=new j(t),this.quotes=new x(t),this.bookings=new S(t)}}class k extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="vault/cards"}}class A{constructor(t){this.client=new O(t),this.aircraft=new y(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new _(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(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 w(this.client),this.refunds=new G(this.client),this.webhooks=new P(this.client),this.stays=new R(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new k(this.cardsClient)}}const C=T;export{A as Duffel,C 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:"2.7.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}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class 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 f extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class 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.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*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ 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 O{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),f={"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 l=yield t(p.href,{method:i,headers:f,body:c,compress:o});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const v=l.headers.get("content-type");if(d=v&&v.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in d&&d.errors)throw new T(Object.assign(Object.assign({},d),{headers:l.headers}));return Object.assign(Object.assign({},d),{headers:l.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 y extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class E extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class w extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class _ 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.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 x 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 j 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 R 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.searchResults=new j(t),this.quotes=new x(t),this.bookings=new S(t)}}class k extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="vault/cards"}}class A{constructor(t){this.client=new O(t),this.aircraft=new y(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new _(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(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 w(this.client),this.refunds=new G(this.client),this.webhooks=new P(this.client),this.stays=new R(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new k(this.cardsClient)}}const C=T;export{A as Duffel,C 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.6.7"};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}=t,i=e(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{return_offers:s})})})),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 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.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 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.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*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),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 f=yield t(d.href,{method:e,headers:p,body:u,compress:n});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const l=f.headers.get("content-type");if(c=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in c&&c.errors)throw new $(Object.assign(Object.assign({},c),{headers:f.headers}));return Object.assign(Object.assign({},c),{headers:f.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 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/aircraft"}}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/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 w 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 G 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 P 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 _ 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 S 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 x 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 j 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.searchResults=new x(t),this.quotes=new S(t),this.bookings=new _(t)}}class R 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 k=$;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new O(this.client),this.airlines=new y(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new G(this.client),this.offerRequests=new u(this.client),this.offers=new c(this.client),this.orders=new p(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(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 w(this.client),this.webhooks=new P(this.client),this.stays=new j(this.client),this.cardsClient=new T(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new R(this.cardsClient)}},exports.DuffelError=k;
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.7.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}=t,i=e(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{return_offers:s})})})),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 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.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 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.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*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),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 f=yield t(d.href,{method:e,headers:p,body:u,compress:n});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const l=f.headers.get("content-type");if(c=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in c&&c.errors)throw new $(Object.assign(Object.assign({},c),{headers:f.headers}));return Object.assign(Object.assign({},c),{headers:f.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 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/aircraft"}}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/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 w 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 G 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 P 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 _ 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 S 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 x 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 j 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.searchResults=new x(t),this.quotes=new S(t),this.bookings=new _(t)}}class R 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 k=$;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new O(this.client),this.airlines=new y(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new G(this.client),this.offerRequests=new u(this.client),this.offers=new c(this.client),this.orders=new p(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(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 w(this.client),this.webhooks=new P(this.client),this.stays=new j(this.client),this.cardsClient=new T(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new R(this.cardsClient)}},exports.DuffelError=k;
2
2
  //# sourceMappingURL=index.js.map
package/dist/typings.d.ts CHANGED
@@ -207,6 +207,9 @@ declare module '@duffel/api/booking/SeatMaps' {
207
207
  }
208
208
 
209
209
  declare module '@duffel/api/types' {
210
+ export * from '@duffel/api/DuffelPayments/PaymentIntents/PaymentIntentsType';
211
+ export * from '@duffel/api/Places/Suggestions/SuggestionsType';
212
+ export * from '@duffel/api/Stays/StaysTypes';
210
213
  export * from '@duffel/api/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes';
211
214
  export * from '@duffel/api/booking/OfferRequests/OfferRequestsTypes';
212
215
  export * from '@duffel/api/booking/Offers/OfferTypes';
@@ -217,15 +220,13 @@ declare module '@duffel/api/types' {
217
220
  export * from '@duffel/api/booking/Orders/OrdersTypes';
218
221
  export * from '@duffel/api/booking/Payments/PaymentsTypes';
219
222
  export * from '@duffel/api/booking/SeatMaps/SeatMapTypes';
223
+ export * from '@duffel/api/notifications/Webhooks/WebhooksType';
220
224
  export * from '@duffel/api/supportingResources/Aircraft/AircraftTypes';
221
225
  export * from '@duffel/api/supportingResources/Airlines/AirlinesTypes';
222
226
  export * from '@duffel/api/supportingResources/Airports/AirportsTypes';
223
- export * from '@duffel/api/DuffelPayments/PaymentIntents/PaymentIntentsType';
224
- export * from '@duffel/api/Places/Suggestions/SuggestionsType';
225
- export * from '@duffel/api/types/shared';
226
227
  export * from '@duffel/api/types/ClientType';
227
- export * from '@duffel/api/notifications/Webhooks/WebhooksType';
228
- export * from '@duffel/api/Stays/StaysTypes';
228
+ export * from '@duffel/api/types/Identity';
229
+ export * from '@duffel/api/types/shared';
229
230
  }
230
231
 
231
232
  declare module '@duffel/api/supportingResources/Aircraft' {
@@ -366,6 +367,7 @@ declare module '@duffel/api/Stays/StaysTypes' {
366
367
  currency: string;
367
368
  }
368
369
  export type StaysLoyaltyProgramme = 'wyndham_rewards' | 'choice_privileges' | 'marriott_bonvoy' | 'best_western_rewards' | 'world_of_hyatt' | 'hilton_honors' | 'ihg_one_rewards' | 'leaders_club' | 'stash_rewards' | 'omni_select_guest' | 'i_prefer' | 'accor_live_limitless' | 'my_6' | 'jumeirah_one' | 'global_hotel_alliance_discovery' | 'duffel_hotel_group_rewards';
370
+ export type StaysPaymentType = 'balance' | 'card';
369
371
  export interface StaysRate {
370
372
  /**
371
373
  * The currency of the base_amount, as an ISO 4217 currency code.
@@ -432,9 +434,17 @@ declare module '@duffel/api/Stays/StaysTypes' {
432
434
  */
433
435
  total_currency: string;
434
436
  /**
435
- * The method available for payment of this rate. A rate with the `balance` payment type will be paid for using your Duffel Balance, and a rate with the `card` payment type will be paid for with card details provided at time of booking.
437
+ Deprecated. Refer to available_payment_methods instead.
438
+ */
439
+ payment_method: StaysPaymentType;
440
+ /**
441
+ * The methods available for payment of this rate.
442
+
443
+ A rate with the `balance` payment type can be paid for using your Duffel Balance.
444
+
445
+ A rate with the `card` payment type can be paid for with card details provided at time of booking.
436
446
  */
437
- payment_method: 'balance' | 'card';
447
+ available_payment_methods: StaysPaymentType[];
438
448
  /**
439
449
  * The loyalty programme that this rate supports.
440
450
  * If the rate does not support a loyalty programme, this will be null.
@@ -1387,6 +1397,183 @@ declare module '@duffel/api/booking/SeatMaps/SeatMaps' {
1387
1397
  }
1388
1398
  }
1389
1399
 
1400
+ declare module '@duffel/api/DuffelPayments/PaymentIntents/PaymentIntentsType' {
1401
+ export interface PaymentIntent {
1402
+ /**
1403
+ * The amount of the Payment Intent that covers the cost of the flight being sold and any additional markup.
1404
+ * The card payment will be charged this amount.
1405
+ */
1406
+ amount: string;
1407
+ /**
1408
+ * The [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country that issued the card used to confirm the Payment Intent.
1409
+ * It will be null until the Payment Intent is confirmed.
1410
+ */
1411
+ card_country_code: string | null;
1412
+ /**
1413
+ * The last four digits of the card used to confirm the Payment Intent.
1414
+ * It will be null until the Payment Intent is confirmed.
1415
+ */
1416
+ card_last_four_digits: string | null;
1417
+ /**
1418
+ * The card network in which the Payment Intent was processed on.
1419
+ * It will be null until the Payment Intent is confirmed.
1420
+ */
1421
+ card_network: 'amex' | 'cartes_bancaires' | 'diners' | 'discover' | 'interac' | 'jcb' | 'mastercard' | 'unionpay' | 'visa' | 'unknown' | null;
1422
+ /**
1423
+ * This value is used when displaying the payment collection form to securely identify and transmit the values to Duffel.
1424
+ */
1425
+ client_token: string;
1426
+ /**
1427
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was confirmed
1428
+ */
1429
+ confirmed_at: string;
1430
+ /**
1431
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was created
1432
+ */
1433
+ created_at: string;
1434
+ /**
1435
+ * The currency of the `amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1436
+ * The card payment will be charged in this currency.
1437
+ * If it's different to your Balance currency, it will be converted to your Balance currency before the Balance is topped up.
1438
+ */
1439
+ currency: string;
1440
+ /**
1441
+ * The amount of the fees to process the Payment Intent.
1442
+ * It will be `null` until the Payment Intent is confirmed.
1443
+ */
1444
+ fees_amount: string | null;
1445
+ /**
1446
+ * The currency of the fees_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1447
+ * This currency will match your Balance currency.
1448
+ * It will be null until the Payment Intent is confirmed.
1449
+ */
1450
+ fees_currency: string | null;
1451
+ /**
1452
+ * Duffel's unique identifier for the `Payment Intent`
1453
+ */
1454
+ id: string;
1455
+ /**
1456
+ * Whether the Payment Intent was created in live mode. This field will be set to `true` if the Payment Intent was created in live mode, or `false` if it was created in test mode.
1457
+ */
1458
+ live_mode: boolean;
1459
+ /**
1460
+ * The amount of the Payment Intent that was added to the Balance.
1461
+ * It'll be `amount` (in the Balance currency) less the `fees_amount`.
1462
+ * It will be `null` until the Payment Intent is confirmed.
1463
+ */
1464
+ net_amount: string | null;
1465
+ /**
1466
+ * The currency of the net_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1467
+ * This currency will match your Balance currency.
1468
+ * It will be null until the Payment Intent is confirmed.
1469
+ */
1470
+ net_currency: string | null;
1471
+ /**
1472
+ * The Refunds for this Payment Intent
1473
+ * @link https://duffel.com/docs/api/payment-intents/schema#payment-intents-schema-refunds
1474
+ */
1475
+ refunds: {
1476
+ amount: string;
1477
+ arrival: string;
1478
+ created_at: string;
1479
+ currency: string;
1480
+ destination: string;
1481
+ id: string;
1482
+ live_mode: boolean;
1483
+ net_amount: string;
1484
+ net_currency: string;
1485
+ payment_intent_id: string;
1486
+ status: 'succeeded' | 'pending' | 'failed';
1487
+ updated_at: string;
1488
+ }[];
1489
+ /**
1490
+ * The status of this Payment Intent
1491
+ */
1492
+ status: null | 'requires_payment_method' | 'requires_confirmation' | 'requires_action' | 'processing' | 'requires_capture' | 'cancelled' | 'succeeded';
1493
+ /**
1494
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was updated
1495
+ */
1496
+ updated_at: string;
1497
+ }
1498
+ export interface CreatePaymentIntent {
1499
+ /**
1500
+ * This is the amount that the card payment being taken will be charged.
1501
+ * It should be enough to cover the service(s) you want to sell (enough to book an Offer for example) and the processing fees.
1502
+ * If the currency is different from your Balance currency you should also account for foreign exchange.
1503
+ * It can be higher than that, in which case the remainder will be considered your markup.
1504
+ * If it's higher than the maximum allowed for you organisation you will get a validation error. By default the maximum is 5,000.00 GBP (or equivalent in the same currency). If you need a maximum higher than the default please get in touch with us via help@duffel.com.
1505
+ */
1506
+ amount: string;
1507
+ /**
1508
+ * The currency of the amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1509
+ * This is going to be the currency that the card payment being taken in will be charged in.
1510
+ */
1511
+ currency: string;
1512
+ }
1513
+ }
1514
+
1515
+ declare module '@duffel/api/Places/Suggestions/SuggestionsType' {
1516
+ import { Airport, City } from '@duffel/api/types';
1517
+ export interface Places {
1518
+ /**
1519
+ * The type of the place
1520
+ */
1521
+ type: string;
1522
+ /**
1523
+ * The time zone of the airport, specified by name from the tz database
1524
+ */
1525
+ time_zone: string | null;
1526
+ /**
1527
+ * The name of the place
1528
+ */
1529
+ name: string;
1530
+ /**
1531
+ * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
1532
+ */
1533
+ longitude: number | null;
1534
+ /**
1535
+ * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
1536
+ */
1537
+ latitude: number | null;
1538
+ /**
1539
+ * Duffel's unique identifier for the place
1540
+ */
1541
+ id: string;
1542
+ /**
1543
+ * The four-character ICAO code for the airport
1544
+ */
1545
+ icao_code: string | null;
1546
+ /**
1547
+ * The ISO 3166-1 alpha-2 code for the country where the city is located
1548
+ */
1549
+ iata_country_code: string;
1550
+ /**
1551
+ * The 3-letter IATA code for the place
1552
+ */
1553
+ iata_code: string;
1554
+ /**
1555
+ * The 3-letter IATA code for the city where the place is located. Only present for airports which are registered with IATA as belonging to a metropolitan area.
1556
+ */
1557
+ iata_city_code: string | null;
1558
+ /**
1559
+ * The name of the country where the city or airport is located
1560
+ */
1561
+ country_name: string | null;
1562
+ /**
1563
+ * The name of the city (or cities separated by a /) where the airport is located
1564
+ */
1565
+ city_name: string | null;
1566
+ /**
1567
+ * The metropolitan area where the airport is located. Only present for airports which are registered with IATA as belonging to a metropolitan area.
1568
+ */
1569
+ city: City | null;
1570
+ /**
1571
+ * The airports associated to a city. This will only be provided where the type is city.
1572
+ */
1573
+ airports: Airport[] | null;
1574
+ }
1575
+ }
1576
+
1390
1577
  declare module '@duffel/api/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes' {
1391
1578
  import { OrderSlice } from '@duffel/api/types';
1392
1579
  export type AirlineInitiatedChangeActionTaken = 'accepted' | 'cancelled' | 'changed';
@@ -1500,7 +1687,7 @@ declare module '@duffel/api/booking/OfferRequests/OfferRequestsTypes' {
1500
1687
  */
1501
1688
  loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
1502
1689
  }
1503
- interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
1690
+ export interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
1504
1691
  age?: never;
1505
1692
  fare_type?: never;
1506
1693
  /**
@@ -1511,7 +1698,7 @@ declare module '@duffel/api/booking/OfferRequests/OfferRequestsTypes' {
1511
1698
  */
1512
1699
  type: Extract<DuffelPassengerType, 'adult'>;
1513
1700
  }
1514
- interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
1701
+ export interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
1515
1702
  /**
1516
1703
  * The age of the passenger on the `departure_date` of the final slice. e.g.
1517
1704
  * if you a searching for a round trip and the passenger is 15 years old at
@@ -3359,279 +3546,415 @@ declare module '@duffel/api/booking/SeatMaps/SeatMapTypes' {
3359
3546
  export type SeatMapCabinRowSectionElementAmenity = Exclude<SeatMapCabinRowSectionElementType, 'empty' | 'seat'>;
3360
3547
  }
3361
3548
 
3362
- declare module '@duffel/api/supportingResources/Aircraft/AircraftTypes' {
3363
- /**
3364
- * Aircraft are used to describe what passengers will fly in for a given trip
3365
- * @link https://duffel.com/docs/api/aircraft/schema
3366
- */
3367
- export interface Aircraft {
3549
+ declare module '@duffel/api/notifications/Webhooks/WebhooksType' {
3550
+ import { PaginationMeta } from '@duffel/api/types';
3551
+ export interface Webhooks {
3368
3552
  /**
3369
- * The name of the aircraft
3553
+ * Whether the webhook receiver is actively being notified or not
3370
3554
  */
3371
- name: string;
3555
+ active: boolean;
3372
3556
  /**
3373
- * Duffel's unique identifier for the aircraft
3557
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
3374
3558
  */
3375
- id: string;
3559
+ created_at: string;
3376
3560
  /**
3377
- * The three-character IATA code for the aircraft
3561
+ * The events that this webhook will be subscribed to
3378
3562
  */
3379
- iata_code: string;
3380
- }
3381
- }
3382
-
3383
- declare module '@duffel/api/supportingResources/Airlines/AirlinesTypes' {
3384
- /**
3385
- * Airlines are used to identify the air travel companies selling and operating flights
3386
- * @link https://duffel.com/docs/api/airlines/schema
3387
- */
3388
- export interface Airline {
3563
+ events: string[];
3389
3564
  /**
3390
- * The three-character IATA code for the airline
3565
+ * Duffel's unique identifier for the webhook receiver
3391
3566
  */
3392
- name: string;
3567
+ id: string;
3393
3568
  /**
3394
- * Duffel's unique identifier for the airline
3569
+ * The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
3395
3570
  */
3396
- id: string;
3397
- iata_code: string;
3398
- logo_lockup_url?: string;
3399
- logo_symbol_url?: string;
3400
- }
3401
- }
3402
-
3403
- declare module '@duffel/api/supportingResources/Airports/AirportsTypes' {
3404
- import { City } from '@duffel/api/types';
3405
- /**
3406
- * Airports are used to identify origins and destinations in journey slices
3407
- * @link https://duffel.com/docs/api/airports/schema
3408
- */
3409
- export interface Airport {
3571
+ live_mode: boolean;
3410
3572
  /**
3411
- * The metropolitan area where the airport is located.
3412
- * Only present for airports which are registered with IATA as belonging to a metropolitan area.
3573
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the order change was updated
3413
3574
  */
3414
- city?: City | null;
3575
+ updated_at: string;
3415
3576
  /**
3416
- * The name of the city (or cities separated by a `/`) where the airport is located
3577
+ * The URL where your webhook will be received
3417
3578
  */
3418
- city_name: string;
3579
+ url: string;
3580
+ }
3581
+ export interface WebhooksListDeliveriesParams extends PaginationMeta {
3582
+ delivery_success: boolean;
3419
3583
  /**
3420
- * The three-character IATA code for the airport
3584
+ * Filters the returned webhook deliveries by creation datetime.
3421
3585
  */
3422
- iata_code?: string;
3586
+ created_at?: PaginationMeta;
3423
3587
  /**
3424
- * The ISO 3166-1 alpha-2 code for the country where the city is located
3425
- * @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
3426
- * @example "GB"
3427
- */
3428
- iata_country_code: string;
3429
- /**
3430
- * The 3-letter IATA code for the city where the place is located.
3431
- * Only present for airports which are registered with IATA as belonging to a [metropolitan area](https://portal.iata.org/faq/articles/en_US/FAQ/How-do-I-create-a-new-Metropolitan-Area).
3588
+ * Filters webhook deliveries by the type of their related webhook event.
3432
3589
  */
3433
- iata_city_code?: string | null;
3590
+ type?: string;
3434
3591
  /**
3435
- * The four-character ICAO code for the airport
3592
+ * Filters webhook deliveries by the ID of the related webhook endpoint.
3436
3593
  */
3437
- icao_code?: string;
3594
+ endpoint_id: string;
3595
+ }
3596
+ export interface WebhooksUpdateParams {
3438
3597
  /**
3439
- * Duffel's unique identifier for the airport
3598
+ * The desired active status of the webhook
3440
3599
  */
3441
- id: string;
3600
+ active: boolean;
3442
3601
  /**
3443
- * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
3602
+ * The desired events that the webhook should subscribe to
3444
3603
  */
3445
- latitude: number;
3604
+ events: string[];
3446
3605
  /**
3447
- * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
3606
+ * The desired url of the webhook
3448
3607
  */
3449
- longitude: number;
3608
+ url: string;
3609
+ }
3610
+ export interface WebhooksCreateParams {
3450
3611
  /**
3451
- * The name of the airport
3612
+ * The desired events that the webhook should subscribe to
3452
3613
  */
3453
- name: string;
3614
+ events: string[];
3454
3615
  /**
3455
- * The time zone of the airport, specified by name from the [tz database](https://en.wikipedia.org/wiki/Tz_database)
3616
+ * The desired url of the webhook
3456
3617
  */
3457
- time_zone: string;
3618
+ url: string;
3458
3619
  }
3459
- }
3460
-
3461
- declare module '@duffel/api/DuffelPayments/PaymentIntents/PaymentIntentsType' {
3462
- export interface PaymentIntent {
3620
+ export interface WebhooksListDeliveriesResponse {
3463
3621
  /**
3464
- * The amount of the Payment Intent that covers the cost of the flight being sold and any additional markup.
3465
- * The card payment will be charged this amount.
3622
+ * The URL where your webhook will be received
3466
3623
  */
3467
- amount: string;
3624
+ url: string;
3625
+ endpoint_id: string;
3468
3626
  /**
3469
- * The [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country that issued the card used to confirm the Payment Intent.
3470
- * It will be null until the Payment Intent is confirmed.
3627
+ * Webhook deliveries will be included if they were successful.
3471
3628
  */
3472
- card_country_code: string | null;
3629
+ delivery_success?: boolean;
3630
+ type: string;
3631
+ response_status_code: 200;
3632
+ response_body: string;
3633
+ event_id: string;
3473
3634
  /**
3474
- * The last four digits of the card used to confirm the Payment Intent.
3475
- * It will be null until the Payment Intent is confirmed.
3635
+ * The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
3476
3636
  */
3477
- card_last_four_digits: string | null;
3637
+ live_mode: boolean;
3478
3638
  /**
3479
- * The card network in which the Payment Intent was processed on.
3480
- * It will be null until the Payment Intent is confirmed.
3639
+ * Duffel's unique identifier for the webhook receiver
3481
3640
  */
3482
- card_network: 'amex' | 'cartes_bancaires' | 'diners' | 'discover' | 'interac' | 'jcb' | 'mastercard' | 'unionpay' | 'visa' | 'unknown' | null;
3641
+ id: string;
3483
3642
  /**
3484
- * This value is used when displaying the payment collection form to securely identify and transmit the values to Duffel.
3643
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
3485
3644
  */
3486
- client_token: string;
3645
+ created_at: string;
3646
+ }
3647
+ export interface WebhooksListResponse extends Webhooks {
3487
3648
  /**
3488
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was confirmed
3649
+ * Webhook deliveries will be included if they were successful.
3489
3650
  */
3490
- confirmed_at: string;
3651
+ delivery_success?: boolean;
3652
+ }
3653
+ export interface WebhooksCreateResponse {
3654
+ secret: string;
3655
+ url: string;
3656
+ updated_at: string;
3657
+ live_mode: boolean;
3658
+ id: string;
3659
+ events: string[];
3660
+ created_at: string;
3661
+ active: boolean;
3662
+ }
3663
+ }
3664
+
3665
+ declare module '@duffel/api/supportingResources/Aircraft/AircraftTypes' {
3666
+ /**
3667
+ * Aircraft are used to describe what passengers will fly in for a given trip
3668
+ * @link https://duffel.com/docs/api/aircraft/schema
3669
+ */
3670
+ export interface Aircraft {
3491
3671
  /**
3492
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was created
3672
+ * The name of the aircraft
3493
3673
  */
3494
- created_at: string;
3674
+ name: string;
3495
3675
  /**
3496
- * The currency of the `amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
3497
- * The card payment will be charged in this currency.
3498
- * If it's different to your Balance currency, it will be converted to your Balance currency before the Balance is topped up.
3676
+ * Duffel's unique identifier for the aircraft
3499
3677
  */
3500
- currency: string;
3678
+ id: string;
3501
3679
  /**
3502
- * The amount of the fees to process the Payment Intent.
3503
- * It will be `null` until the Payment Intent is confirmed.
3680
+ * The three-character IATA code for the aircraft
3504
3681
  */
3505
- fees_amount: string | null;
3682
+ iata_code: string;
3683
+ }
3684
+ }
3685
+
3686
+ declare module '@duffel/api/supportingResources/Airlines/AirlinesTypes' {
3687
+ /**
3688
+ * Airlines are used to identify the air travel companies selling and operating flights
3689
+ * @link https://duffel.com/docs/api/airlines/schema
3690
+ */
3691
+ export interface Airline {
3506
3692
  /**
3507
- * The currency of the fees_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
3508
- * This currency will match your Balance currency.
3509
- * It will be null until the Payment Intent is confirmed.
3693
+ * The three-character IATA code for the airline
3510
3694
  */
3511
- fees_currency: string | null;
3695
+ name: string;
3512
3696
  /**
3513
- * Duffel's unique identifier for the `Payment Intent`
3697
+ * Duffel's unique identifier for the airline
3514
3698
  */
3515
3699
  id: string;
3700
+ iata_code: string;
3701
+ logo_lockup_url?: string;
3702
+ logo_symbol_url?: string;
3703
+ }
3704
+ }
3705
+
3706
+ declare module '@duffel/api/supportingResources/Airports/AirportsTypes' {
3707
+ import { City } from '@duffel/api/types';
3708
+ /**
3709
+ * Airports are used to identify origins and destinations in journey slices
3710
+ * @link https://duffel.com/docs/api/airports/schema
3711
+ */
3712
+ export interface Airport {
3516
3713
  /**
3517
- * Whether the Payment Intent was created in live mode. This field will be set to `true` if the Payment Intent was created in live mode, or `false` if it was created in test mode.
3714
+ * The metropolitan area where the airport is located.
3715
+ * Only present for airports which are registered with IATA as belonging to a metropolitan area.
3518
3716
  */
3519
- live_mode: boolean;
3717
+ city?: City | null;
3520
3718
  /**
3521
- * The amount of the Payment Intent that was added to the Balance.
3522
- * It'll be `amount` (in the Balance currency) less the `fees_amount`.
3523
- * It will be `null` until the Payment Intent is confirmed.
3719
+ * The name of the city (or cities separated by a `/`) where the airport is located
3524
3720
  */
3525
- net_amount: string | null;
3721
+ city_name: string;
3526
3722
  /**
3527
- * The currency of the net_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
3528
- * This currency will match your Balance currency.
3529
- * It will be null until the Payment Intent is confirmed.
3723
+ * The three-character IATA code for the airport
3530
3724
  */
3531
- net_currency: string | null;
3725
+ iata_code?: string;
3532
3726
  /**
3533
- * The Refunds for this Payment Intent
3534
- * @link https://duffel.com/docs/api/payment-intents/schema#payment-intents-schema-refunds
3727
+ * The ISO 3166-1 alpha-2 code for the country where the city is located
3728
+ * @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
3729
+ * @example "GB"
3535
3730
  */
3536
- refunds: {
3537
- amount: string;
3538
- arrival: string;
3539
- created_at: string;
3540
- currency: string;
3541
- destination: string;
3542
- id: string;
3543
- live_mode: boolean;
3544
- net_amount: string;
3545
- net_currency: string;
3546
- payment_intent_id: string;
3547
- status: 'succeeded' | 'pending' | 'failed';
3548
- updated_at: string;
3549
- }[];
3731
+ iata_country_code: string;
3550
3732
  /**
3551
- * The status of this Payment Intent
3733
+ * The 3-letter IATA code for the city where the place is located.
3734
+ * Only present for airports which are registered with IATA as belonging to a [metropolitan area](https://portal.iata.org/faq/articles/en_US/FAQ/How-do-I-create-a-new-Metropolitan-Area).
3552
3735
  */
3553
- status: null | 'requires_payment_method' | 'requires_confirmation' | 'requires_action' | 'processing' | 'requires_capture' | 'cancelled' | 'succeeded';
3736
+ iata_city_code?: string | null;
3554
3737
  /**
3555
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was updated
3738
+ * The four-character ICAO code for the airport
3556
3739
  */
3557
- updated_at: string;
3558
- }
3559
- export interface CreatePaymentIntent {
3740
+ icao_code?: string;
3560
3741
  /**
3561
- * This is the amount that the card payment being taken will be charged.
3562
- * It should be enough to cover the service(s) you want to sell (enough to book an Offer for example) and the processing fees.
3563
- * If the currency is different from your Balance currency you should also account for foreign exchange.
3564
- * It can be higher than that, in which case the remainder will be considered your markup.
3565
- * If it's higher than the maximum allowed for you organisation you will get a validation error. By default the maximum is 5,000.00 GBP (or equivalent in the same currency). If you need a maximum higher than the default please get in touch with us via help@duffel.com.
3742
+ * Duffel's unique identifier for the airport
3566
3743
  */
3567
- amount: string;
3744
+ id: string;
3568
3745
  /**
3569
- * The currency of the amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
3570
- * This is going to be the currency that the card payment being taken in will be charged in.
3746
+ * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
3571
3747
  */
3572
- currency: string;
3748
+ latitude: number;
3749
+ /**
3750
+ * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
3751
+ */
3752
+ longitude: number;
3753
+ /**
3754
+ * The name of the airport
3755
+ */
3756
+ name: string;
3757
+ /**
3758
+ * The time zone of the airport, specified by name from the [tz database](https://en.wikipedia.org/wiki/Tz_database)
3759
+ */
3760
+ time_zone: string;
3573
3761
  }
3574
3762
  }
3575
3763
 
3576
- declare module '@duffel/api/Places/Suggestions/SuggestionsType' {
3577
- import { Airport, City } from '@duffel/api/types';
3578
- export interface Places {
3764
+ declare module '@duffel/api/types/ClientType' {
3765
+ import { Headers } from 'node-fetch';
3766
+ /**
3767
+ * Our list APIs will only return a limited number of results at a time.
3768
+ * By default, we'll return 50 results per page, but you can set this to any number between 1 and 200.
3769
+ * @link https://duffel.com/docs/api/overview/pagination
3770
+ */
3771
+ export interface PaginationMeta {
3579
3772
  /**
3580
- * The type of the place
3773
+ * The number of results to be returned in a page, between 1 and 200 (optional, default is 50)
3581
3774
  */
3582
- type: string;
3775
+ limit?: number;
3583
3776
  /**
3584
- * The time zone of the airport, specified by name from the tz database
3777
+ * "Before" cursor for pagination
3585
3778
  */
3586
- time_zone: string | null;
3779
+ before?: string;
3587
3780
  /**
3588
- * The name of the place
3781
+ * "After" cursor for pagination
3589
3782
  */
3590
- name: string;
3783
+ after?: string | null;
3784
+ }
3785
+ export interface ApiResponseMeta {
3591
3786
  /**
3592
- * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
3787
+ * The identifier of the request
3593
3788
  */
3594
- longitude: number | null;
3789
+ request_id: string;
3595
3790
  /**
3596
- * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
3791
+ * The [HTTP status](https://httpstatuses.com/) of the request
3597
3792
  */
3598
- latitude: number | null;
3793
+ status: number;
3794
+ }
3795
+ /**
3796
+ * Duffel uses standard [HTTP response codes](https://httpstatuses.com/) to indicate the success or failure of API requests.
3797
+ * @link https://duffel.com/docs/api/overview/errors
3798
+ */
3799
+ export interface ApiResponseError {
3599
3800
  /**
3600
- * Duffel's unique identifier for the place
3801
+ * A machine-readable identifier for this specific error
3601
3802
  */
3602
- id: string;
3803
+ code: string;
3603
3804
  /**
3604
- * The four-character ICAO code for the airport
3805
+ * A URL pointing to a place in our documentation where you can read about the error
3605
3806
  */
3606
- icao_code: string | null;
3807
+ documentation_url: string;
3607
3808
  /**
3608
- * The ISO 3166-1 alpha-2 code for the country where the city is located
3809
+ * A more detailed human-readable description of what went wrong
3609
3810
  */
3610
- iata_country_code: string;
3811
+ message: string;
3611
3812
  /**
3612
- * The 3-letter IATA code for the place
3813
+ * A quick and simple description of what went wrong
3613
3814
  */
3614
- iata_code: string;
3815
+ title: string;
3615
3816
  /**
3616
- * The 3-letter IATA code for the city where the place is located. Only present for airports which are registered with IATA as belonging to a metropolitan area.
3817
+ * A machine-readable identifier for the general category of error
3617
3818
  */
3618
- iata_city_code: string | null;
3819
+ type: string;
3820
+ }
3821
+ export interface DuffelResponse<T_Data> {
3619
3822
  /**
3620
- * The name of the country where the city or airport is located
3823
+ * The body of the response
3621
3824
  */
3622
- country_name: string | null;
3825
+ data: T_Data;
3623
3826
  /**
3624
- * The name of the city (or cities separated by a /) where the airport is located
3827
+ * Optional metadata for the request
3625
3828
  */
3626
- city_name: string | null;
3829
+ meta?: PaginationMeta;
3627
3830
  /**
3628
- * The metropolitan area where the airport is located. Only present for airports which are registered with IATA as belonging to a metropolitan area.
3831
+ * The headers from the http response
3629
3832
  */
3630
- city: City | null;
3833
+ headers?: Headers;
3834
+ }
3835
+ export interface SDKOptions {
3631
3836
  /**
3632
- * The airports associated to a city. This will only be provided where the type is city.
3837
+ * If `true` it will output the path and the method called
3633
3838
  */
3634
- airports: Airport[] | null;
3839
+ verbose?: boolean;
3840
+ }
3841
+ }
3842
+
3843
+ declare module '@duffel/api/types/Identity' {
3844
+ export type AcceptedCurrencies = 'AUD' | 'CAD' | 'EUR' | 'GBP' | 'USD';
3845
+ export type LegalEntityType = 'corporation' | 'non_profit' | 'other' | 'partnership' | 'sole_proprietorship';
3846
+ export type PersonalAccessTokenRole = 'roles/user/personal';
3847
+ export type SourceOfFunds = 'capital_invested' | 'debt' | 'other' | 'revenue';
3848
+ export type TokenRole = 'roles/api/read_write' | 'roles/api/read_only';
3849
+ export type UserRole = 'roles/duffel/travel_ops' | 'roles/user/admin' | 'roles/user/agent' | 'roles/user/developer' | 'roles/user/owner' | 'roles/user/viewer' | PersonalAccessTokenRole;
3850
+ export type VerificationFlow = 'duffel_2020' | 'stripe_connect';
3851
+ export interface AccessToken {
3852
+ created_at: string;
3853
+ expires_at: string;
3854
+ id: string;
3855
+ last_used_at: string | null;
3856
+ last_version_used: string | null;
3857
+ live_mode: boolean | null;
3858
+ name: string | null;
3859
+ scope: TokenRole | UserRole;
3860
+ token: string;
3861
+ }
3862
+ export interface Invitation {
3863
+ accepted_at: string | null;
3864
+ created_at: string;
3865
+ expires_at: string | null;
3866
+ id: string;
3867
+ organisation: Organisation;
3868
+ organisation_id: string;
3869
+ recipient: User | null;
3870
+ recipient_email: string;
3871
+ recipient_id: string | null;
3872
+ revoked_at: string | null;
3873
+ scope: UserRole;
3874
+ sender: User;
3875
+ sender_id: string;
3876
+ sent_at: string;
3877
+ token: string;
3878
+ }
3879
+ export interface Organisation {
3880
+ access_tokens: AccessToken[] | null;
3881
+ avatar_url: string | null;
3882
+ created_at: string;
3883
+ id: string;
3884
+ name: string;
3885
+ settlement_currency: AcceptedCurrencies;
3886
+ slug: string;
3887
+ verified: boolean | null;
3888
+ legal_entity: LegalEntity | null;
3889
+ stripe_customer_id: string | null;
3890
+ stripe_payment_method_id: string | null;
3891
+ verification_flow: VerificationFlow;
3892
+ contact_emails: string[] | null;
3893
+ schedule_change_emails: string[] | null;
3894
+ is_duffel_links_enabled: boolean;
3895
+ stays_access_status: 'disabled' | 'live' | 'test';
3896
+ password_expiry_timeout_days: number | null;
3897
+ session_expiry_timeout: number;
3898
+ }
3899
+ export interface OrganisationMembership {
3900
+ avatar_url: string | null;
3901
+ id: string;
3902
+ created_at: string;
3903
+ disabled_at: string | null;
3904
+ organisation_id: string;
3905
+ owner: boolean | null;
3906
+ scope: UserRole;
3907
+ user_id: string;
3908
+ user: User;
3909
+ }
3910
+ export interface User {
3911
+ avatar_url: string | null;
3912
+ created_at: string;
3913
+ duffel_admin: boolean | null;
3914
+ email: string;
3915
+ email_confirmed_at: string | null;
3916
+ full_name: string;
3917
+ id: string;
3918
+ organisation_invitations: Invitation[] | null;
3919
+ organisation_memberships: UserOrganisationMembership[] | null;
3920
+ unconfirmed_email: string | null;
3921
+ temporary_personal_access_tokens: PersonalAccessToken[] | null;
3922
+ send_marketing_emails: boolean;
3923
+ }
3924
+ export interface PersonalAccessToken {
3925
+ created_at: string;
3926
+ expires_at: string;
3927
+ id: string;
3928
+ last_used_at: null | string;
3929
+ last_version_used: null | string;
3930
+ live_mode: true;
3931
+ name: null;
3932
+ scope: PersonalAccessTokenRole;
3933
+ token: string;
3934
+ }
3935
+ export interface UserOrganisationMembership extends OrganisationMembership {
3936
+ organisation: Organisation;
3937
+ }
3938
+ export interface LegalEntity {
3939
+ name: string;
3940
+ type: LegalEntityType;
3941
+ type_extra: string | null;
3942
+ trading_name: string | null;
3943
+ registered_business_address_line1: string;
3944
+ registered_business_address_line2: string | null;
3945
+ registered_business_address_city: string;
3946
+ registered_business_address_region: string | null;
3947
+ registered_business_address_postal_code: string;
3948
+ registered_business_address_country_code: string;
3949
+ registration_number: string;
3950
+ registration_country_code: string;
3951
+ tax_identification_number: string;
3952
+ key_contact_first_name: string;
3953
+ key_contact_last_name: string;
3954
+ key_contact_job_title: string;
3955
+ key_contact_email: string;
3956
+ initial_top_up_source_of_funds: SourceOfFunds;
3957
+ initial_top_up_source_of_funds_description: string | null;
3635
3958
  }
3636
3959
  }
3637
3960
 
@@ -3795,201 +4118,6 @@ declare module '@duffel/api/types/shared' {
3795
4118
  export type PaymentType = 'arc_bsp_cash' | 'balance';
3796
4119
  }
3797
4120
 
3798
- declare module '@duffel/api/types/ClientType' {
3799
- import { Headers } from 'node-fetch';
3800
- /**
3801
- * Our list APIs will only return a limited number of results at a time.
3802
- * By default, we'll return 50 results per page, but you can set this to any number between 1 and 200.
3803
- * @link https://duffel.com/docs/api/overview/pagination
3804
- */
3805
- export interface PaginationMeta {
3806
- /**
3807
- * The number of results to be returned in a page, between 1 and 200 (optional, default is 50)
3808
- */
3809
- limit?: number;
3810
- /**
3811
- * "Before" cursor for pagination
3812
- */
3813
- before?: string;
3814
- /**
3815
- * "After" cursor for pagination
3816
- */
3817
- after?: string | null;
3818
- }
3819
- export interface ApiResponseMeta {
3820
- /**
3821
- * The identifier of the request
3822
- */
3823
- request_id: string;
3824
- /**
3825
- * The [HTTP status](https://httpstatuses.com/) of the request
3826
- */
3827
- status: number;
3828
- }
3829
- /**
3830
- * Duffel uses standard [HTTP response codes](https://httpstatuses.com/) to indicate the success or failure of API requests.
3831
- * @link https://duffel.com/docs/api/overview/errors
3832
- */
3833
- export interface ApiResponseError {
3834
- /**
3835
- * A machine-readable identifier for this specific error
3836
- */
3837
- code: string;
3838
- /**
3839
- * A URL pointing to a place in our documentation where you can read about the error
3840
- */
3841
- documentation_url: string;
3842
- /**
3843
- * A more detailed human-readable description of what went wrong
3844
- */
3845
- message: string;
3846
- /**
3847
- * A quick and simple description of what went wrong
3848
- */
3849
- title: string;
3850
- /**
3851
- * A machine-readable identifier for the general category of error
3852
- */
3853
- type: string;
3854
- }
3855
- export interface DuffelResponse<T_Data> {
3856
- /**
3857
- * The body of the response
3858
- */
3859
- data: T_Data;
3860
- /**
3861
- * Optional metadata for the request
3862
- */
3863
- meta?: PaginationMeta;
3864
- /**
3865
- * The headers from the http response
3866
- */
3867
- headers?: Headers;
3868
- }
3869
- export interface SDKOptions {
3870
- /**
3871
- * If `true` it will output the path and the method called
3872
- */
3873
- verbose?: boolean;
3874
- }
3875
- }
3876
-
3877
- declare module '@duffel/api/notifications/Webhooks/WebhooksType' {
3878
- import { PaginationMeta } from '@duffel/api/types';
3879
- export interface Webhooks {
3880
- /**
3881
- * Whether the webhook receiver is actively being notified or not
3882
- */
3883
- active: boolean;
3884
- /**
3885
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
3886
- */
3887
- created_at: string;
3888
- /**
3889
- * The events that this webhook will be subscribed to
3890
- */
3891
- events: string[];
3892
- /**
3893
- * Duffel's unique identifier for the webhook receiver
3894
- */
3895
- id: string;
3896
- /**
3897
- * The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
3898
- */
3899
- live_mode: boolean;
3900
- /**
3901
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the order change was updated
3902
- */
3903
- updated_at: string;
3904
- /**
3905
- * The URL where your webhook will be received
3906
- */
3907
- url: string;
3908
- }
3909
- export interface WebhooksListDeliveriesParams extends PaginationMeta {
3910
- delivery_success: boolean;
3911
- /**
3912
- * Filters the returned webhook deliveries by creation datetime.
3913
- */
3914
- created_at?: PaginationMeta;
3915
- /**
3916
- * Filters webhook deliveries by the type of their related webhook event.
3917
- */
3918
- type?: string;
3919
- /**
3920
- * Filters webhook deliveries by the ID of the related webhook endpoint.
3921
- */
3922
- endpoint_id: string;
3923
- }
3924
- export interface WebhooksUpdateParams {
3925
- /**
3926
- * The desired active status of the webhook
3927
- */
3928
- active: boolean;
3929
- /**
3930
- * The desired events that the webhook should subscribe to
3931
- */
3932
- events: string[];
3933
- /**
3934
- * The desired url of the webhook
3935
- */
3936
- url: string;
3937
- }
3938
- export interface WebhooksCreateParams {
3939
- /**
3940
- * The desired events that the webhook should subscribe to
3941
- */
3942
- events: string[];
3943
- /**
3944
- * The desired url of the webhook
3945
- */
3946
- url: string;
3947
- }
3948
- export interface WebhooksListDeliveriesResponse {
3949
- /**
3950
- * The URL where your webhook will be received
3951
- */
3952
- url: string;
3953
- endpoint_id: string;
3954
- /**
3955
- * Webhook deliveries will be included if they were successful.
3956
- */
3957
- delivery_success?: boolean;
3958
- type: string;
3959
- response_status_code: 200;
3960
- response_body: string;
3961
- event_id: string;
3962
- /**
3963
- * The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
3964
- */
3965
- live_mode: boolean;
3966
- /**
3967
- * Duffel's unique identifier for the webhook receiver
3968
- */
3969
- id: string;
3970
- /**
3971
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
3972
- */
3973
- created_at: string;
3974
- }
3975
- export interface WebhooksListResponse extends Webhooks {
3976
- /**
3977
- * Webhook deliveries will be included if they were successful.
3978
- */
3979
- delivery_success?: boolean;
3980
- }
3981
- export interface WebhooksCreateResponse {
3982
- secret: string;
3983
- url: string;
3984
- updated_at: string;
3985
- live_mode: boolean;
3986
- id: string;
3987
- events: string[];
3988
- created_at: string;
3989
- active: boolean;
3990
- }
3991
- }
3992
-
3993
4121
  declare module '@duffel/api/supportingResources/Aircraft/Aircraft' {
3994
4122
  import { Resource } from '@duffel/api/Resource';
3995
4123
  import { Aircraft as AircraftType, DuffelResponse, PaginationMeta } from '@duffel/api/types';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duffel/api",
3
- "version": "2.6.8",
3
+ "version": "2.7.1",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",