@duffel/api 4.21.0 → 4.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ import { Headers } from 'node-fetch';
2
+ import { DuffelResponse, SDKOptions, ApiResponseMeta, ApiResponseError } from './types';
3
+ export interface Config {
4
+ token: string;
5
+ basePath?: string;
6
+ apiVersion?: string;
7
+ debug?: SDKOptions;
8
+ source?: string;
9
+ }
10
+ export declare class DuffelError extends Error {
11
+ meta: ApiResponseMeta;
12
+ errors: ApiResponseError[];
13
+ headers: Headers;
14
+ constructor({ meta, errors, headers, }: {
15
+ meta: ApiResponseMeta;
16
+ errors: ApiResponseError[];
17
+ headers: Headers;
18
+ });
19
+ }
20
+ export declare class Client {
21
+ private token;
22
+ private basePath;
23
+ private apiVersion;
24
+ private debug;
25
+ private source;
26
+ constructor({ token, basePath, apiVersion, debug, source }: Config);
27
+ request: <T_Data = any>({ method, path, data, params, compress, }: {
28
+ method: string;
29
+ path: string;
30
+ data?: Record<string, any>;
31
+ params?: Record<string, any>;
32
+ compress?: boolean;
33
+ }) => Promise<DuffelResponse<T_Data>>;
34
+ paginatedRequest<T_Data = any>({ path, params, }: {
35
+ path: string;
36
+ params?: Record<string, any>;
37
+ }): AsyncGenerator<DuffelResponse<T_Data>, void, unknown>;
38
+ }
@@ -0,0 +1,16 @@
1
+ import { Client } from './Client';
2
+ import { DuffelResponse } from './types';
3
+ export declare class Resource {
4
+ private client;
5
+ constructor(client: Client);
6
+ protected request: <T_Data = any>({ method, path, data, params, }: {
7
+ method: string;
8
+ path: string;
9
+ data?: Record<string, any>;
10
+ params?: Record<string, any>;
11
+ }) => Promise<DuffelResponse<T_Data>>;
12
+ protected paginatedRequest: <T_Data = any>({ path, params, }: {
13
+ path: string;
14
+ params?: Record<string, any>;
15
+ }) => AsyncGenerator<DuffelResponse<T_Data>, void, unknown>;
16
+ }
@@ -144,6 +144,10 @@ export interface StaysRate {
144
144
  * Useful in scenarios where a rate requires explicitly showing the source.
145
145
  */
146
146
  source: StaysSource;
147
+ /**
148
+ * The ISO 8601 date and time at which the rate will expire
149
+ */
150
+ expires_at: string;
147
151
  }
148
152
  export interface StaysRoomRate extends StaysRate {
149
153
  /**
@@ -570,6 +574,10 @@ export interface StaysSearchResult {
570
574
  cheapest_rate_public_currency: string;
571
575
  cheapest_rate_due_at_accommodation_amount: string | null;
572
576
  cheapest_rate_due_at_accommodation_currency: string | null;
577
+ /**
578
+ * The ISO 8601 date and time at which the search result will expire
579
+ */
580
+ expires_at: string;
573
581
  }
574
582
  export interface StaysLoyaltyProgramme {
575
583
  reference: StaysLoyaltyProgrammeReference;
@@ -0,0 +1,62 @@
1
+ import { PaymentIntents } from './DuffelPayments';
2
+ import { BatchOfferRequests, OfferRequests, Offers, OrderCancellations, Orders, OrderChangeRequests, OrderChangeOffers, OrderChanges, Payments, PartialOfferRequests, SeatMaps, AirlineInitiatedChanges } from './booking';
3
+ import { Config, DuffelError as _DuffelError } from './Client';
4
+ import { Aircraft, Airlines, Airports } from './supportingResources';
5
+ import { Suggestions } from './Places/Suggestions';
6
+ import { Refunds } from './DuffelPayments/Refunds';
7
+ import { Sessions } from './Links';
8
+ import { Webhooks } from './notifications';
9
+ import { Stays } from './Stays/Stays';
10
+ import { Cards } from './Payments/Cards';
11
+ import { ThreeDSecureSessions } from './Payments/ThreeDSecureSessions';
12
+ import { Identity } from './Identity/Identity';
13
+ import { hasService as hasServiceImport } from './functions/hasService';
14
+ import { hasAvailableSeatService as hasAvailableSeatServiceImport } from './functions/hasAvailableSeatService';
15
+ export interface DuffelAPIClient {
16
+ aircraft: Aircraft;
17
+ airlines: Airlines;
18
+ airports: Airports;
19
+ batchOfferRequests: BatchOfferRequests;
20
+ offers: Offers;
21
+ offerRequests: OfferRequests;
22
+ orders: Orders;
23
+ orderChangeRequests: OrderChangeRequests;
24
+ orderChangeOffers: OrderChangeOffers;
25
+ orderChanges: OrderChanges;
26
+ orderCancellations: OrderCancellations;
27
+ payments: Payments;
28
+ seatMaps: SeatMaps;
29
+ threeDSecureSessions: ThreeDSecureSessions;
30
+ }
31
+ export declare class Duffel {
32
+ private client;
33
+ aircraft: Aircraft;
34
+ airlineInitiatedChanges: AirlineInitiatedChanges;
35
+ airlines: Airlines;
36
+ airports: Airports;
37
+ links: Sessions;
38
+ batchOfferRequests: BatchOfferRequests;
39
+ offerRequests: OfferRequests;
40
+ offers: Offers;
41
+ orders: Orders;
42
+ orderChangeRequests: OrderChangeRequests;
43
+ orderChangeOffers: OrderChangeOffers;
44
+ orderChanges: OrderChanges;
45
+ orderCancellations: OrderCancellations;
46
+ payments: Payments;
47
+ seatMaps: SeatMaps;
48
+ paymentIntents: PaymentIntents;
49
+ partialOfferRequests: PartialOfferRequests;
50
+ suggestions: Suggestions;
51
+ refunds: Refunds;
52
+ webhooks: Webhooks;
53
+ stays: Stays;
54
+ three_d_secure_sessions: ThreeDSecureSessions;
55
+ identity: Identity;
56
+ private cardsClient;
57
+ cards: Cards;
58
+ constructor(config: Config);
59
+ }
60
+ export declare const DuffelError: typeof _DuffelError;
61
+ export declare const hasService: typeof hasServiceImport;
62
+ export declare const hasAvailableSeatService: typeof hasAvailableSeatServiceImport;
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:"4.20.1"};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=t=>h(this,[t],void 0,(function*({method:t,path:s,data:e,params:i}){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.create=t=>h(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.path="air/batch_offer_requests"}}class d extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:s,supplier_timeout:e}=t,h=i(t,["return_offers","supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:h,params:Object.assign(Object.assign({},null!=s&&{return_offers:s}),null!=e&&{supplier_timeout:e})})})),this.path="air/offer_requests"}}class p extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.getPriced=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/price`,data:s})})),this.path="air/offers"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=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 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.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class m extends 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 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.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 g extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class $ extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>h(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class T extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let y=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=i=>h(this,[i],void 0,(function*({method:i,path:h,data:r,params:a,compress:n=!0}){var o,u;let c,d;const p=new s(h,this.basePath),l={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e;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())})),p.search=t.toString()}r&&(c=JSON.stringify({data:Object.assign({},r)})),(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&(console.info("Endpoint: ",p.href),console.info("Method: ",i),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const f=yield t(p.href,{method:i,headers:l,body:c,compress:n});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const v=f.headers.get("content-type");if(d=v&&v.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in d&&d.errors)throw new y(Object.assign(Object.assign({},d),{status:f.status,headers:f.headers}));return Object.assign(Object.assign({},d),{status:f.status,headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v2",this.debug=n,this.source=o}paginatedRequest(t){return a(this,arguments,(function*({path:t,params:s}){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t,status:e.status});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:Object.assign(Object.assign({},s),{limit:e.meta.limit,after:e.meta.after})}));for(const t of e.data)yield yield r({data:t,status:e.status})}}))}}class _ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}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/airlines"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class 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 P 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 x 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,s)=>h(this,[t,s],void 0,(function*(t,{active:s,events:e,url:i}){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=t=>h(this,[t],void 0,(function*({events:t,url:s}){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class S extends n{constructor(t){super(t),this.suggestions=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})})),this.reviews=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/reviews`,params:s})})),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.path="stays/accommodation"}}class j 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=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/brands"}}class R extends n{constructor(t){super(t),this.list=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/loyalty_programmes"}}class A 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=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),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 k 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:{rate_id:t}})})),this.path="stays/quotes"}}class C 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 W extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.accommodation=new S(t),this.brands=new j(t),this.loyaltyProgrammes=new R(t),this.searchResults=new C(t),this.quotes=new k(t),this.bookings=new A(t)}}class I 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="payments/cards"}}class D 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="payments/three_d_secure_sessions"}}class H 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.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PUT",path:`${this.path}/${t}`,data:s})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.path="identity/customer/users"}}class V 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.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.delete=t=>h(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})})),this.path="identity/customer/user_groups"}}class U extends n{constructor(t){super(t),this.create=(...t)=>h(this,[...t],void 0,(function*(t={}){return this.request({method:"POST",path:this.path,data:t})})),this.path="identity/component_client_keys"}}class B extends n{constructor(t){super(t),this.path="identity",this.customerUsers=new H(t),this.customerUserGroups=new V(t),this.componentClientKeys=new U(t)}}function z(t){if(!Array.isArray(t)||0===t.length)return!1;for(const s of t)for(const t of s.cabins)for(const s of t.rows)for(const t of s.sections)for(const s of t.elements)if("seat"===s.type&&s.available_services.length>0)return!0;return!1}class L{constructor(t){this.client=new O(t),this.aircraft=new _(this.client),this.airlines=new E(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new P(this.client),this.batchOfferRequests=new c(this.client),this.offerRequests=new d(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new v(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new q(this.client),this.orderCancellations=new l(this.client),this.payments=new g(this.client),this.seatMaps=new T(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new $(this.client),this.suggestions=new w(this.client),this.refunds=new G(this.client),this.webhooks=new x(this.client),this.stays=new W(this.client),this.three_d_secure_sessions=new D(this.client),this.identity=new B(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new I(this.cardsClient)}}const M=y,F=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some((t=>t.maximum_quantity>0))||z(s)},J=z;export{L as Duffel,M as DuffelError,J as hasAvailableSeatService,F as hasService};
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:"4.21.1"};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=t=>h(this,[t],void 0,(function*({method:t,path:s,data:e,params:i}){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.create=t=>h(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.path="air/batch_offer_requests"}}class d extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:s,supplier_timeout:e}=t,h=i(t,["return_offers","supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:h,params:Object.assign(Object.assign({},null!=s&&{return_offers:s}),null!=e&&{supplier_timeout:e})})})),this.path="air/offer_requests"}}class p extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.getPriced=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/price`,data:s})})),this.path="air/offers"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=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 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.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class m extends 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 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.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 g extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class $ extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>h(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,e=i(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class T extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let y=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=i=>h(this,[i],void 0,(function*({method:i,path:h,data:r,params:a,compress:n=!0}){var o,u;let c,d;const p=new s(h,this.basePath),l={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e;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())})),p.search=t.toString()}r&&(c=JSON.stringify({data:Object.assign({},r)})),(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&(console.info("Endpoint: ",p.href),console.info("Method: ",i),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const f=yield t(p.href,{method:i,headers:l,body:c,compress:n});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const v=f.headers.get("content-type");if(d=v&&v.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in d&&d.errors)throw new y(Object.assign(Object.assign({},d),{status:f.status,headers:f.headers}));return Object.assign(Object.assign({},d),{status:f.status,headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v2",this.debug=n,this.source=o}paginatedRequest(t){return a(this,arguments,(function*({path:t,params:s}){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t,status:e.status});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:Object.assign(Object.assign({},s),{limit:e.meta.limit,after:e.meta.after})}));for(const t of e.data)yield yield r({data:t,status:e.status})}}))}}class _ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}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/airlines"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class 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 P 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 x 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,s)=>h(this,[t,s],void 0,(function*(t,{active:s,events:e,url:i}){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=t=>h(this,[t],void 0,(function*({events:t,url:s}){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class S extends n{constructor(t){super(t),this.suggestions=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})})),this.reviews=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/reviews`,params:s})})),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.path="stays/accommodation"}}class j 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=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/brands"}}class R extends n{constructor(t){super(t),this.list=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/loyalty_programmes"}}class A 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=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),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 k 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:{rate_id:t}})})),this.path="stays/quotes"}}class C 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 W extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.accommodation=new S(t),this.brands=new j(t),this.loyaltyProgrammes=new R(t),this.searchResults=new C(t),this.quotes=new k(t),this.bookings=new A(t)}}class I 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="payments/cards"}}class D 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="payments/three_d_secure_sessions"}}class H 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.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PUT",path:`${this.path}/${t}`,data:s})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.path="identity/customer/users"}}class V 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.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.delete=t=>h(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})})),this.path="identity/customer/user_groups"}}class U extends n{constructor(t){super(t),this.create=(...t)=>h(this,[...t],void 0,(function*(t={}){return this.request({method:"POST",path:this.path,data:t})})),this.path="identity/component_client_keys"}}class B extends n{constructor(t){super(t),this.path="identity",this.customerUsers=new H(t),this.customerUserGroups=new V(t),this.componentClientKeys=new U(t)}}function z(t){if(!Array.isArray(t)||0===t.length)return!1;for(const s of t)for(const t of s.cabins)for(const s of t.rows)for(const t of s.sections)for(const s of t.elements)if("seat"===s.type&&s.available_services.length>0)return!0;return!1}class L{constructor(t){this.client=new O(t),this.aircraft=new _(this.client),this.airlines=new E(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new P(this.client),this.batchOfferRequests=new c(this.client),this.offerRequests=new d(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new v(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new q(this.client),this.orderCancellations=new l(this.client),this.payments=new g(this.client),this.seatMaps=new T(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new $(this.client),this.suggestions=new w(this.client),this.refunds=new G(this.client),this.webhooks=new x(this.client),this.stays=new W(this.client),this.three_d_secure_sessions=new D(this.client),this.identity=new B(this.client),this.cardsClient=new O(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new I(this.cardsClient)}}const M=y,F=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some((t=>t.maximum_quantity>0))||z(s)},J=z;export{L as Duffel,M as DuffelError,J as hasAvailableSeatService,F as hasService};
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:"4.20.1"};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=t=>i(this,[t],void 0,(function*({method:t,path:s,data:e,params:i}){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 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.create=t=>i(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,i=e(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.path="air/batch_offer_requests"}}class c extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>i(this,void 0,void 0,(function*(){const{return_offers:s,supplier_timeout:i}=t,h=e(t,["return_offers","supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:h,params:Object.assign(Object.assign({},null!=s&&{return_offers:s}),null!=i&&{supplier_timeout:i})})})),this.path="air/offer_requests"}}class d 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.getPriced=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/price`,data:s})})),this.path="air/offers"}}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=>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 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=>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 v 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 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.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 q 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 g extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>i(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,i=e(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.getFaresById=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ 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 T=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class y{constructor({token:e,basePath:h,apiVersion:r,debug:a,source:n}){this.request=e=>i(this,[e],void 0,(function*({method:e,path:i,data:h,params:r,compress:a=!0}){var n,o;let u,c;const d=new s.URL(i,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(r){const t=new s.URLSearchParams;Object.entries(r).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()}h&&(u=JSON.stringify({data:Object.assign({},h)})),(null===(n=this.debug)||void 0===n?void 0:n.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",e),h&&console.info("Body Parameters: ",h),r&&console.info("Query Parameters: ",r));const l=yield t(d.href,{method:e,headers:p,body:u,compress:a});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const f=l.headers.get("content-type");if(c=f&&f.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in c&&c.errors)throw new T(Object.assign(Object.assign({},c),{status:l.status,headers:l.headers}));return Object.assign(Object.assign({},c),{status:l.status,headers:l.headers})})),this.token=e,this.basePath=h||"https://api.duffel.com",this.apiVersion=r||"v2",this.debug=a,this.source=n}paginatedRequest(t){return r(this,arguments,(function*({path:t,params:s}){let e=yield h(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield h({data:t,status:e.status});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield h(this.request({method:"GET",path:t,params:Object.assign(Object.assign({},s),{limit:e.meta.limit,after:e.meta.after})}));for(const t of e.data)yield yield h({data:t,status:e.status})}}))}}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 _ 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 E 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 b 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,s)=>i(this,[t,s],void 0,(function*(t,{active:s,events:e,url:i}){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:i}})})),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=t=>i(this,[t],void 0,(function*({events:t,url:s}){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class x extends a{constructor(t){super(t),this.suggestions=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})})),this.reviews=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/reviews`,params:s})})),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.path="stays/accommodation"}}class S 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=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/brands"}}class j extends a{constructor(t){super(t),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/loyalty_programmes"}}class 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.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:this.path,params:t}),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 A 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:{rate_id:t}})})),this.path="stays/quotes"}}class k 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 C extends a{constructor(t){super(t),this.search=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.accommodation=new x(t),this.brands=new S(t),this.loyaltyProgrammes=new j(t),this.searchResults=new k(t),this.quotes=new A(t),this.bookings=new R(t)}}class W extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/cards"}}class D 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="payments/three_d_secure_sessions"}}class I 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.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PUT",path:`${this.path}/${t}`,data:s})})),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.path="identity/customer/users"}}class U 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.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.delete=t=>i(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})})),this.path="identity/customer/user_groups"}}class H extends a{constructor(t){super(t),this.create=(...t)=>i(this,[...t],void 0,(function*(t={}){return this.request({method:"POST",path:this.path,data:t})})),this.path="identity/component_client_keys"}}class V extends a{constructor(t){super(t),this.path="identity",this.customerUsers=new I(t),this.customerUserGroups=new U(t),this.componentClientKeys=new H(t)}}function L(t){if(!Array.isArray(t)||0===t.length)return!1;for(const s of t)for(const t of s.cabins)for(const s of t.rows)for(const t of s.sections)for(const s of t.elements)if("seat"===s.type&&s.available_services.length>0)return!0;return!1}const B=T,z=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some((t=>t.maximum_quantity>0))||L(s)},M=L;exports.Duffel=class{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new _(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new G(this.client),this.batchOfferRequests=new u(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new l(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new v(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new p(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new n(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new b(this.client),this.refunds=new w(this.client),this.webhooks=new P(this.client),this.stays=new C(this.client),this.three_d_secure_sessions=new D(this.client),this.identity=new V(this.client),this.cardsClient=new y(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new W(this.cardsClient)}},exports.DuffelError=B,exports.hasAvailableSeatService=M,exports.hasService=z;
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:"4.21.1"};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=t=>i(this,[t],void 0,(function*({method:t,path:s,data:e,params:i}){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 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.create=t=>i(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,i=e(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.path="air/batch_offer_requests"}}class c extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>i(this,void 0,void 0,(function*(){const{return_offers:s,supplier_timeout:i}=t,h=e(t,["return_offers","supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:h,params:Object.assign(Object.assign({},null!=s&&{return_offers:s}),null!=i&&{supplier_timeout:i})})})),this.path="air/offer_requests"}}class d 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.getPriced=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/price`,data:s})})),this.path="air/offers"}}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=>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 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=>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 v 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 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.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 q 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 g extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>i(this,void 0,void 0,(function*(){const{supplier_timeout:s}=t,i=e(t,["supplier_timeout"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{supplier_timeout:s})})})),this.getFaresById=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ 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 T=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class y{constructor({token:e,basePath:h,apiVersion:r,debug:a,source:n}){this.request=e=>i(this,[e],void 0,(function*({method:e,path:i,data:h,params:r,compress:a=!0}){var n,o;let u,c;const d=new s.URL(i,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(r){const t=new s.URLSearchParams;Object.entries(r).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()}h&&(u=JSON.stringify({data:Object.assign({},h)})),(null===(n=this.debug)||void 0===n?void 0:n.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",e),h&&console.info("Body Parameters: ",h),r&&console.info("Query Parameters: ",r));const l=yield t(d.href,{method:e,headers:p,body:u,compress:a});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const f=l.headers.get("content-type");if(c=f&&f.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in c&&c.errors)throw new T(Object.assign(Object.assign({},c),{status:l.status,headers:l.headers}));return Object.assign(Object.assign({},c),{status:l.status,headers:l.headers})})),this.token=e,this.basePath=h||"https://api.duffel.com",this.apiVersion=r||"v2",this.debug=a,this.source=n}paginatedRequest(t){return r(this,arguments,(function*({path:t,params:s}){let e=yield h(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield h({data:t,status:e.status});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield h(this.request({method:"GET",path:t,params:Object.assign(Object.assign({},s),{limit:e.meta.limit,after:e.meta.after})}));for(const t of e.data)yield yield h({data:t,status:e.status})}}))}}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 _ 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 E 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 b 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,s)=>i(this,[t,s],void 0,(function*(t,{active:s,events:e,url:i}){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:i}})})),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=t=>i(this,[t],void 0,(function*({events:t,url:s}){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class x extends a{constructor(t){super(t),this.suggestions=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/suggestions`,data:{query:t,location:s}})})),this.reviews=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/reviews`,params:s})})),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.path="stays/accommodation"}}class S 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=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/brands"}}class j extends a{constructor(t){super(t),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.path="stays/loyalty_programmes"}}class 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.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:this.path,params:t}),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 A 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:{rate_id:t}})})),this.path="stays/quotes"}}class k 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 C extends a{constructor(t){super(t),this.search=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.accommodation=new x(t),this.brands=new S(t),this.loyaltyProgrammes=new j(t),this.searchResults=new k(t),this.quotes=new A(t),this.bookings=new R(t)}}class W extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/cards"}}class D 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="payments/three_d_secure_sessions"}}class I 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.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PUT",path:`${this.path}/${t}`,data:s})})),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.path="identity/customer/users"}}class U 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.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.delete=t=>i(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:s})})),this.path="identity/customer/user_groups"}}class H extends a{constructor(t){super(t),this.create=(...t)=>i(this,[...t],void 0,(function*(t={}){return this.request({method:"POST",path:this.path,data:t})})),this.path="identity/component_client_keys"}}class V extends a{constructor(t){super(t),this.path="identity",this.customerUsers=new I(t),this.customerUserGroups=new U(t),this.componentClientKeys=new H(t)}}function L(t){if(!Array.isArray(t)||0===t.length)return!1;for(const s of t)for(const t of s.cabins)for(const s of t.rows)for(const t of s.sections)for(const s of t.elements)if("seat"===s.type&&s.available_services.length>0)return!0;return!1}const B=T,z=function(t,s){return t&&Array.isArray(t.available_services)&&t.available_services.some((t=>t.maximum_quantity>0))||L(s)},M=L;exports.Duffel=class{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new _(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new G(this.client),this.batchOfferRequests=new u(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new l(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new v(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new p(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new n(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new b(this.client),this.refunds=new w(this.client),this.webhooks=new P(this.client),this.stays=new C(this.client),this.three_d_secure_sessions=new D(this.client),this.identity=new V(this.client),this.cardsClient=new y(Object.assign(Object.assign({},t),{basePath:"https://api.duffel.cards"})),this.cards=new W(this.cardsClient)}},exports.DuffelError=B,exports.hasAvailableSeatService=M,exports.hasService=z;
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,80 @@
1
+ import { Headers } from 'node-fetch';
2
+ /**
3
+ * Our list APIs will only return a limited number of results at a time.
4
+ * By default, we'll return 50 results per page, but you can set this to any number between 1 and 200.
5
+ * @link https://duffel.com/docs/api/overview/pagination
6
+ */
7
+ export interface PaginationMeta {
8
+ /**
9
+ * The number of results to be returned in a page, between 1 and 200 (optional, default is 50)
10
+ */
11
+ limit?: number;
12
+ /**
13
+ * "Before" cursor for pagination
14
+ */
15
+ before?: string;
16
+ /**
17
+ * "After" cursor for pagination
18
+ */
19
+ after?: string | null;
20
+ }
21
+ export interface ApiResponseMeta {
22
+ /**
23
+ * The identifier of the request
24
+ */
25
+ request_id: string;
26
+ /**
27
+ * The [HTTP status](https://httpstatuses.com/) of the request
28
+ */
29
+ status: number;
30
+ }
31
+ /**
32
+ * Duffel uses standard [HTTP response codes](https://httpstatuses.com/) to indicate the success or failure of API requests.
33
+ * @link https://duffel.com/docs/api/overview/errors
34
+ */
35
+ export interface ApiResponseError {
36
+ /**
37
+ * A machine-readable identifier for this specific error
38
+ */
39
+ code: string;
40
+ /**
41
+ * A URL pointing to a place in our documentation where you can read about the error
42
+ */
43
+ documentation_url: string;
44
+ /**
45
+ * A more detailed human-readable description of what went wrong
46
+ */
47
+ message: string;
48
+ /**
49
+ * A quick and simple description of what went wrong
50
+ */
51
+ title: string;
52
+ /**
53
+ * A machine-readable identifier for the general category of error
54
+ */
55
+ type: string;
56
+ }
57
+ export interface DuffelResponse<T_Data> {
58
+ /**
59
+ * The body of the response
60
+ */
61
+ data: T_Data;
62
+ /**
63
+ * Optional metadata for the request
64
+ */
65
+ meta?: PaginationMeta;
66
+ /**
67
+ * The headers from the http response
68
+ */
69
+ headers?: Headers;
70
+ /**
71
+ * The status from the http response
72
+ */
73
+ status: number;
74
+ }
75
+ export interface SDKOptions {
76
+ /**
77
+ * If `true` it will output the path and the method called
78
+ */
79
+ verbose?: boolean;
80
+ }
@@ -0,0 +1,115 @@
1
+ export type AcceptedCurrencies = 'AUD' | 'CAD' | 'EUR' | 'GBP' | 'USD';
2
+ export type LegalEntityType = 'corporation' | 'non_profit' | 'other' | 'partnership' | 'sole_proprietorship';
3
+ export type PersonalAccessTokenRole = 'roles/user/personal';
4
+ export type SourceOfFunds = 'capital_invested' | 'debt' | 'other' | 'revenue';
5
+ export type TokenRole = 'roles/api/read_write' | 'roles/api/read_only';
6
+ export type UserRole = 'roles/duffel/travel_ops' | 'roles/user/admin' | 'roles/user/agent' | 'roles/user/developer' | 'roles/user/owner' | 'roles/user/viewer' | PersonalAccessTokenRole;
7
+ export type VerificationFlow = 'duffel_2020' | 'stripe_connect';
8
+ export interface AccessToken {
9
+ created_at: string;
10
+ expires_at: string;
11
+ id: string;
12
+ last_used_at: string | null;
13
+ last_version_used: string | null;
14
+ live_mode: boolean | null;
15
+ name: string | null;
16
+ scope: TokenRole | UserRole;
17
+ token: string;
18
+ }
19
+ export interface Invitation {
20
+ accepted_at: string | null;
21
+ created_at: string;
22
+ expires_at: string | null;
23
+ id: string;
24
+ organisation: Organisation;
25
+ organisation_id: string;
26
+ recipient: User | null;
27
+ recipient_email: string;
28
+ recipient_id: string | null;
29
+ revoked_at: string | null;
30
+ scope: UserRole;
31
+ sender: User;
32
+ sender_id: string;
33
+ sent_at: string;
34
+ token: string;
35
+ }
36
+ export interface Organisation {
37
+ access_tokens: AccessToken[] | null;
38
+ avatar_url: string | null;
39
+ created_at: string;
40
+ id: string;
41
+ name: string;
42
+ settlement_currency: AcceptedCurrencies;
43
+ slug: string;
44
+ verified: boolean | null;
45
+ legal_entity: LegalEntity | null;
46
+ stripe_customer_id: string | null;
47
+ stripe_payment_method_id: string | null;
48
+ verification_flow: VerificationFlow;
49
+ contact_emails: string[] | null;
50
+ schedule_change_emails: string[] | null;
51
+ is_duffel_links_enabled: boolean;
52
+ stays_access_status: 'disabled' | 'live' | 'test';
53
+ password_expiry_timeout_days: number | null;
54
+ session_expiry_timeout: number;
55
+ }
56
+ export interface OrganisationMembership {
57
+ avatar_url: string | null;
58
+ id: string;
59
+ created_at: string;
60
+ disabled_at: string | null;
61
+ organisation_id: string;
62
+ owner: boolean | null;
63
+ scope: UserRole;
64
+ user_id: string;
65
+ user: User;
66
+ }
67
+ export interface User {
68
+ avatar_url: string | null;
69
+ created_at: string;
70
+ duffel_admin: boolean | null;
71
+ email: string;
72
+ email_confirmed_at: string | null;
73
+ full_name: string;
74
+ id: string;
75
+ organisation_invitations: Invitation[] | null;
76
+ organisation_memberships: UserOrganisationMembership[] | null;
77
+ unconfirmed_email: string | null;
78
+ temporary_personal_access_tokens: PersonalAccessToken[] | null;
79
+ send_marketing_emails: boolean;
80
+ }
81
+ export interface PersonalAccessToken {
82
+ created_at: string;
83
+ expires_at: string;
84
+ id: string;
85
+ last_used_at: null | string;
86
+ last_version_used: null | string;
87
+ live_mode: true;
88
+ name: null;
89
+ scope: PersonalAccessTokenRole;
90
+ token: string;
91
+ }
92
+ export interface UserOrganisationMembership extends OrganisationMembership {
93
+ organisation: Organisation;
94
+ }
95
+ export interface LegalEntity {
96
+ name: string;
97
+ type: LegalEntityType;
98
+ type_extra: string | null;
99
+ trading_name: string | null;
100
+ registered_business_address_line1: string;
101
+ registered_business_address_line2: string | null;
102
+ registered_business_address_city: string;
103
+ registered_business_address_region: string | null;
104
+ registered_business_address_postal_code: string;
105
+ registered_business_address_country_code: string;
106
+ registration_number: string;
107
+ registration_country_code: string;
108
+ tax_identification_number: string;
109
+ key_contact_first_name: string;
110
+ key_contact_last_name: string;
111
+ key_contact_job_title: string;
112
+ key_contact_email: string;
113
+ initial_top_up_source_of_funds: SourceOfFunds;
114
+ initial_top_up_source_of_funds_description: string | null;
115
+ }
@@ -0,0 +1,22 @@
1
+ export * from '../DuffelPayments/PaymentIntents/PaymentIntentsType';
2
+ export * from '../Places/Suggestions/SuggestionsType';
3
+ export * from '../Stays/StaysTypes';
4
+ export * from '../booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes';
5
+ export * from '../booking/OfferRequests/OfferRequestsTypes';
6
+ export * from '../booking/BatchOfferRequests/BatchOfferRequestsTypes';
7
+ export * from '../booking/Offers/OfferTypes';
8
+ export * from '../booking/OrderCancellations/OrderCancellationsTypes';
9
+ export * from '../booking/OrderChangeOffers/OrderChangeOfferTypes';
10
+ export * from '../booking/OrderChangeRequests/OrderChangeRequestsTypes';
11
+ export * from '../booking/OrderChanges/OrderChangesTypes';
12
+ export * from '../booking/Orders/OrdersTypes';
13
+ export * from '../booking/Payments/PaymentsTypes';
14
+ export * from '../booking/SeatMaps/SeatMapTypes';
15
+ export * from '../notifications/Webhooks/WebhooksType';
16
+ export * from '../supportingResources/Aircraft/AircraftTypes';
17
+ export * from '../supportingResources/Airlines/AirlinesTypes';
18
+ export * from '../supportingResources/Airports/AirportsTypes';
19
+ export * from './ClientType';
20
+ export * from './Identity';
21
+ export * from './shared';
22
+ export * from '../Identity/IdentityTypes';
@@ -0,0 +1,171 @@
1
+ import { Airport } from '../supportingResources/Airports/AirportsTypes';
2
+ /**
3
+ * The metropolitan area where the airport is located.
4
+ * Only present for airports which are registered with IATA as belonging to a metropolitan area.
5
+ * @link https://portal.iata.org/faq/articles/en_US/FAQ/How-do-I-create-a-new-Metropolitan-Area
6
+ */
7
+ export interface City {
8
+ /**
9
+ * The three-character IATA code for the city
10
+ * @example "LON"
11
+ */
12
+ iata_code: string;
13
+ /**
14
+ * The ISO 3166-1 alpha-2 code for the country where the city is located
15
+ * @link https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
16
+ * @example "GB"
17
+ */
18
+ iata_country_code: string;
19
+ /**
20
+ * Duffel's unique identifier for the city
21
+ * @example "cit_lon_gb"
22
+ */
23
+ id: string;
24
+ /**
25
+ * The name of the city
26
+ * @example "London"
27
+ */
28
+ name: string;
29
+ /**
30
+ * "The airports associated to a city. This will only be provided where the `type` is `city`."
31
+ */
32
+ airports?: Airport[];
33
+ /**
34
+ * The type of the place
35
+ */
36
+ type: 'city';
37
+ }
38
+ /**
39
+ * The cabin class that the passenger will travel in on this segment
40
+ */
41
+ export type CabinClass = 'first' | 'business' | 'premium_economy' | 'economy';
42
+ /**
43
+ * The type of the passenger
44
+ */
45
+ export type PassengerType = 'adult' | 'child' | 'infant_without_seat';
46
+ /**
47
+ * The passenger's title
48
+ */
49
+ export type DuffelPassengerTitle = 'mr' | 'ms' | 'mrs' | 'miss' | 'dr';
50
+ /**
51
+ * The passenger's gender
52
+ */
53
+ export type DuffelPassengerGender = 'm' | 'f';
54
+ /**
55
+ * The type of the identity document.
56
+ * This must be one of the `allowed_passenger_identity_document_types` on the offer.
57
+ */
58
+ export type PassengerIdentityDocumentType = 'passport' | 'tax_id';
59
+ export type Place = (Airport & {
60
+ type: 'airport';
61
+ }) | (City & {
62
+ type: 'city';
63
+ });
64
+ /**
65
+ * The type of the origin or destination
66
+ */
67
+ export type PlaceType = Place['type'];
68
+ export type FlightsConditionAllowed = {
69
+ /**
70
+ * The currency of the `penalty_amount` as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
71
+ * This will be in a currency determined by the airline, which is not necessarily the same as the currency of the order or offer.
72
+ * If this is `null` then `penalty_amount` will also be `null`.
73
+ *
74
+ * @example "GBP"
75
+ */
76
+ penalty_currency: string | null;
77
+ /**
78
+ * If the modification is `allowed` then this is the amount payable to apply the modification to all passengers.
79
+ * If there is no penalty, the value will be zero. If the modification isn't `allowed` or the penalty is not known then this field will be `null`.
80
+ * If this is `null` then the `penalty_currency` will also be null.
81
+ *
82
+ * @example "100.00"
83
+ */
84
+ penalty_amount: string | null;
85
+ /**
86
+ * Whether this kind of modification is allowed post-booking
87
+ *
88
+ * @example "true"
89
+ */
90
+ allowed: true;
91
+ };
92
+ export type FlightsConditionNotAllowed = {
93
+ /**
94
+ * The currency of the `penalty_amount` as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
95
+ * This will be in a currency determined by the airline, which is not necessarily the same as the currency of the order or offer.
96
+ * If this is `null` then `penalty_amount` will also be `null`.
97
+ *
98
+ * @example "GBP"
99
+ */
100
+ penalty_currency: null;
101
+ /**
102
+ * If the modification is `allowed` then this is the amount payable to apply the modification to all passengers.
103
+ * If there is no penalty, the value will be zero. If the modification isn't `allowed` or the penalty is not known then this field will be `null`.
104
+ * If this is `null` then the `penalty_currency` will also be null.
105
+ *
106
+ * @example "100.00"
107
+ */
108
+ penalty_amount: null;
109
+ /**
110
+ * Whether this kind of modification is allowed post-booking
111
+ *
112
+ * @example "true"
113
+ */
114
+ allowed: false;
115
+ };
116
+ export type FlightsCondition = FlightsConditionAllowed | FlightsConditionNotAllowed;
117
+ /**
118
+ * The conditions associated with this offer, describing the kinds of modifications you can make post-booking and any penalties that will apply to those modifications.
119
+ * This information assumes the condition is applied to all of the slices and passengers associated with this offer - for information at the slice level (e.g. "what happens if I just want to change the first slice?") refer to the slices.
120
+ * If a particular kind of modification is allowed, you may not always be able to take action through the Duffel API.
121
+ * In some cases, you may need to contact the Duffel support team or the airline directly.
122
+ */
123
+ export type FlightsConditions = {
124
+ /**
125
+ * Whether the whole order or offer can be refunded before the departure of the first slice.
126
+ * If all of the slices on the order or offer can be refunded then the `allowed` property will be `true` and information will be provided about any penalties.
127
+ * If any of the slices on the order or offer can't be refunded then the `allowed` property will be `false`.
128
+ * If the airline hasn't provided any information about whether this order or offer can be refunded then this property will be `null`.
129
+ */
130
+ refund_before_departure: FlightsCondition | null;
131
+ /**
132
+ * Whether the whole order or offer can be changed before the departure of the first slice.
133
+ * If all of the slices on the order or offer can be changed then the `allowed` property will be `true`.
134
+ * Refer to the `slices` for information about change penalties.
135
+ * If any of the slices on the order or offer can't be changed then the `allowed` property will be `false`.
136
+ * In this case you should refer to the slices conditions to determine if any part of the order or offer is changeable.
137
+ * If the airline hasn't provided any information about whether this order or offer can be changed then this property will be `null`.
138
+ */
139
+ change_before_departure: FlightsCondition | null;
140
+ };
141
+ /**
142
+ * The conditions associated with this offer, describing the kinds of modifications you can make post-booking and any penalties that will apply to those modifications.
143
+ * This information assumes the condition is applied to all of the slices and passengers associated with this offer - for information at the slice level (e.g. "what happens if I just want to change the first slice?") refer to the slices.
144
+ * If a particular kind of modification is allowed, you may not always be able to take action through the Duffel API.
145
+ * In some cases, you may need to contact the Duffel support team or the airline directly.
146
+ * Note that the perks associated with the slice are aggregated across passengers and segments and are intended to provide a brief summary of the passenger experience,
147
+ * however, the experience may not be consistent across all segments.
148
+ * As an example, priority boarding may be flagged as available but not available on all segments on the slice.
149
+ * See segment passenger conditions for a per-flight breakdown what is available to
150
+ * passengers if you require this level of granularity.
151
+ */
152
+ export type OfferSliceConditions = FlightsConditions & {
153
+ /**
154
+ * Whether passengers are able to select a seat prior to check in.
155
+ */
156
+ advance_seat_selection: boolean | null;
157
+ /**
158
+ * Whether passengers are given preferential boarding over others passengers in their cabin.
159
+ */
160
+ priority_boarding: boolean | null;
161
+ /**
162
+ * Whether passengers are given access to a fast track lane during check in.
163
+ */
164
+ priority_check_in: boolean | null;
165
+ };
166
+ /**
167
+ * The type of payment you want to apply to the order.
168
+ * If you are an IATA agent with your own agreements with airlines, in some cases, you can pay using ARC/BSP cash by specifying `arc_bsp_cash`. Otherwise, you must pay using your Duffel account's balance by specifying `balance`.
169
+ * In test mode, your balance is unlimited. If you're not sure which of these options applies to you, get in touch with the Duffel support team at [help@duffel.com](mailto:help@duffel.com).
170
+ */
171
+ export type PaymentType = 'arc_bsp_cash' | 'balance';
package/dist/typings.d.ts CHANGED
@@ -529,6 +529,10 @@ declare module '@duffel/api/Stays/StaysTypes' {
529
529
  * Useful in scenarios where a rate requires explicitly showing the source.
530
530
  */
531
531
  source: StaysSource;
532
+ /**
533
+ * The ISO 8601 date and time at which the rate will expire
534
+ */
535
+ expires_at: string;
532
536
  }
533
537
  export interface StaysRoomRate extends StaysRate {
534
538
  /**
@@ -955,6 +959,10 @@ declare module '@duffel/api/Stays/StaysTypes' {
955
959
  cheapest_rate_public_currency: string;
956
960
  cheapest_rate_due_at_accommodation_amount: string | null;
957
961
  cheapest_rate_due_at_accommodation_currency: string | null;
962
+ /**
963
+ * The ISO 8601 date and time at which the search result will expire
964
+ */
965
+ expires_at: string;
958
966
  }
959
967
  export interface StaysLoyaltyProgramme {
960
968
  reference: StaysLoyaltyProgrammeReference;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duffel/api",
3
- "version": "4.21.0",
3
+ "version": "4.21.1",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -83,7 +83,7 @@
83
83
  "eslint-plugin-spellcheck": "0.0.20",
84
84
  "husky": "8.0.3",
85
85
  "jest": "29.7.0",
86
- "lint-staged": "15.2.10",
86
+ "lint-staged": "15.5.2",
87
87
  "nock": "13.5.6",
88
88
  "prettier": "3.5.3",
89
89
  "rollup": "4.22.4",