@duffel/api 1.13.1 → 1.14.2

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,21 @@
1
+ import { Resource } from '../../Resource';
2
+ import { DuffelResponse } from '../../types';
3
+ import { CreateRefund, Refund } from './RefundsType';
4
+ export declare class Refunds extends Resource {
5
+ /**
6
+ * Endpoint path
7
+ */
8
+ path: string;
9
+ constructor(args: any);
10
+ /**
11
+ * You should use this API to get the complete, up-to-date information about a Refund.
12
+ * @param {string} id - Duffel's unique identifier for the Refund
13
+ * @link https://duffel.com/docs/api/refunds/get-refund-by-id
14
+ */
15
+ get: (id: string) => Promise<DuffelResponse<Refund>>;
16
+ /**
17
+ * Create a Refund to refund some money to a customer that they paid using a Payment Intent. You must specify the amount and currency. The currency is currently limited to the currency in which the Payment Intent was made.
18
+ * @param {Object.<CreateFund>} params - Endpoint params (amount, currency and payment_intent_id)
19
+ */
20
+ create: (params: CreateRefund) => Promise<DuffelResponse<Refund>>;
21
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,70 @@
1
+ export interface Refund {
2
+ /**
3
+ * The amount of the Payment Intent that will be refunded to the customer
4
+ */
5
+ amount: string;
6
+ /**
7
+ * When the refund is expected to arrive in the destination
8
+ */
9
+ arrival: string;
10
+ /**
11
+ * The ISO 8601 datetime at which the Refund was created
12
+ */
13
+ created_at: string;
14
+ /**
15
+ * The currency of the amount, as an ISO 4217 currency code.
16
+ * It will always match the currency of the Payment Intent.
17
+ */
18
+ currency: string;
19
+ /**
20
+ * Where the Refund amount will be sent to
21
+ */
22
+ destination: 'original_form_of_payment';
23
+ /**
24
+ * Duffel's unique identifier for the Refund
25
+ */
26
+ id: string;
27
+ /**
28
+ * Whether the Refund was created in live mode. This field will be set to true if the Refund was created in live mode, or false if it was created in test mode.
29
+ */
30
+ live_mode: boolean;
31
+ /**
32
+ * The amount deducted from your Balance to cover the Refund amount
33
+ */
34
+ net_amount: string;
35
+ /**
36
+ * The currency of the net_amount, as an ISO 4217 currency code.
37
+ * This currency will match your Balance currency.
38
+ */
39
+ net_currency: string;
40
+ /**
41
+ * Duffel's unique identifier for the Payment Intent that the Refund is for
42
+ */
43
+ payment_intent_id: string;
44
+ /**
45
+ * The status of the Refund.
46
+ * Succeeded: The refund is on its way to the destination.
47
+ * Pending: The Refund could not be processed immediately, and is pending processing.
48
+ * Failed: A refund can fail if the customer’s bank or card issuer has been unable to process it correctly (e.g., a closed bank account or a problem with the card). The bank returns the refunded amount to us and we add it back to your Balance. This process can take up to 30 days from the post date.
49
+ */
50
+ status: 'succeeded' | 'pending' | 'failed';
51
+ /**
52
+ * The ISO 8601 datetime at which the Refund was updated
53
+ */
54
+ updated_at: string;
55
+ }
56
+ export interface CreateRefund {
57
+ /**
58
+ * This amount that will be refunded to the customer's card.
59
+ */
60
+ amount: string;
61
+ /**
62
+ * The currency of the amount, as an ISO 4217 currency code.
63
+ * It must match the Payment Intent currency.
64
+ */
65
+ currency: string;
66
+ /**
67
+ * Duffel's unique identifier for the Payment Intent that the Refund is for
68
+ */
69
+ payment_intent_id: string;
70
+ }
@@ -0,0 +1 @@
1
+ export * from './Refunds';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import { OfferRequests, Offers, OrderCancellations, Orders, OrderChangeRequests,
3
3
  import { Config, DuffelError as _DuffelError } from './Client';
4
4
  import { Aircraft, Airlines, Airports } from './supportingResources';
5
5
  import { Suggestions } from './Places/Suggestions';
6
+ import { Refunds } from './DuffelPayments/Refunds';
6
7
  export interface DuffelAPIClient {
7
8
  aircraft: Aircraft;
8
9
  airlines: Airlines;
@@ -33,6 +34,7 @@ export declare class Duffel {
33
34
  seatMaps: SeatMaps;
34
35
  paymentIntents: PaymentIntents;
35
36
  suggestions: Suggestions;
37
+ refunds: Refunds;
36
38
  constructor(config: Config);
37
39
  }
38
40
  export declare const DuffelError: typeof _DuffelError;
package/dist/index.es.js CHANGED
@@ -1,2 +1,2 @@
1
- import t from"node-fetch";import{URL as e,URLSearchParams as s}from"url";function i(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function r(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function h(t){return this instanceof h?(this.v=t,this):new h(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){a.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof h?Promise.resolve(s.value.v).then(p,c):u(a[0][2],s)}catch(t){u(a[0][3],t)}var s}function p(t){o("next",t)}function c(t){o("throw",t)}function u(t,e){t(e),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.13.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class n{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>r(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class p extends n{constructor(t){super(t),this.get=t=>r(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=>r(this,void 0,void 0,(function*(){const{return_offers:e}=t,s=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class c extends n{constructor(t){super(t),this.get=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>r(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class u extends n{constructor(t){super(t),this.get=t=>r(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=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class d extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>r(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=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.path="air/orders"}}class f extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class l extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m extends n{constructor(t){super(t),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class v extends n{constructor(t){super(t),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}class q extends Error{constructor({meta:t,errors:e}){super(),this.meta=t,this.errors=e}}class y{constructor({token:i,basePath:h,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:h,data:a,params:n,compress:o=!0})=>r(this,void 0,void 0,(function*(){var r;let p,c;const u=new e(h,this.basePath),d={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=new s;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),u.search=t.toString()}a&&(p=JSON.stringify({data:Object.assign({},a)})),(null===(r=this.debug)||void 0===r?void 0:r.verbose)&&(console.info("Endpoint: ",u.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(u.href,{method:i,headers:d,body:p,compress:o}),l=f.headers.get("content-type");if(c=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in c&&c.errors)throw new q(c);return c})),this.token=i,this.basePath=h||"https://api.duffel.com",this.apiVersion=a||"beta",this.debug=n,this.source=o}paginatedRequest({path:t,params:e}){return a(this,arguments,(function*(){let s=yield h(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield h({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield h(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield h({data:t})}}))}}class $ extends n{constructor(t){super(t),this.get=t=>r(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 T extends n{constructor(t){super(t),this.get=t=>r(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 w extends n{constructor(t){super(t),this.get=t=>r(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 G extends n{constructor(t){super(t),this.list=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class O{constructor(t){this.client=new y(t),this.aircraft=new $(this.client),this.airlines=new T(this.client),this.airports=new w(this.client),this.offerRequests=new p(this.client),this.offers=new c(this.client),this.orders=new d(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new u(this.client),this.payments=new v(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new o(this.client),this.suggestions=new G(this.client)}}const b=q;export{O as Duffel,b as DuffelError};
1
+ import t from"node-fetch";import{URL as e,URLSearchParams as s}from"url";function i(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function r(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function h(t){return this instanceof h?(this.v=t,this):new h(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){a.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof h?Promise.resolve(s.value.v).then(p,c):u(a[0][2],s)}catch(t){u(a[0][3],t)}var s}function p(t){o("next",t)}function c(t){o("throw",t)}function u(t,e){t(e),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.14.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class n{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>r(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class p extends n{constructor(t){super(t),this.get=t=>r(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=>r(this,void 0,void 0,(function*(){const{return_offers:e}=t,s=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class c extends n{constructor(t){super(t),this.get=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>r(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class u extends n{constructor(t){super(t),this.get=t=>r(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=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class d extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>r(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=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.path="air/orders"}}class f extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class l extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m extends n{constructor(t){super(t),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class v extends n{constructor(t){super(t),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}class q extends Error{constructor({meta:t,errors:e}){super(),this.meta=t,this.errors=e}}class y{constructor({token:i,basePath:h,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:h,data:a,params:n,compress:o=!0})=>r(this,void 0,void 0,(function*(){var r;let p,c;const u=new e(h,this.basePath),d={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=new s;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),u.search=t.toString()}a&&(p=JSON.stringify({data:Object.assign({},a)})),(null===(r=this.debug)||void 0===r?void 0:r.verbose)&&(console.info("Endpoint: ",u.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(u.href,{method:i,headers:d,body:p,compress:o}),l=f.headers.get("content-type");if(c=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in c&&c.errors)throw new q(c);return c})),this.token=i,this.basePath=h||"https://api.duffel.com",this.apiVersion=a||"beta",this.debug=n,this.source=o}paginatedRequest({path:t,params:e}){return a(this,arguments,(function*(){let s=yield h(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield h({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield h(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield h({data:t})}}))}}class $ extends n{constructor(t){super(t),this.get=t=>r(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 T extends n{constructor(t){super(t),this.get=t=>r(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 w extends n{constructor(t){super(t),this.get=t=>r(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 G extends n{constructor(t){super(t),this.list=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class O extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class E{constructor(t){this.client=new y(t),this.aircraft=new $(this.client),this.airlines=new T(this.client),this.airports=new w(this.client),this.offerRequests=new p(this.client),this.offers=new c(this.client),this.orders=new d(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new u(this.client),this.payments=new v(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new o(this.client),this.suggestions=new G(this.client),this.refunds=new O(this.client)}}const b=q;export{E as Duffel,b as DuffelError};
2
2
  //# sourceMappingURL=index.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","rejected","result","done","then","apply","__await","v","this","__asyncGenerator","Symbol","asyncIterator","TypeError","g","q","verb","n","a","b","push","resume","r","fulfill","settle","f","shift"],"mappings":"yEAwCO,SAASA,EAAOC,EAAGC,GACtB,IAAIC,EAAI,GACR,IAAK,IAAIC,KAAKH,EAAOI,OAAOC,UAAUC,eAAeC,KAAKP,EAAGG,IAAMF,EAAEO,QAAQL,GAAK,IAC9ED,EAAEC,GAAKH,EAAEG,IACb,GAAS,MAALH,GAAqD,mBAAjCI,OAAOK,sBACtB,CAAA,IAAIC,EAAI,EAAb,IAAgBP,EAAIC,OAAOK,sBAAsBT,GAAIU,EAAIP,EAAEQ,OAAQD,IAC3DT,EAAEO,QAAQL,EAAEO,IAAM,GAAKN,OAAOC,UAAUO,qBAAqBL,KAAKP,EAAGG,EAAEO,MACvER,EAAEC,EAAEO,IAAMV,EAAEG,EAAEO,KAE1B,OAAOR,EAkBJ,SAASW,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOrB,GAAKmB,EAAOnB,IACpF,SAASwB,EAASH,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,IAAW,MAAOrB,GAAKmB,EAAOnB,IACvF,SAASsB,EAAKG,GAJlB,IAAeJ,EAIaI,EAAOC,KAAOR,EAAQO,EAAOJ,QAJ1CA,EAIyDI,EAAOJ,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,OAITM,KAAKP,EAAWI,GAClGF,GAAMN,EAAYA,EAAUY,MAAMf,EAASC,GAAc,KAAKS,WAoF/D,SAASM,EAAQC,GACpB,OAAOC,gBAAgBF,GAAWE,KAAKD,EAAIA,EAAGC,MAAQ,IAAIF,EAAQC,GAG/D,SAASE,EAAiBnB,EAASC,EAAYE,GAClD,IAAKiB,OAAOC,cAAe,MAAM,IAAIC,UAAU,wCAC/C,IAAoD1B,EAAhD2B,EAAIpB,EAAUY,MAAMf,EAASC,GAAc,IAAQuB,EAAI,GAC3D,OAAO5B,EAAI,GAAI6B,EAAK,QAASA,EAAK,SAAUA,EAAK,UAAW7B,EAAEwB,OAAOC,eAAiB,WAAc,OAAOH,MAAStB,EACpH,SAAS6B,EAAKC,GAASH,EAAEG,KAAI9B,EAAE8B,GAAK,SAAUT,GAAK,OAAO,IAAIb,SAAQ,SAAUuB,EAAGC,GAAKJ,EAAEK,KAAK,CAACH,EAAGT,EAAGU,EAAGC,IAAM,GAAKE,EAAOJ,EAAGT,QAC9H,SAASa,EAAOJ,EAAGT,GAAK,KACVc,EADqBR,EAAEG,GAAGT,IACnBT,iBAAiBQ,EAAUZ,QAAQC,QAAQ0B,EAAEvB,MAAMS,GAAGH,KAAKkB,EAAS1B,GAAU2B,EAAOT,EAAE,GAAG,GAAIO,GADpE,MAAO5C,GAAK8C,EAAOT,EAAE,GAAG,GAAIrC,GAC3E,IAAc4C,EACd,SAASC,EAAQxB,GAASsB,EAAO,OAAQtB,GACzC,SAASF,EAAOE,GAASsB,EAAO,QAAStB,GACzC,SAASyB,EAAOC,EAAGjB,GAASiB,EAAEjB,GAAIO,EAAEW,QAASX,EAAE3B,QAAQiC,EAAON,EAAE,GAAG,GAAIA,EAAE,GAAG"}
1
+ {"version":3,"file":"index.es.js","sources":["../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","rejected","result","done","then","apply","__await","v","this","__asyncGenerator","Symbol","asyncIterator","TypeError","g","q","verb","n","a","b","push","resume","r","fulfill","settle","f","shift"],"mappings":"yEAwCO,SAASA,EAAOC,EAAGC,GACtB,IAAIC,EAAI,CAAA,EACR,IAAK,IAAIC,KAAKH,EAAOI,OAAOC,UAAUC,eAAeC,KAAKP,EAAGG,IAAMF,EAAEO,QAAQL,GAAK,IAC9ED,EAAEC,GAAKH,EAAEG,IACb,GAAS,MAALH,GAAqD,mBAAjCI,OAAOK,sBACtB,KAAIC,EAAI,EAAb,IAAgBP,EAAIC,OAAOK,sBAAsBT,GAAIU,EAAIP,EAAEQ,OAAQD,IAC3DT,EAAEO,QAAQL,EAAEO,IAAM,GAAKN,OAAOC,UAAUO,qBAAqBL,KAAKP,EAAGG,EAAEO,MACvER,EAAEC,EAAEO,IAAMV,EAAEG,EAAEO,IAF4B,CAItD,OAAOR,CACX,CAiBO,SAASW,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOrB,GAAKmB,EAAOnB,GAAO,CAC3F,SAASwB,EAASH,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,IAAW,MAAOrB,GAAKmB,EAAOnB,GAAO,CAC9F,SAASsB,EAAKG,GAJlB,IAAeJ,EAIaI,EAAOC,KAAOR,EAAQO,EAAOJ,QAJ1CA,EAIyDI,EAAOJ,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBM,KAAKP,EAAWI,EAAY,CAC9GF,GAAMN,EAAYA,EAAUY,MAAMf,EAASC,GAAc,KAAKS,OACtE,GACA,CAkFO,SAASM,EAAQC,GACpB,OAAOC,gBAAgBF,GAAWE,KAAKD,EAAIA,EAAGC,MAAQ,IAAIF,EAAQC,EACtE,CAEO,SAASE,EAAiBnB,EAASC,EAAYE,GAClD,IAAKiB,OAAOC,cAAe,MAAM,IAAIC,UAAU,wCAC/C,IAAoD1B,EAAhD2B,EAAIpB,EAAUY,MAAMf,EAASC,GAAc,IAAQuB,EAAI,GAC3D,OAAO5B,EAAI,CAAA,EAAI6B,EAAK,QAASA,EAAK,SAAUA,EAAK,UAAW7B,EAAEwB,OAAOC,eAAiB,WAAc,OAAOH,IAAO,EAAEtB,EACpH,SAAS6B,EAAKC,GAASH,EAAEG,KAAI9B,EAAE8B,GAAK,SAAUT,GAAK,OAAO,IAAIb,SAAQ,SAAUuB,EAAGC,GAAKJ,EAAEK,KAAK,CAACH,EAAGT,EAAGU,EAAGC,IAAM,GAAKE,EAAOJ,EAAGT,EAAG,GAAM,EAAG,CAC1I,SAASa,EAAOJ,EAAGT,GAAK,KACVc,EADqBR,EAAEG,GAAGT,IACnBT,iBAAiBQ,EAAUZ,QAAQC,QAAQ0B,EAAEvB,MAAMS,GAAGH,KAAKkB,EAAS1B,GAAU2B,EAAOT,EAAE,GAAG,GAAIO,GADpE,MAAO5C,GAAK8C,EAAOT,EAAE,GAAG,GAAIrC,GAC3E,IAAc4C,CADoE,CAElF,SAASC,EAAQxB,GAASsB,EAAO,OAAQtB,EAAS,CAClD,SAASF,EAAOE,GAASsB,EAAO,QAAStB,EAAS,CAClD,SAASyB,EAAOC,EAAGjB,GAASiB,EAAEjB,GAAIO,EAAEW,QAASX,EAAE3B,QAAQiC,EAAON,EAAE,GAAG,GAAIA,EAAE,GAAG,GAAM,CACtF"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("node-fetch"),e=require("url");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);function r(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function h(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function n(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),h=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){h.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):p(h[0][2],s)}catch(t){p(h[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}}!function(){const t={npm_package_version:"1.13.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class o{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class u extends o{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 c extends o{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:e}=t,s=r(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class d extends o{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 o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.path="air/orders"}}class l extends o{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 o{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 v extends o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class g extends o{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 q extends o{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"}}class y extends Error{constructor({meta:t,errors:e}){super(),this.meta=t,this.errors=e}}class ${constructor({token:t,basePath:s,apiVersion:r,debug:a,source:n}){this.request=({method:t,path:s,data:r,params:a,compress:n=!0})=>h(this,void 0,void 0,(function*(){var h;let o,u;const c=new e.URL(s,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),c.search=t.toString()}r&&(o=JSON.stringify({data:Object.assign({},r)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",c.href),console.info("Method: ",t),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const d=yield i.default(c.href,{method:t,headers:p,body:o,compress:n}),f=d.headers.get("content-type");if(u=f&&f.includes("json")?yield d.json():yield d.text(),!d.ok||"errors"in u&&u.errors)throw new y(u);return u})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=r||"beta",this.debug=a,this.source=n}paginatedRequest({path:t,params:e}){return n(this,arguments,(function*(){let s=yield a(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield a({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield a(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield a({data:t})}}))}}class T extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class b extends o{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 O extends o{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 _ extends o{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"}}const w=y;exports.Duffel=class{constructor(t){this.client=new $(t),this.aircraft=new T(this.client),this.airlines=new b(this.client),this.airports=new O(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new g(this.client),this.seatMaps=new q(this.client),this.paymentIntents=new u(this.client),this.suggestions=new _(this.client)}},exports.DuffelError=w;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("node-fetch"),e=require("url");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);function r(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function h(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function n(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),h=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){h.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):p(h[0][2],s)}catch(t){p(h[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}}!function(){const t={npm_package_version:"1.14.0"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class o{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class u extends o{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 c extends o{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:e}=t,s=r(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class d extends o{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 o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.path="air/orders"}}class l extends o{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 o{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 v extends o{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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class q extends o{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends o{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"}}class y extends Error{constructor({meta:t,errors:e}){super(),this.meta=t,this.errors=e}}class ${constructor({token:t,basePath:s,apiVersion:r,debug:a,source:n}){this.request=({method:t,path:s,data:r,params:a,compress:n=!0})=>h(this,void 0,void 0,(function*(){var h;let o,u;const c=new e.URL(s,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),c.search=t.toString()}r&&(o=JSON.stringify({data:Object.assign({},r)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",c.href),console.info("Method: ",t),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const d=yield i.default(c.href,{method:t,headers:p,body:o,compress:n}),f=d.headers.get("content-type");if(u=f&&f.includes("json")?yield d.json():yield d.text(),!d.ok||"errors"in u&&u.errors)throw new y(u);return u})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=r||"beta",this.debug=a,this.source=n}paginatedRequest({path:t,params:e}){return n(this,arguments,(function*(){let s=yield a(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield a({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield a(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield a({data:t})}}))}}class T extends o{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 O extends o{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 o{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 o{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 E extends o{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"}}const G=y;exports.Duffel=class{constructor(t){this.client=new $(t),this.aircraft=new T(this.client),this.airlines=new O(this.client),this.airports=new b(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new q(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new u(this.client),this.suggestions=new w(this.client),this.refunds=new E(this.client)}},exports.DuffelError=G;
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","rejected","result","done","then","apply","__await","v","this","__asyncGenerator","Symbol","asyncIterator","TypeError","g","q","verb","n","a","b","push","resume","r","fulfill","settle","f","shift"],"mappings":"oMAwCO,SAASA,EAAOC,EAAGC,GACtB,IAAIC,EAAI,GACR,IAAK,IAAIC,KAAKH,EAAOI,OAAOC,UAAUC,eAAeC,KAAKP,EAAGG,IAAMF,EAAEO,QAAQL,GAAK,IAC9ED,EAAEC,GAAKH,EAAEG,IACb,GAAS,MAALH,GAAqD,mBAAjCI,OAAOK,sBACtB,CAAA,IAAIC,EAAI,EAAb,IAAgBP,EAAIC,OAAOK,sBAAsBT,GAAIU,EAAIP,EAAEQ,OAAQD,IAC3DT,EAAEO,QAAQL,EAAEO,IAAM,GAAKN,OAAOC,UAAUO,qBAAqBL,KAAKP,EAAGG,EAAEO,MACvER,EAAEC,EAAEO,IAAMV,EAAEG,EAAEO,KAE1B,OAAOR,EAkBJ,SAASW,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOrB,GAAKmB,EAAOnB,IACpF,SAASwB,EAASH,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,IAAW,MAAOrB,GAAKmB,EAAOnB,IACvF,SAASsB,EAAKG,GAJlB,IAAeJ,EAIaI,EAAOC,KAAOR,EAAQO,EAAOJ,QAJ1CA,EAIyDI,EAAOJ,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,OAITM,KAAKP,EAAWI,GAClGF,GAAMN,EAAYA,EAAUY,MAAMf,EAASC,GAAc,KAAKS,WAoF/D,SAASM,EAAQC,GACpB,OAAOC,gBAAgBF,GAAWE,KAAKD,EAAIA,EAAGC,MAAQ,IAAIF,EAAQC,GAG/D,SAASE,EAAiBnB,EAASC,EAAYE,GAClD,IAAKiB,OAAOC,cAAe,MAAM,IAAIC,UAAU,wCAC/C,IAAoD1B,EAAhD2B,EAAIpB,EAAUY,MAAMf,EAASC,GAAc,IAAQuB,EAAI,GAC3D,OAAO5B,EAAI,GAAI6B,EAAK,QAASA,EAAK,SAAUA,EAAK,UAAW7B,EAAEwB,OAAOC,eAAiB,WAAc,OAAOH,MAAStB,EACpH,SAAS6B,EAAKC,GAASH,EAAEG,KAAI9B,EAAE8B,GAAK,SAAUT,GAAK,OAAO,IAAIb,SAAQ,SAAUuB,EAAGC,GAAKJ,EAAEK,KAAK,CAACH,EAAGT,EAAGU,EAAGC,IAAM,GAAKE,EAAOJ,EAAGT,QAC9H,SAASa,EAAOJ,EAAGT,GAAK,KACVc,EADqBR,EAAEG,GAAGT,IACnBT,iBAAiBQ,EAAUZ,QAAQC,QAAQ0B,EAAEvB,MAAMS,GAAGH,KAAKkB,EAAS1B,GAAU2B,EAAOT,EAAE,GAAG,GAAIO,GADpE,MAAO5C,GAAK8C,EAAOT,EAAE,GAAG,GAAIrC,GAC3E,IAAc4C,EACd,SAASC,EAAQxB,GAASsB,EAAO,OAAQtB,GACzC,SAASF,EAAOE,GAASsB,EAAO,QAAStB,GACzC,SAASyB,EAAOC,EAAGjB,GAASiB,EAAEjB,GAAIO,EAAEW,QAASX,EAAE3B,QAAQiC,EAAON,EAAE,GAAG,GAAIA,EAAE,GAAG"}
1
+ {"version":3,"file":"index.js","sources":["../node_modules/tslib/tslib.es6.js"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport function __createBinding(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}\r\n\r\nexport function __exportStar(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n};\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, privateMap) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to get private field on non-instance\");\r\n }\r\n return privateMap.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, privateMap, value) {\r\n if (!privateMap.has(receiver)) {\r\n throw new TypeError(\"attempted to set private field on non-instance\");\r\n }\r\n privateMap.set(receiver, value);\r\n return value;\r\n}\r\n"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","__awaiter","thisArg","_arguments","P","generator","Promise","resolve","reject","fulfilled","value","step","next","rejected","result","done","then","apply","__await","v","this","__asyncGenerator","Symbol","asyncIterator","TypeError","g","q","verb","n","a","b","push","resume","r","fulfill","settle","f","shift"],"mappings":"oMAwCO,SAASA,EAAOC,EAAGC,GACtB,IAAIC,EAAI,CAAA,EACR,IAAK,IAAIC,KAAKH,EAAOI,OAAOC,UAAUC,eAAeC,KAAKP,EAAGG,IAAMF,EAAEO,QAAQL,GAAK,IAC9ED,EAAEC,GAAKH,EAAEG,IACb,GAAS,MAALH,GAAqD,mBAAjCI,OAAOK,sBACtB,KAAIC,EAAI,EAAb,IAAgBP,EAAIC,OAAOK,sBAAsBT,GAAIU,EAAIP,EAAEQ,OAAQD,IAC3DT,EAAEO,QAAQL,EAAEO,IAAM,GAAKN,OAAOC,UAAUO,qBAAqBL,KAAKP,EAAGG,EAAEO,MACvER,EAAEC,EAAEO,IAAMV,EAAEG,EAAEO,IAF4B,CAItD,OAAOR,CACX,CAiBO,SAASW,EAAUC,EAASC,EAAYC,EAAGC,GAE9C,OAAO,IAAKD,IAAMA,EAAIE,WAAU,SAAUC,EAASC,GAC/C,SAASC,EAAUC,GAAS,IAAMC,EAAKN,EAAUO,KAAKF,IAAW,MAAOrB,GAAKmB,EAAOnB,GAAO,CAC3F,SAASwB,EAASH,GAAS,IAAMC,EAAKN,EAAiB,MAAEK,IAAW,MAAOrB,GAAKmB,EAAOnB,GAAO,CAC9F,SAASsB,EAAKG,GAJlB,IAAeJ,EAIaI,EAAOC,KAAOR,EAAQO,EAAOJ,QAJ1CA,EAIyDI,EAAOJ,MAJhDA,aAAiBN,EAAIM,EAAQ,IAAIN,GAAE,SAAUG,GAAWA,EAAQG,EAAO,KAIhBM,KAAKP,EAAWI,EAAY,CAC9GF,GAAMN,EAAYA,EAAUY,MAAMf,EAASC,GAAc,KAAKS,OACtE,GACA,CAkFO,SAASM,EAAQC,GACpB,OAAOC,gBAAgBF,GAAWE,KAAKD,EAAIA,EAAGC,MAAQ,IAAIF,EAAQC,EACtE,CAEO,SAASE,EAAiBnB,EAASC,EAAYE,GAClD,IAAKiB,OAAOC,cAAe,MAAM,IAAIC,UAAU,wCAC/C,IAAoD1B,EAAhD2B,EAAIpB,EAAUY,MAAMf,EAASC,GAAc,IAAQuB,EAAI,GAC3D,OAAO5B,EAAI,CAAA,EAAI6B,EAAK,QAASA,EAAK,SAAUA,EAAK,UAAW7B,EAAEwB,OAAOC,eAAiB,WAAc,OAAOH,IAAO,EAAEtB,EACpH,SAAS6B,EAAKC,GAASH,EAAEG,KAAI9B,EAAE8B,GAAK,SAAUT,GAAK,OAAO,IAAIb,SAAQ,SAAUuB,EAAGC,GAAKJ,EAAEK,KAAK,CAACH,EAAGT,EAAGU,EAAGC,IAAM,GAAKE,EAAOJ,EAAGT,EAAG,GAAM,EAAG,CAC1I,SAASa,EAAOJ,EAAGT,GAAK,KACVc,EADqBR,EAAEG,GAAGT,IACnBT,iBAAiBQ,EAAUZ,QAAQC,QAAQ0B,EAAEvB,MAAMS,GAAGH,KAAKkB,EAAS1B,GAAU2B,EAAOT,EAAE,GAAG,GAAIO,GADpE,MAAO5C,GAAK8C,EAAOT,EAAE,GAAG,GAAIrC,GAC3E,IAAc4C,CADoE,CAElF,SAASC,EAAQxB,GAASsB,EAAO,OAAQtB,EAAS,CAClD,SAASF,EAAOE,GAASsB,EAAO,QAAStB,EAAS,CAClD,SAASyB,EAAOC,EAAGjB,GAASiB,EAAEjB,GAAIO,EAAEW,QAASX,EAAE3B,QAAQiC,EAAON,EAAE,GAAG,GAAIA,EAAE,GAAG,GAAM,CACtF"}
@@ -2655,6 +2655,96 @@ declare class Suggestions extends Resource {
2655
2655
  list: (params: PlacesSuggestionsParameters) => Promise<DuffelResponse<Places[]>>;
2656
2656
  }
2657
2657
 
2658
+ interface Refund {
2659
+ /**
2660
+ * The amount of the Payment Intent that will be refunded to the customer
2661
+ */
2662
+ amount: string;
2663
+ /**
2664
+ * When the refund is expected to arrive in the destination
2665
+ */
2666
+ arrival: string;
2667
+ /**
2668
+ * The ISO 8601 datetime at which the Refund was created
2669
+ */
2670
+ created_at: string;
2671
+ /**
2672
+ * The currency of the amount, as an ISO 4217 currency code.
2673
+ * It will always match the currency of the Payment Intent.
2674
+ */
2675
+ currency: string;
2676
+ /**
2677
+ * Where the Refund amount will be sent to
2678
+ */
2679
+ destination: 'original_form_of_payment';
2680
+ /**
2681
+ * Duffel's unique identifier for the Refund
2682
+ */
2683
+ id: string;
2684
+ /**
2685
+ * Whether the Refund was created in live mode. This field will be set to true if the Refund was created in live mode, or false if it was created in test mode.
2686
+ */
2687
+ live_mode: boolean;
2688
+ /**
2689
+ * The amount deducted from your Balance to cover the Refund amount
2690
+ */
2691
+ net_amount: string;
2692
+ /**
2693
+ * The currency of the net_amount, as an ISO 4217 currency code.
2694
+ * This currency will match your Balance currency.
2695
+ */
2696
+ net_currency: string;
2697
+ /**
2698
+ * Duffel's unique identifier for the Payment Intent that the Refund is for
2699
+ */
2700
+ payment_intent_id: string;
2701
+ /**
2702
+ * The status of the Refund.
2703
+ * Succeeded: The refund is on its way to the destination.
2704
+ * Pending: The Refund could not be processed immediately, and is pending processing.
2705
+ * Failed: A refund can fail if the customer’s bank or card issuer has been unable to process it correctly (e.g., a closed bank account or a problem with the card). The bank returns the refunded amount to us and we add it back to your Balance. This process can take up to 30 days from the post date.
2706
+ */
2707
+ status: 'succeeded' | 'pending' | 'failed';
2708
+ /**
2709
+ * The ISO 8601 datetime at which the Refund was updated
2710
+ */
2711
+ updated_at: string;
2712
+ }
2713
+ interface CreateRefund {
2714
+ /**
2715
+ * This amount that will be refunded to the customer's card.
2716
+ */
2717
+ amount: string;
2718
+ /**
2719
+ * The currency of the amount, as an ISO 4217 currency code.
2720
+ * It must match the Payment Intent currency.
2721
+ */
2722
+ currency: string;
2723
+ /**
2724
+ * Duffel's unique identifier for the Payment Intent that the Refund is for
2725
+ */
2726
+ payment_intent_id: string;
2727
+ }
2728
+
2729
+ declare class Refunds extends Resource {
2730
+ /**
2731
+ * Endpoint path
2732
+ */
2733
+ path: string;
2734
+ constructor(args: any);
2735
+ /**
2736
+ * You should use this API to get the complete, up-to-date information about a Refund.
2737
+ * @param {string} id - Duffel's unique identifier for the Refund
2738
+ * @link https://duffel.com/docs/api/refunds/get-refund-by-id
2739
+ */
2740
+ get: (id: string) => Promise<DuffelResponse<Refund>>;
2741
+ /**
2742
+ * Create a Refund to refund some money to a customer that they paid using a Payment Intent. You must specify the amount and currency. The currency is currently limited to the currency in which the Payment Intent was made.
2743
+ * @param {Object.<CreateFund>} params - Endpoint params (amount, currency and payment_intent_id)
2744
+ */
2745
+ create: (params: CreateRefund) => Promise<DuffelResponse<Refund>>;
2746
+ }
2747
+
2658
2748
  interface DuffelAPIClient {
2659
2749
  aircraft: Aircraft;
2660
2750
  airlines: Airlines;
@@ -2685,6 +2775,7 @@ declare class Duffel {
2685
2775
  seatMaps: SeatMaps;
2686
2776
  paymentIntents: PaymentIntents;
2687
2777
  suggestions: Suggestions;
2778
+ refunds: Refunds;
2688
2779
  constructor(config: Config);
2689
2780
  }
2690
2781
  declare const DuffelError: typeof DuffelError$1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duffel/api",
3
- "version": "1.13.1",
3
+ "version": "1.14.2",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -52,17 +52,17 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@types/node": "^17.0.21",
55
- "@types/node-fetch": "^2.6.1",
56
- "node-fetch": "3.2.8"
55
+ "@types/node-fetch": "^2.6.2",
56
+ "node-fetch": "2.6.7"
57
57
  },
58
58
  "devDependencies": {
59
- "@babel/core": "7.18.6",
60
- "@babel/preset-env": "7.18.6",
59
+ "@babel/core": "7.18.10",
60
+ "@babel/preset-env": "7.18.10",
61
61
  "@babel/preset-typescript": "7.18.6",
62
62
  "@commitlint/cli": "17.0.3",
63
63
  "@commitlint/config-angular": "17.0.3",
64
64
  "@commitlint/cz-commitlint": "17.0.3",
65
- "@rollup/plugin-commonjs": "22.0.1",
65
+ "@rollup/plugin-commonjs": "22.0.2",
66
66
  "@rollup/plugin-multi-entry": "4.1.0",
67
67
  "@rollup/plugin-node-resolve": "13.3.0",
68
68
  "@types/jest": "28.1.6",
@@ -77,7 +77,7 @@
77
77
  "husky": "8.0.1",
78
78
  "jest": "28.1.3",
79
79
  "lint-staged": "13.0.3",
80
- "nock": "13.2.8",
80
+ "nock": "13.2.9",
81
81
  "prettier": "2.7.1",
82
82
  "rollup": "2.76.0",
83
83
  "rollup-plugin-dts": "4.2.2",
@@ -85,7 +85,7 @@
85
85
  "rollup-plugin-peer-deps-external": "2.2.4",
86
86
  "rollup-plugin-terser": "7.0.2",
87
87
  "rollup-plugin-typescript2": "0.32.1",
88
- "ts-jest": "28.0.6",
88
+ "ts-jest": "28.0.7",
89
89
  "ts-node": "10.9.1",
90
90
  "typescript": "4.7.4"
91
91
  },