@duffel/api 2.6.8 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.6.8"};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.6.8"};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' {
@@ -1387,6 +1388,183 @@ declare module '@duffel/api/booking/SeatMaps/SeatMaps' {
1387
1388
  }
1388
1389
  }
1389
1390
 
1391
+ declare module '@duffel/api/DuffelPayments/PaymentIntents/PaymentIntentsType' {
1392
+ export interface PaymentIntent {
1393
+ /**
1394
+ * The amount of the Payment Intent that covers the cost of the flight being sold and any additional markup.
1395
+ * The card payment will be charged this amount.
1396
+ */
1397
+ amount: string;
1398
+ /**
1399
+ * 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.
1400
+ * It will be null until the Payment Intent is confirmed.
1401
+ */
1402
+ card_country_code: string | null;
1403
+ /**
1404
+ * The last four digits of the card used to confirm the Payment Intent.
1405
+ * It will be null until the Payment Intent is confirmed.
1406
+ */
1407
+ card_last_four_digits: string | null;
1408
+ /**
1409
+ * The card network in which the Payment Intent was processed on.
1410
+ * It will be null until the Payment Intent is confirmed.
1411
+ */
1412
+ card_network: 'amex' | 'cartes_bancaires' | 'diners' | 'discover' | 'interac' | 'jcb' | 'mastercard' | 'unionpay' | 'visa' | 'unknown' | null;
1413
+ /**
1414
+ * This value is used when displaying the payment collection form to securely identify and transmit the values to Duffel.
1415
+ */
1416
+ client_token: string;
1417
+ /**
1418
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was confirmed
1419
+ */
1420
+ confirmed_at: string;
1421
+ /**
1422
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was created
1423
+ */
1424
+ created_at: string;
1425
+ /**
1426
+ * The currency of the `amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1427
+ * The card payment will be charged in this currency.
1428
+ * If it's different to your Balance currency, it will be converted to your Balance currency before the Balance is topped up.
1429
+ */
1430
+ currency: string;
1431
+ /**
1432
+ * The amount of the fees to process the Payment Intent.
1433
+ * It will be `null` until the Payment Intent is confirmed.
1434
+ */
1435
+ fees_amount: string | null;
1436
+ /**
1437
+ * The currency of the fees_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1438
+ * This currency will match your Balance currency.
1439
+ * It will be null until the Payment Intent is confirmed.
1440
+ */
1441
+ fees_currency: string | null;
1442
+ /**
1443
+ * Duffel's unique identifier for the `Payment Intent`
1444
+ */
1445
+ id: string;
1446
+ /**
1447
+ * 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.
1448
+ */
1449
+ live_mode: boolean;
1450
+ /**
1451
+ * The amount of the Payment Intent that was added to the Balance.
1452
+ * It'll be `amount` (in the Balance currency) less the `fees_amount`.
1453
+ * It will be `null` until the Payment Intent is confirmed.
1454
+ */
1455
+ net_amount: string | null;
1456
+ /**
1457
+ * The currency of the net_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1458
+ * This currency will match your Balance currency.
1459
+ * It will be null until the Payment Intent is confirmed.
1460
+ */
1461
+ net_currency: string | null;
1462
+ /**
1463
+ * The Refunds for this Payment Intent
1464
+ * @link https://duffel.com/docs/api/payment-intents/schema#payment-intents-schema-refunds
1465
+ */
1466
+ refunds: {
1467
+ amount: string;
1468
+ arrival: string;
1469
+ created_at: string;
1470
+ currency: string;
1471
+ destination: string;
1472
+ id: string;
1473
+ live_mode: boolean;
1474
+ net_amount: string;
1475
+ net_currency: string;
1476
+ payment_intent_id: string;
1477
+ status: 'succeeded' | 'pending' | 'failed';
1478
+ updated_at: string;
1479
+ }[];
1480
+ /**
1481
+ * The status of this Payment Intent
1482
+ */
1483
+ status: null | 'requires_payment_method' | 'requires_confirmation' | 'requires_action' | 'processing' | 'requires_capture' | 'cancelled' | 'succeeded';
1484
+ /**
1485
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was updated
1486
+ */
1487
+ updated_at: string;
1488
+ }
1489
+ export interface CreatePaymentIntent {
1490
+ /**
1491
+ * This is the amount that the card payment being taken will be charged.
1492
+ * It should be enough to cover the service(s) you want to sell (enough to book an Offer for example) and the processing fees.
1493
+ * If the currency is different from your Balance currency you should also account for foreign exchange.
1494
+ * It can be higher than that, in which case the remainder will be considered your markup.
1495
+ * 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.
1496
+ */
1497
+ amount: string;
1498
+ /**
1499
+ * The currency of the amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1500
+ * This is going to be the currency that the card payment being taken in will be charged in.
1501
+ */
1502
+ currency: string;
1503
+ }
1504
+ }
1505
+
1506
+ declare module '@duffel/api/Places/Suggestions/SuggestionsType' {
1507
+ import { Airport, City } from '@duffel/api/types';
1508
+ export interface Places {
1509
+ /**
1510
+ * The type of the place
1511
+ */
1512
+ type: string;
1513
+ /**
1514
+ * The time zone of the airport, specified by name from the tz database
1515
+ */
1516
+ time_zone: string | null;
1517
+ /**
1518
+ * The name of the place
1519
+ */
1520
+ name: string;
1521
+ /**
1522
+ * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
1523
+ */
1524
+ longitude: number | null;
1525
+ /**
1526
+ * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
1527
+ */
1528
+ latitude: number | null;
1529
+ /**
1530
+ * Duffel's unique identifier for the place
1531
+ */
1532
+ id: string;
1533
+ /**
1534
+ * The four-character ICAO code for the airport
1535
+ */
1536
+ icao_code: string | null;
1537
+ /**
1538
+ * The ISO 3166-1 alpha-2 code for the country where the city is located
1539
+ */
1540
+ iata_country_code: string;
1541
+ /**
1542
+ * The 3-letter IATA code for the place
1543
+ */
1544
+ iata_code: string;
1545
+ /**
1546
+ * 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.
1547
+ */
1548
+ iata_city_code: string | null;
1549
+ /**
1550
+ * The name of the country where the city or airport is located
1551
+ */
1552
+ country_name: string | null;
1553
+ /**
1554
+ * The name of the city (or cities separated by a /) where the airport is located
1555
+ */
1556
+ city_name: string | null;
1557
+ /**
1558
+ * The metropolitan area where the airport is located. Only present for airports which are registered with IATA as belonging to a metropolitan area.
1559
+ */
1560
+ city: City | null;
1561
+ /**
1562
+ * The airports associated to a city. This will only be provided where the type is city.
1563
+ */
1564
+ airports: Airport[] | null;
1565
+ }
1566
+ }
1567
+
1390
1568
  declare module '@duffel/api/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes' {
1391
1569
  import { OrderSlice } from '@duffel/api/types';
1392
1570
  export type AirlineInitiatedChangeActionTaken = 'accepted' | 'cancelled' | 'changed';
@@ -1500,7 +1678,7 @@ declare module '@duffel/api/booking/OfferRequests/OfferRequestsTypes' {
1500
1678
  */
1501
1679
  loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
1502
1680
  }
1503
- interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
1681
+ export interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
1504
1682
  age?: never;
1505
1683
  fare_type?: never;
1506
1684
  /**
@@ -1511,7 +1689,7 @@ declare module '@duffel/api/booking/OfferRequests/OfferRequestsTypes' {
1511
1689
  */
1512
1690
  type: Extract<DuffelPassengerType, 'adult'>;
1513
1691
  }
1514
- interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
1692
+ export interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
1515
1693
  /**
1516
1694
  * The age of the passenger on the `departure_date` of the final slice. e.g.
1517
1695
  * if you a searching for a round trip and the passenger is 15 years old at
@@ -3359,279 +3537,415 @@ declare module '@duffel/api/booking/SeatMaps/SeatMapTypes' {
3359
3537
  export type SeatMapCabinRowSectionElementAmenity = Exclude<SeatMapCabinRowSectionElementType, 'empty' | 'seat'>;
3360
3538
  }
3361
3539
 
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 {
3540
+ declare module '@duffel/api/notifications/Webhooks/WebhooksType' {
3541
+ import { PaginationMeta } from '@duffel/api/types';
3542
+ export interface Webhooks {
3368
3543
  /**
3369
- * The name of the aircraft
3544
+ * Whether the webhook receiver is actively being notified or not
3370
3545
  */
3371
- name: string;
3546
+ active: boolean;
3372
3547
  /**
3373
- * Duffel's unique identifier for the aircraft
3548
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
3549
+ */
3550
+ created_at: string;
3551
+ /**
3552
+ * The events that this webhook will be subscribed to
3553
+ */
3554
+ events: string[];
3555
+ /**
3556
+ * Duffel's unique identifier for the webhook receiver
3374
3557
  */
3375
3558
  id: string;
3376
3559
  /**
3377
- * The three-character IATA code for the aircraft
3560
+ * 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.
3378
3561
  */
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 {
3562
+ live_mode: boolean;
3389
3563
  /**
3390
- * The three-character IATA code for the airline
3564
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the order change was updated
3391
3565
  */
3392
- name: string;
3566
+ updated_at: string;
3393
3567
  /**
3394
- * Duffel's unique identifier for the airline
3568
+ * The URL where your webhook will be received
3395
3569
  */
3396
- id: string;
3397
- iata_code: string;
3398
- logo_lockup_url?: string;
3399
- logo_symbol_url?: string;
3570
+ url: string;
3400
3571
  }
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 {
3572
+ export interface WebhooksListDeliveriesParams extends PaginationMeta {
3573
+ delivery_success: boolean;
3410
3574
  /**
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.
3575
+ * Filters the returned webhook deliveries by creation datetime.
3413
3576
  */
3414
- city?: City | null;
3577
+ created_at?: PaginationMeta;
3415
3578
  /**
3416
- * The name of the city (or cities separated by a `/`) where the airport is located
3579
+ * Filters webhook deliveries by the type of their related webhook event.
3417
3580
  */
3418
- city_name: string;
3581
+ type?: string;
3419
3582
  /**
3420
- * The three-character IATA code for the airport
3583
+ * Filters webhook deliveries by the ID of the related webhook endpoint.
3421
3584
  */
3422
- iata_code?: string;
3585
+ endpoint_id: string;
3586
+ }
3587
+ export interface WebhooksUpdateParams {
3423
3588
  /**
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"
3589
+ * The desired active status of the webhook
3427
3590
  */
3428
- iata_country_code: string;
3591
+ active: boolean;
3429
3592
  /**
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).
3593
+ * The desired events that the webhook should subscribe to
3432
3594
  */
3433
- iata_city_code?: string | null;
3595
+ events: string[];
3434
3596
  /**
3435
- * The four-character ICAO code for the airport
3597
+ * The desired url of the webhook
3436
3598
  */
3437
- icao_code?: string;
3599
+ url: string;
3600
+ }
3601
+ export interface WebhooksCreateParams {
3438
3602
  /**
3439
- * Duffel's unique identifier for the airport
3603
+ * The desired events that the webhook should subscribe to
3440
3604
  */
3441
- id: string;
3605
+ events: string[];
3442
3606
  /**
3443
- * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
3607
+ * The desired url of the webhook
3444
3608
  */
3445
- latitude: number;
3609
+ url: string;
3610
+ }
3611
+ export interface WebhooksListDeliveriesResponse {
3446
3612
  /**
3447
- * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
3613
+ * The URL where your webhook will be received
3448
3614
  */
3449
- longitude: number;
3615
+ url: string;
3616
+ endpoint_id: string;
3450
3617
  /**
3451
- * The name of the airport
3618
+ * Webhook deliveries will be included if they were successful.
3452
3619
  */
3453
- name: string;
3620
+ delivery_success?: boolean;
3621
+ type: string;
3622
+ response_status_code: 200;
3623
+ response_body: string;
3624
+ event_id: string;
3454
3625
  /**
3455
- * The time zone of the airport, specified by name from the [tz database](https://en.wikipedia.org/wiki/Tz_database)
3626
+ * 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.
3456
3627
  */
3457
- time_zone: string;
3458
- }
3459
- }
3460
-
3461
- declare module '@duffel/api/DuffelPayments/PaymentIntents/PaymentIntentsType' {
3462
- export interface PaymentIntent {
3628
+ live_mode: boolean;
3463
3629
  /**
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.
3630
+ * Duffel's unique identifier for the webhook receiver
3466
3631
  */
3467
- amount: string;
3632
+ id: string;
3468
3633
  /**
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.
3634
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
3471
3635
  */
3472
- card_country_code: string | null;
3636
+ created_at: string;
3637
+ }
3638
+ export interface WebhooksListResponse extends Webhooks {
3473
3639
  /**
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.
3640
+ * Webhook deliveries will be included if they were successful.
3476
3641
  */
3477
- card_last_four_digits: string | null;
3642
+ delivery_success?: boolean;
3643
+ }
3644
+ export interface WebhooksCreateResponse {
3645
+ secret: string;
3646
+ url: string;
3647
+ updated_at: string;
3648
+ live_mode: boolean;
3649
+ id: string;
3650
+ events: string[];
3651
+ created_at: string;
3652
+ active: boolean;
3653
+ }
3654
+ }
3655
+
3656
+ declare module '@duffel/api/supportingResources/Aircraft/AircraftTypes' {
3657
+ /**
3658
+ * Aircraft are used to describe what passengers will fly in for a given trip
3659
+ * @link https://duffel.com/docs/api/aircraft/schema
3660
+ */
3661
+ export interface Aircraft {
3478
3662
  /**
3479
- * The card network in which the Payment Intent was processed on.
3480
- * It will be null until the Payment Intent is confirmed.
3663
+ * The name of the aircraft
3481
3664
  */
3482
- card_network: 'amex' | 'cartes_bancaires' | 'diners' | 'discover' | 'interac' | 'jcb' | 'mastercard' | 'unionpay' | 'visa' | 'unknown' | null;
3665
+ name: string;
3483
3666
  /**
3484
- * This value is used when displaying the payment collection form to securely identify and transmit the values to Duffel.
3667
+ * Duffel's unique identifier for the aircraft
3485
3668
  */
3486
- client_token: string;
3669
+ id: string;
3487
3670
  /**
3488
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was confirmed
3671
+ * The three-character IATA code for the aircraft
3489
3672
  */
3490
- confirmed_at: string;
3673
+ iata_code: string;
3674
+ }
3675
+ }
3676
+
3677
+ declare module '@duffel/api/supportingResources/Airlines/AirlinesTypes' {
3678
+ /**
3679
+ * Airlines are used to identify the air travel companies selling and operating flights
3680
+ * @link https://duffel.com/docs/api/airlines/schema
3681
+ */
3682
+ export interface Airline {
3491
3683
  /**
3492
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was created
3684
+ * The three-character IATA code for the airline
3493
3685
  */
3494
- created_at: string;
3686
+ name: string;
3495
3687
  /**
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.
3688
+ * Duffel's unique identifier for the airline
3499
3689
  */
3500
- currency: string;
3690
+ id: string;
3691
+ iata_code: string;
3692
+ logo_lockup_url?: string;
3693
+ logo_symbol_url?: string;
3694
+ }
3695
+ }
3696
+
3697
+ declare module '@duffel/api/supportingResources/Airports/AirportsTypes' {
3698
+ import { City } from '@duffel/api/types';
3699
+ /**
3700
+ * Airports are used to identify origins and destinations in journey slices
3701
+ * @link https://duffel.com/docs/api/airports/schema
3702
+ */
3703
+ export interface Airport {
3501
3704
  /**
3502
- * The amount of the fees to process the Payment Intent.
3503
- * It will be `null` until the Payment Intent is confirmed.
3705
+ * The metropolitan area where the airport is located.
3706
+ * Only present for airports which are registered with IATA as belonging to a metropolitan area.
3504
3707
  */
3505
- fees_amount: string | null;
3708
+ city?: City | null;
3506
3709
  /**
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.
3710
+ * The name of the city (or cities separated by a `/`) where the airport is located
3510
3711
  */
3511
- fees_currency: string | null;
3712
+ city_name: string;
3512
3713
  /**
3513
- * Duffel's unique identifier for the `Payment Intent`
3714
+ * The three-character IATA code for the airport
3514
3715
  */
3515
- id: string;
3716
+ iata_code?: string;
3516
3717
  /**
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.
3718
+ * The ISO 3166-1 alpha-2 code for the country where the city is located
3719
+ * @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
3720
+ * @example "GB"
3518
3721
  */
3519
- live_mode: boolean;
3722
+ iata_country_code: string;
3520
3723
  /**
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.
3724
+ * The 3-letter IATA code for the city where the place is located.
3725
+ * 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).
3524
3726
  */
3525
- net_amount: string | null;
3727
+ iata_city_code?: string | null;
3526
3728
  /**
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.
3729
+ * The four-character ICAO code for the airport
3530
3730
  */
3531
- net_currency: string | null;
3731
+ icao_code?: string;
3532
3732
  /**
3533
- * The Refunds for this Payment Intent
3534
- * @link https://duffel.com/docs/api/payment-intents/schema#payment-intents-schema-refunds
3733
+ * Duffel's unique identifier for the airport
3535
3734
  */
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
- }[];
3735
+ id: string;
3550
3736
  /**
3551
- * The status of this Payment Intent
3737
+ * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
3552
3738
  */
3553
- status: null | 'requires_payment_method' | 'requires_confirmation' | 'requires_action' | 'processing' | 'requires_capture' | 'cancelled' | 'succeeded';
3739
+ latitude: number;
3554
3740
  /**
3555
- * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was updated
3741
+ * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
3556
3742
  */
3557
- updated_at: string;
3558
- }
3559
- export interface CreatePaymentIntent {
3743
+ longitude: number;
3560
3744
  /**
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.
3745
+ * The name of the airport
3566
3746
  */
3567
- amount: string;
3747
+ name: string;
3568
3748
  /**
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.
3749
+ * The time zone of the airport, specified by name from the [tz database](https://en.wikipedia.org/wiki/Tz_database)
3571
3750
  */
3572
- currency: string;
3751
+ time_zone: string;
3573
3752
  }
3574
3753
  }
3575
3754
 
3576
- declare module '@duffel/api/Places/Suggestions/SuggestionsType' {
3577
- import { Airport, City } from '@duffel/api/types';
3578
- export interface Places {
3755
+ declare module '@duffel/api/types/ClientType' {
3756
+ import { Headers } from 'node-fetch';
3757
+ /**
3758
+ * Our list APIs will only return a limited number of results at a time.
3759
+ * By default, we'll return 50 results per page, but you can set this to any number between 1 and 200.
3760
+ * @link https://duffel.com/docs/api/overview/pagination
3761
+ */
3762
+ export interface PaginationMeta {
3579
3763
  /**
3580
- * The type of the place
3764
+ * The number of results to be returned in a page, between 1 and 200 (optional, default is 50)
3581
3765
  */
3582
- type: string;
3766
+ limit?: number;
3583
3767
  /**
3584
- * The time zone of the airport, specified by name from the tz database
3768
+ * "Before" cursor for pagination
3585
3769
  */
3586
- time_zone: string | null;
3770
+ before?: string;
3587
3771
  /**
3588
- * The name of the place
3772
+ * "After" cursor for pagination
3589
3773
  */
3590
- name: string;
3774
+ after?: string | null;
3775
+ }
3776
+ export interface ApiResponseMeta {
3591
3777
  /**
3592
- * The longitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -180° and 180°
3778
+ * The identifier of the request
3593
3779
  */
3594
- longitude: number | null;
3780
+ request_id: string;
3595
3781
  /**
3596
- * The latitude position of the airport represented in Decimal degrees with 6 decimal points with a range between -90° and 90°
3782
+ * The [HTTP status](https://httpstatuses.com/) of the request
3597
3783
  */
3598
- latitude: number | null;
3784
+ status: number;
3785
+ }
3786
+ /**
3787
+ * Duffel uses standard [HTTP response codes](https://httpstatuses.com/) to indicate the success or failure of API requests.
3788
+ * @link https://duffel.com/docs/api/overview/errors
3789
+ */
3790
+ export interface ApiResponseError {
3599
3791
  /**
3600
- * Duffel's unique identifier for the place
3792
+ * A machine-readable identifier for this specific error
3601
3793
  */
3602
- id: string;
3794
+ code: string;
3603
3795
  /**
3604
- * The four-character ICAO code for the airport
3796
+ * A URL pointing to a place in our documentation where you can read about the error
3605
3797
  */
3606
- icao_code: string | null;
3798
+ documentation_url: string;
3607
3799
  /**
3608
- * The ISO 3166-1 alpha-2 code for the country where the city is located
3800
+ * A more detailed human-readable description of what went wrong
3609
3801
  */
3610
- iata_country_code: string;
3802
+ message: string;
3611
3803
  /**
3612
- * The 3-letter IATA code for the place
3804
+ * A quick and simple description of what went wrong
3613
3805
  */
3614
- iata_code: string;
3806
+ title: string;
3615
3807
  /**
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.
3808
+ * A machine-readable identifier for the general category of error
3617
3809
  */
3618
- iata_city_code: string | null;
3810
+ type: string;
3811
+ }
3812
+ export interface DuffelResponse<T_Data> {
3619
3813
  /**
3620
- * The name of the country where the city or airport is located
3814
+ * The body of the response
3621
3815
  */
3622
- country_name: string | null;
3816
+ data: T_Data;
3623
3817
  /**
3624
- * The name of the city (or cities separated by a /) where the airport is located
3818
+ * Optional metadata for the request
3625
3819
  */
3626
- city_name: string | null;
3820
+ meta?: PaginationMeta;
3627
3821
  /**
3628
- * The metropolitan area where the airport is located. Only present for airports which are registered with IATA as belonging to a metropolitan area.
3822
+ * The headers from the http response
3629
3823
  */
3630
- city: City | null;
3824
+ headers?: Headers;
3825
+ }
3826
+ export interface SDKOptions {
3631
3827
  /**
3632
- * The airports associated to a city. This will only be provided where the type is city.
3828
+ * If `true` it will output the path and the method called
3633
3829
  */
3634
- airports: Airport[] | null;
3830
+ verbose?: boolean;
3831
+ }
3832
+ }
3833
+
3834
+ declare module '@duffel/api/types/Identity' {
3835
+ export type AcceptedCurrencies = 'AUD' | 'CAD' | 'EUR' | 'GBP' | 'USD';
3836
+ export type LegalEntityType = 'corporation' | 'non_profit' | 'other' | 'partnership' | 'sole_proprietorship';
3837
+ export type PersonalAccessTokenRole = 'roles/user/personal';
3838
+ export type SourceOfFunds = 'capital_invested' | 'debt' | 'other' | 'revenue';
3839
+ export type TokenRole = 'roles/api/read_write' | 'roles/api/read_only';
3840
+ export type UserRole = 'roles/duffel/travel_ops' | 'roles/user/admin' | 'roles/user/agent' | 'roles/user/developer' | 'roles/user/owner' | 'roles/user/viewer' | PersonalAccessTokenRole;
3841
+ export type VerificationFlow = 'duffel_2020' | 'stripe_connect';
3842
+ export interface AccessToken {
3843
+ created_at: string;
3844
+ expires_at: string;
3845
+ id: string;
3846
+ last_used_at: string | null;
3847
+ last_version_used: string | null;
3848
+ live_mode: boolean | null;
3849
+ name: string | null;
3850
+ scope: TokenRole | UserRole;
3851
+ token: string;
3852
+ }
3853
+ export interface Invitation {
3854
+ accepted_at: string | null;
3855
+ created_at: string;
3856
+ expires_at: string | null;
3857
+ id: string;
3858
+ organisation: Organisation;
3859
+ organisation_id: string;
3860
+ recipient: User | null;
3861
+ recipient_email: string;
3862
+ recipient_id: string | null;
3863
+ revoked_at: string | null;
3864
+ scope: UserRole;
3865
+ sender: User;
3866
+ sender_id: string;
3867
+ sent_at: string;
3868
+ token: string;
3869
+ }
3870
+ export interface Organisation {
3871
+ access_tokens: AccessToken[] | null;
3872
+ avatar_url: string | null;
3873
+ created_at: string;
3874
+ id: string;
3875
+ name: string;
3876
+ settlement_currency: AcceptedCurrencies;
3877
+ slug: string;
3878
+ verified: boolean | null;
3879
+ legal_entity: LegalEntity | null;
3880
+ stripe_customer_id: string | null;
3881
+ stripe_payment_method_id: string | null;
3882
+ verification_flow: VerificationFlow;
3883
+ contact_emails: string[] | null;
3884
+ schedule_change_emails: string[] | null;
3885
+ is_duffel_links_enabled: boolean;
3886
+ stays_access_status: 'disabled' | 'live' | 'test';
3887
+ password_expiry_timeout_days: number | null;
3888
+ session_expiry_timeout: number;
3889
+ }
3890
+ export interface OrganisationMembership {
3891
+ avatar_url: string | null;
3892
+ id: string;
3893
+ created_at: string;
3894
+ disabled_at: string | null;
3895
+ organisation_id: string;
3896
+ owner: boolean | null;
3897
+ scope: UserRole;
3898
+ user_id: string;
3899
+ user: User;
3900
+ }
3901
+ export interface User {
3902
+ avatar_url: string | null;
3903
+ created_at: string;
3904
+ duffel_admin: boolean | null;
3905
+ email: string;
3906
+ email_confirmed_at: string | null;
3907
+ full_name: string;
3908
+ id: string;
3909
+ organisation_invitations: Invitation[] | null;
3910
+ organisation_memberships: UserOrganisationMembership[] | null;
3911
+ unconfirmed_email: string | null;
3912
+ temporary_personal_access_tokens: PersonalAccessToken[] | null;
3913
+ send_marketing_emails: boolean;
3914
+ }
3915
+ export interface PersonalAccessToken {
3916
+ created_at: string;
3917
+ expires_at: string;
3918
+ id: string;
3919
+ last_used_at: null | string;
3920
+ last_version_used: null | string;
3921
+ live_mode: true;
3922
+ name: null;
3923
+ scope: PersonalAccessTokenRole;
3924
+ token: string;
3925
+ }
3926
+ export interface UserOrganisationMembership extends OrganisationMembership {
3927
+ organisation: Organisation;
3928
+ }
3929
+ export interface LegalEntity {
3930
+ name: string;
3931
+ type: LegalEntityType;
3932
+ type_extra: string | null;
3933
+ trading_name: string | null;
3934
+ registered_business_address_line1: string;
3935
+ registered_business_address_line2: string | null;
3936
+ registered_business_address_city: string;
3937
+ registered_business_address_region: string | null;
3938
+ registered_business_address_postal_code: string;
3939
+ registered_business_address_country_code: string;
3940
+ registration_number: string;
3941
+ registration_country_code: string;
3942
+ tax_identification_number: string;
3943
+ key_contact_first_name: string;
3944
+ key_contact_last_name: string;
3945
+ key_contact_job_title: string;
3946
+ key_contact_email: string;
3947
+ initial_top_up_source_of_funds: SourceOfFunds;
3948
+ initial_top_up_source_of_funds_description: string | null;
3635
3949
  }
3636
3950
  }
3637
3951
 
@@ -3795,201 +4109,6 @@ declare module '@duffel/api/types/shared' {
3795
4109
  export type PaymentType = 'arc_bsp_cash' | 'balance';
3796
4110
  }
3797
4111
 
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
4112
  declare module '@duffel/api/supportingResources/Aircraft/Aircraft' {
3994
4113
  import { Resource } from '@duffel/api/Resource';
3995
4114
  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.0",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",