@duffel/api 2.5.3 → 2.5.5
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.
- package/dist/DuffelPayments/PaymentIntents/PaymentIntents.d.ts +28 -28
- package/dist/DuffelPayments/PaymentIntents/PaymentIntents.spec.d.ts +1 -1
- package/dist/DuffelPayments/PaymentIntents/PaymentIntentsType.d.ts +112 -112
- package/dist/DuffelPayments/PaymentIntents/index.d.ts +1 -1
- package/dist/DuffelPayments/Refunds/Refunds.d.ts +21 -21
- package/dist/DuffelPayments/Refunds/Refunds.spec.d.ts +1 -1
- package/dist/DuffelPayments/Refunds/RefundsType.d.ts +70 -70
- package/dist/DuffelPayments/Refunds/index.d.ts +1 -1
- package/dist/DuffelPayments/index.d.ts +1 -1
- package/dist/Links/Sessions/Sessions.d.ts +63 -63
- package/dist/Links/Sessions/Sessions.spec.d.ts +1 -1
- package/dist/Links/Sessions/index.d.ts +1 -1
- package/dist/Links/index.d.ts +1 -1
- package/dist/Places/Suggestions/Suggestions.d.ts +42 -42
- package/dist/Places/Suggestions/Suggestions.spec.d.ts +1 -1
- package/dist/Places/Suggestions/SuggestionsType.d.ts +59 -59
- package/dist/Places/Suggestions/index.d.ts +1 -1
- package/dist/Places/index.d.ts +1 -1
- package/dist/Stays/Bookings/Bookings.d.ts +41 -41
- package/dist/Stays/Bookings/Bookings.spec.d.ts +1 -1
- package/dist/Stays/Bookings/index.d.ts +1 -1
- package/dist/Stays/Quotes/Quotes.d.ts +16 -16
- package/dist/Stays/Quotes/Quotes.spec.d.ts +1 -1
- package/dist/Stays/Quotes/index.d.ts +1 -1
- package/dist/Stays/SearchResults/SearchResults.d.ts +16 -16
- package/dist/Stays/SearchResults/SearchResults.spec.d.ts +1 -1
- package/dist/Stays/SearchResults/index.d.ts +1 -1
- package/dist/Stays/Stays.d.ts +22 -22
- package/dist/Stays/Stays.spec.d.ts +1 -1
- package/dist/Stays/StaysTypes.d.ts +454 -454
- package/dist/booking/AirlineInitiatedChanges/AirlineInitiatedChanges.d.ts +63 -63
- package/dist/booking/AirlineInitiatedChanges/AirlineInitiatedChanges.spec.d.ts +1 -1
- package/dist/booking/AirlineInitiatedChanges/AirlineInitiatedChangesTypes.d.ts +57 -57
- package/dist/booking/AirlineInitiatedChanges/index.d.ts +1 -1
- package/dist/booking/OfferRequests/OfferRequests.d.ts +46 -46
- package/dist/booking/OfferRequests/OfferRequests.spec.d.ts +1 -1
- package/dist/booking/OfferRequests/OfferRequestsTypes.d.ts +240 -240
- package/dist/booking/OfferRequests/index.d.ts +1 -1
- package/dist/booking/Offers/OfferTypes.d.ts +495 -495
- package/dist/booking/Offers/Offers.d.ts +53 -53
- package/dist/booking/Offers/Offers.spec.d.ts +1 -1
- package/dist/booking/Offers/index.d.ts +1 -1
- package/dist/booking/OrderCancellations/OrderCancellations.d.ts +41 -41
- package/dist/booking/OrderCancellations/OrderCancellations.spec.d.ts +1 -1
- package/dist/booking/OrderCancellations/OrderCancellationsTypes.d.ts +53 -53
- package/dist/booking/OrderCancellations/index.d.ts +1 -1
- package/dist/booking/OrderChangeOffers/OrderChangeOfferTypes.d.ts +113 -113
- package/dist/booking/OrderChangeOffers/OrderChangeOffers.d.ts +31 -31
- package/dist/booking/OrderChangeOffers/OrderChangeOffers.spec.d.ts +1 -1
- package/dist/booking/OrderChangeOffers/index.d.ts +1 -1
- package/dist/booking/OrderChangeRequests/OrderChangeRequests.d.ts +29 -29
- package/dist/booking/OrderChangeRequests/OrderChangeRequestsTypes.d.ts +141 -141
- package/dist/booking/OrderChangeRequests/OrderRequestChanges.spec.d.ts +1 -1
- package/dist/booking/OrderChangeRequests/index.d.ts +1 -1
- package/dist/booking/OrderChanges/OrderChanges.d.ts +31 -31
- package/dist/booking/OrderChanges/OrderChanges.spec.d.ts +1 -1
- package/dist/booking/OrderChanges/OrderChangesTypes.d.ts +102 -102
- package/dist/booking/OrderChanges/index.d.ts +1 -1
- package/dist/booking/Orders/Orders.d.ts +52 -52
- package/dist/booking/Orders/Orders.spec.d.ts +1 -1
- package/dist/booking/Orders/OrdersTypes.d.ts +500 -500
- package/dist/booking/Orders/index.d.ts +1 -1
- package/dist/booking/PartialOfferRequests/PartialOfferRequestTypes.d.ts +6 -6
- package/dist/booking/PartialOfferRequests/PartialOfferRequests.d.ts +40 -40
- package/dist/booking/PartialOfferRequests/PartialOfferRequests.spec.d.ts +1 -1
- package/dist/booking/PartialOfferRequests/index.d.ts +1 -1
- package/dist/booking/Payments/Payments.d.ts +16 -16
- package/dist/booking/Payments/Payments.spec.d.ts +1 -1
- package/dist/booking/Payments/PaymentsTypes.d.ts +43 -43
- package/dist/booking/Payments/index.d.ts +1 -1
- package/dist/booking/SeatMaps/SeatMapTypes.d.ts +190 -190
- package/dist/booking/SeatMaps/SeatMaps.d.ts +17 -17
- package/dist/booking/SeatMaps/SeatMaps.spec.d.ts +1 -1
- package/dist/booking/SeatMaps/index.d.ts +1 -1
- package/dist/booking/index.d.ts +11 -11
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/notifications/Webhooks/Webhooks.d.ts +51 -51
- package/dist/notifications/Webhooks/Webhooks.spec.d.ts +1 -1
- package/dist/notifications/Webhooks/WebhooksType.d.ts +113 -113
- package/dist/notifications/Webhooks/index.d.ts +1 -1
- package/dist/notifications/index.d.ts +1 -1
- package/dist/supportingResources/Aircraft/Aircraft.d.ts +30 -30
- package/dist/supportingResources/Aircraft/Aircraft.spec.d.ts +1 -1
- package/dist/supportingResources/Aircraft/AircraftTypes.d.ts +18 -18
- package/dist/supportingResources/Aircraft/index.d.ts +1 -1
- package/dist/supportingResources/Airlines/Airlines.d.ts +29 -29
- package/dist/supportingResources/Airlines/Airlines.spec.d.ts +1 -1
- package/dist/supportingResources/Airlines/AirlinesTypes.d.ts +17 -17
- package/dist/supportingResources/Airlines/index.d.ts +2 -2
- package/dist/supportingResources/Airports/Airports.d.ts +30 -30
- package/dist/supportingResources/Airports/Airports.spec.d.ts +1 -1
- package/dist/supportingResources/Airports/AirportsTypes.d.ts +55 -55
- package/dist/supportingResources/Airports/index.d.ts +2 -2
- package/dist/supportingResources/index.d.ts +3 -3
- package/dist/typings.d.ts +2 -3
- package/package.json +15 -15
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Resource } from '../../Resource';
|
|
2
|
-
import { DuffelResponse, SeatMap } from '../../types';
|
|
3
|
-
export declare class SeatMaps extends Resource {
|
|
4
|
-
/**
|
|
5
|
-
* Endpoint path
|
|
6
|
-
*/
|
|
7
|
-
path: string;
|
|
8
|
-
constructor(args: any);
|
|
9
|
-
/**
|
|
10
|
-
* Gets seat maps by specific parameters. At the moment we only support querying by an offer ID.
|
|
11
|
-
* @param {string} offer_id - Duffel's unique identifier for the offer
|
|
12
|
-
* @link https://duffel.com/docs/api/seat-maps/get-seat-maps
|
|
13
|
-
*/
|
|
14
|
-
get: (params: {
|
|
15
|
-
offer_id: string;
|
|
16
|
-
}) => Promise<DuffelResponse<SeatMap[]>>;
|
|
17
|
-
}
|
|
1
|
+
import { Resource } from '../../Resource';
|
|
2
|
+
import { DuffelResponse, SeatMap } from '../../types';
|
|
3
|
+
export declare class SeatMaps extends Resource {
|
|
4
|
+
/**
|
|
5
|
+
* Endpoint path
|
|
6
|
+
*/
|
|
7
|
+
path: string;
|
|
8
|
+
constructor(args: any);
|
|
9
|
+
/**
|
|
10
|
+
* Gets seat maps by specific parameters. At the moment we only support querying by an offer ID.
|
|
11
|
+
* @param {string} offer_id - Duffel's unique identifier for the offer
|
|
12
|
+
* @link https://duffel.com/docs/api/seat-maps/get-seat-maps
|
|
13
|
+
*/
|
|
14
|
+
get: (params: {
|
|
15
|
+
offer_id: string;
|
|
16
|
+
}) => Promise<DuffelResponse<SeatMap[]>>;
|
|
17
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './SeatMaps';
|
|
1
|
+
export * from './SeatMaps';
|
package/dist/booking/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export * from './AirlineInitiatedChanges';
|
|
2
|
-
export * from './OfferRequests';
|
|
3
|
-
export * from './Offers';
|
|
4
|
-
export * from './OrderCancellations';
|
|
5
|
-
export * from './Orders';
|
|
6
|
-
export * from './OrderChangeRequests';
|
|
7
|
-
export * from './OrderChangeOffers';
|
|
8
|
-
export * from './OrderChanges';
|
|
9
|
-
export * from './Payments';
|
|
10
|
-
export * from './PartialOfferRequests';
|
|
11
|
-
export * from './SeatMaps';
|
|
1
|
+
export * from './AirlineInitiatedChanges';
|
|
2
|
+
export * from './OfferRequests';
|
|
3
|
+
export * from './Offers';
|
|
4
|
+
export * from './OrderCancellations';
|
|
5
|
+
export * from './Orders';
|
|
6
|
+
export * from './OrderChangeRequests';
|
|
7
|
+
export * from './OrderChangeOffers';
|
|
8
|
+
export * from './OrderChanges';
|
|
9
|
+
export * from './Payments';
|
|
10
|
+
export * from './PartialOfferRequests';
|
|
11
|
+
export * from './SeatMaps';
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"node-fetch";import{URL as s,URLSearchParams as e}from"url";function i(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function h(t,s,e,i){return new(e||(e=Promise))((function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e((function(t){t(s)}))).then(a,n)}o((i=i.apply(t,s||[])).next())}))}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}function o(t,s){try{(e=h[t](s)).value instanceof r?Promise.resolve(e.value.v).then(u,c):d(a[0][2],e)}catch(t){d(a[0][3],t)}var e}function u(t){o("next",t)}function c(t){o("throw",t)}function d(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"2.5.2"};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:s,data:e,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:i})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class u extends n{constructor(t){super(t),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})})),this.path="air/airline_initiated_changes"}}class c extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:s}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class d extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.path="air/offers"}}class p extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class f extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class v extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})})),this.path="air/order_changes"}}class q extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let T=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class y{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:r,data:a,params:n,compress:o=!0})=>h(this,void 0,void 0,(function*(){var h,u;let c,d;const p=new s(r,this.basePath),f={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=new e;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([s,e])=>{Array.isArray(e)?e.forEach((e=>t.append(s,e.toString()))):t.append(s,e.toString())})),p.search=t.toString()}a&&(c=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",p.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const l=yield t(p.href,{method:i,headers:f,body:c,compress:o});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const v=l.headers.get("content-type");if(d=v&&v.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in d&&d.errors)throw new T(Object.assign(Object.assign({},d),{headers:l.headers}));return Object.assign(Object.assign({},d),{headers:l.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v1",this.debug=n,this.source=o}paginatedRequest({path:t,params:s}){return a(this,arguments,(function*(){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield r({data:t})}}))}}class O extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class E extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class w extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class _ extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class P extends n{constructor(t){super(t),this.redeliver=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>h(this,void 0,void 0,(function*(){var s=i(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})})),this.delete=t=>h(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:s,events:e,url:i})=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:i}})})),this.list=t=>h(this,void 0,void 0,(function*(){var s=i(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})})),this.create=({events:t,url:s})=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class x extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.cancel=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})})),this.path="stays/bookings"}}class S extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})})),this.path="stays/quotes"}}class j extends n{constructor(t){super(t),this.fetchAllRates=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/fetch_all_rates`})})),this.path="stays/search_results"}}class R extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.searchResults=new j(t),this.quotes=new S(t),this.bookings=new x(t)}}class k{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new _(this.client),this.offerRequests=new c(this.client),this.offers=new d(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new v(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new p(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new w(this.client),this.refunds=new G(this.client),this.webhooks=new P(this.client),this.stays=new R(this.client)}}const A=T;export{k as Duffel,A as DuffelError};
|
|
1
|
+
import t from"node-fetch";import{URL as s,URLSearchParams as e}from"url";function i(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function h(t,s,e,i){return new(e||(e=Promise))((function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e((function(t){t(s)}))).then(a,n)}o((i=i.apply(t,s||[])).next())}))}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}function o(t,s){try{(e=h[t](s)).value instanceof r?Promise.resolve(e.value.v).then(u,d):c(a[0][2],e)}catch(t){c(a[0][3],t)}var e}function u(t){o("next",t)}function d(t){o("throw",t)}function c(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"2.5.4"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}(),"function"==typeof SuppressedError&&SuppressedError;class n{constructor(t){this.request=({method:t,path:s,data:e,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:i})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class u extends n{constructor(t){super(t),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})})),this.path="air/airline_initiated_changes"}}class d extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:s}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class c extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.path="air/offers"}}class p extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class f extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class v extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})})),this.path="air/order_changes"}}class q extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let T=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class y{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:r,data:a,params:n,compress:o=!0})=>h(this,void 0,void 0,(function*(){var h,u;let d,c;const p=new s(r,this.basePath),f={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=new e;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([s,e])=>{Array.isArray(e)?e.forEach((e=>t.append(s,e.toString()))):t.append(s,e.toString())})),p.search=t.toString()}a&&(d=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",p.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const l=yield t(p.href,{method:i,headers:f,body:d,compress:o});(null===(u=this.debug)||void 0===u?void 0:u.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const v=l.headers.get("content-type");if(c=v&&v.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in c&&c.errors)throw new T(Object.assign(Object.assign({},c),{headers:l.headers}));return Object.assign(Object.assign({},c),{headers:l.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v1",this.debug=n,this.source=o}paginatedRequest({path:t,params:s}){return a(this,arguments,(function*(){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield r({data:t})}}))}}class O extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class E extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class b extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class w extends n{constructor(t){super(t),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class _ extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class P extends n{constructor(t){super(t),this.redeliver=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>h(this,void 0,void 0,(function*(){var s=i(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})})),this.delete=t=>h(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:s,events:e,url:i})=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:i}})})),this.list=t=>h(this,void 0,void 0,(function*(){var s=i(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})})),this.create=({events:t,url:s})=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class S extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=()=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.cancel=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})})),this.path="stays/bookings"}}class x extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})})),this.path="stays/quotes"}}class j extends n{constructor(t){super(t),this.fetchAllRates=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/fetch_all_rates`})})),this.path="stays/search_results"}}class R extends n{constructor(t){super(t),this.search=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.searchResults=new j(t),this.quotes=new x(t),this.bookings=new S(t)}}class k{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new E(this.client),this.airports=new b(this.client),this.airlineInitiatedChanges=new u(this.client),this.links=new _(this.client),this.offerRequests=new d(this.client),this.offers=new c(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new v(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new p(this.client),this.payments=new q(this.client),this.seatMaps=new $(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new w(this.client),this.refunds=new G(this.client),this.webhooks=new P(this.client),this.stays=new R(this.client)}}const A=T;export{k as Duffel,A as DuffelError};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("node-fetch"),s=require("url");function e(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function i(t,s,e,i){return new(e||(e=Promise))((function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e((function(t){t(s)}))).then(a,n)}o((i=i.apply(t,s||[])).next())}))}function h(t){return this instanceof h?(this.v=t,this):new h(t)}function r(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}function o(t,s){try{(e=r[t](s)).value instanceof h?Promise.resolve(e.value.v).then(u,c):d(a[0][2],e)}catch(t){d(a[0][3],t)}var e}function u(t){o("next",t)}function c(t){o("throw",t)}function d(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"2.5.2"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class a{constructor(t){this.request=({method:t,path:s,data:e,params:h})=>i(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:h})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class n extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class o extends a{constructor(t){super(t),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})})),this.path="air/airline_initiated_changes"}}class u extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>i(this,void 0,void 0,(function*(){const{return_offers:s}=t,i=e(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class c extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,i=e(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,i=e(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.update=(t,s,e)=>i(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.path="air/offers"}}class d extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class p extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class f extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class l extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class v extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})})),this.path="air/order_changes"}}class m extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class q extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class g extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let $=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class T{constructor({token:e,basePath:h,apiVersion:r,debug:a,source:n}){this.request=({method:e,path:h,data:r,params:a,compress:n=!0})=>i(this,void 0,void 0,(function*(){var i,o;let u,c;const d=new s.URL(h,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new s.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([s,e])=>{Array.isArray(e)?e.forEach((e=>t.append(s,e.toString()))):t.append(s,e.toString())})),d.search=t.toString()}r&&(u=JSON.stringify({data:Object.assign({},r)})),(null===(i=this.debug)||void 0===i?void 0:i.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",e),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const f=yield t(d.href,{method:e,headers:p,body:u,compress:n});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const l=f.headers.get("content-type");if(c=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in c&&c.errors)throw new $(Object.assign(Object.assign({},c),{headers:f.headers}));return Object.assign(Object.assign({},c),{headers:f.headers})})),this.token=e,this.basePath=h||"https://api.duffel.com",this.apiVersion=r||"v1",this.debug=a,this.source=n}paginatedRequest({path:t,params:s}){return r(this,arguments,(function*(){let e=yield h(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield h({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield h(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield h({data:t})}}))}}class y extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class O extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class E extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class b extends a{constructor(t){super(t),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class w extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class G extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class _ extends a{constructor(t){super(t),this.redeliver=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})})),this.delete=t=>i(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:s,events:e,url:h})=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:h}})})),this.list=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})})),this.create=({events:t,url:s})=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class P extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.cancel=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})})),this.path="stays/bookings"}}class x extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})})),this.path="stays/quotes"}}class S extends a{constructor(t){super(t),this.fetchAllRates=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/fetch_all_rates`})})),this.path="stays/search_results"}}class j extends a{constructor(t){super(t),this.search=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.searchResults=new S(t),this.quotes=new x(t),this.bookings=new P(t)}}const R=$;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new y(this.client),this.airlines=new O(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new G(this.client),this.offerRequests=new u(this.client),this.offers=new c(this.client),this.orders=new p(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new m(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new n(this.client),this.partialOfferRequests=new q(this.client),this.suggestions=new b(this.client),this.refunds=new w(this.client),this.webhooks=new _(this.client),this.stays=new j(this.client)}},exports.DuffelError=R;
|
|
1
|
+
"use strict";var t=require("node-fetch"),s=require("url");function e(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function i(t,s,e,i){return new(e||(e=Promise))((function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e((function(t){t(s)}))).then(a,n)}o((i=i.apply(t,s||[])).next())}))}function h(t){return this instanceof h?(this.v=t,this):new h(t)}function r(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}function o(t,s){try{(e=r[t](s)).value instanceof h?Promise.resolve(e.value.v).then(u,c):d(a[0][2],e)}catch(t){d(a[0][3],t)}var e}function u(t){o("next",t)}function c(t){o("throw",t)}function d(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"2.5.4"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}(),"function"==typeof SuppressedError&&SuppressedError;class a{constructor(t){this.request=({method:t,path:s,data:e,params:h})=>i(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:h})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class n extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class o extends a{constructor(t){super(t),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})})),this.path="air/airline_initiated_changes"}}class u extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>i(this,void 0,void 0,(function*(){const{return_offers:s}=t,i=e(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:i,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class c extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,i=e(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,i=e(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},i),{offer_request_id:s})})},this.update=(t,s,e)=>i(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.path="air/offers"}}class d extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class p extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class f extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class l extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class v extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})})),this.path="air/order_changes"}}class m extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class q extends a{constructor(t){super(t),this.get=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class g extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}let $=class extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}};class T{constructor({token:e,basePath:h,apiVersion:r,debug:a,source:n}){this.request=({method:e,path:h,data:r,params:a,compress:n=!0})=>i(this,void 0,void 0,(function*(){var i,o;let u,c;const d=new s.URL(h,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new s.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([s,e])=>{Array.isArray(e)?e.forEach((e=>t.append(s,e.toString()))):t.append(s,e.toString())})),d.search=t.toString()}r&&(u=JSON.stringify({data:Object.assign({},r)})),(null===(i=this.debug)||void 0===i?void 0:i.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",e),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const f=yield t(d.href,{method:e,headers:p,body:u,compress:n});(null===(o=this.debug)||void 0===o?void 0:o.verbose)&&f.headers.get("x-request-id")&&console.info("Request ID: ",f.headers.get("x-request-id"));const l=f.headers.get("content-type");if(c=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in c&&c.errors)throw new $(Object.assign(Object.assign({},c),{headers:f.headers}));return Object.assign(Object.assign({},c),{headers:f.headers})})),this.token=e,this.basePath=h||"https://api.duffel.com",this.apiVersion=r||"v1",this.debug=a,this.source=n}paginatedRequest({path:t,params:s}){return r(this,arguments,(function*(){let e=yield h(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield h({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield h(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield h({data:t})}}))}}class y extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class O extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class E extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class b extends a{constructor(t){super(t),this.list=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="places/suggestions"}}class w extends a{constructor(t){super(t),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/refunds"}}class G extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class _ extends a{constructor(t){super(t),this.redeliver=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},s)})})),this.delete=t=>i(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:s,events:e,url:h})=>i(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:s,events:e,url:h}})})),this.list=t=>i(this,void 0,void 0,(function*(){var s=e(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},s)})})),this.create=({events:t,url:s})=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:s}})})),this.path="air/webhooks"}}class P extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=()=>i(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path})})),this.cancel=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/cancel`})})),this.path="stays/bookings"}}class S extends a{constructor(t){super(t),this.create=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{rate_id:t}})})),this.path="stays/quotes"}}class x extends a{constructor(t){super(t),this.fetchAllRates=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/fetch_all_rates`})})),this.path="stays/search_results"}}class j extends a{constructor(t){super(t),this.search=t=>i(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/search`,data:t})})),this.path="stays",this.searchResults=new x(t),this.quotes=new S(t),this.bookings=new P(t)}}const R=$;exports.Duffel=class{constructor(t){this.client=new T(t),this.aircraft=new y(this.client),this.airlines=new O(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new o(this.client),this.links=new G(this.client),this.offerRequests=new u(this.client),this.offers=new c(this.client),this.orders=new p(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new m(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new n(this.client),this.partialOfferRequests=new q(this.client),this.suggestions=new b(this.client),this.refunds=new w(this.client),this.webhooks=new _(this.client),this.stays=new j(this.client)}},exports.DuffelError=R;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { DuffelResponse, PaginationMeta, Webhooks as WebhooksType, WebhooksCreateParams, WebhooksCreateResponse, WebhooksListDeliveriesParams, WebhooksListDeliveriesResponse, WebhooksListResponse, WebhooksUpdateParams } from '../../types';
|
|
2
|
-
import { Resource } from '../../Resource';
|
|
3
|
-
import { Client } from '../../Client';
|
|
4
|
-
export declare class Webhooks extends Resource {
|
|
5
|
-
/**
|
|
6
|
-
* Endpoint path
|
|
7
|
-
*/
|
|
8
|
-
path: string;
|
|
9
|
-
constructor(client: Client);
|
|
10
|
-
/**
|
|
11
|
-
* Trigger a re-delivery of an event to a webhook.
|
|
12
|
-
* @param {string} id - Duffel's unique identifier for the webhook event
|
|
13
|
-
* @link https://duffel.com/docs/api/v1/webhooks/schema#webhooks-retry-delivering-a-webhook-event-url-parameters-id
|
|
14
|
-
*/
|
|
15
|
-
redeliver: (id: string) => Promise<DuffelResponse<unknown>>;
|
|
16
|
-
/**
|
|
17
|
-
* Send a ping, a "fake event" notification, to a webhook.
|
|
18
|
-
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
19
|
-
*/
|
|
20
|
-
ping: (id: string) => Promise<DuffelResponse<unknown>>;
|
|
21
|
-
/**
|
|
22
|
-
* Retrieves a webhook event by its ID.
|
|
23
|
-
* @param {string} id- Duffel's unique identifier for the webhook event
|
|
24
|
-
*/
|
|
25
|
-
get: (id: string) => Promise<DuffelResponse<WebhooksType>>;
|
|
26
|
-
/**
|
|
27
|
-
* Retrieve a paginated list of webhook deliveries
|
|
28
|
-
* @param {Object.<WebhooksListDeliveriesParams>} params - Endpoint options
|
|
29
|
-
*/
|
|
30
|
-
listDeliveries: ({ ...params }: WebhooksListDeliveriesParams) => Promise<DuffelResponse<WebhooksListDeliveriesResponse[]>>;
|
|
31
|
-
/**
|
|
32
|
-
* Delete a webhook
|
|
33
|
-
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
34
|
-
*/
|
|
35
|
-
delete: (id: string) => Promise<DuffelResponse<any>>;
|
|
36
|
-
/**
|
|
37
|
-
* Update a webhook
|
|
38
|
-
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
39
|
-
*/
|
|
40
|
-
update: (id: string, { active, events, url }: WebhooksUpdateParams) => Promise<DuffelResponse<any>>;
|
|
41
|
-
/**
|
|
42
|
-
* Retrieve a paginated list of webhook
|
|
43
|
-
* @param {Object.<PaginationMeta>} params - Endpoint options
|
|
44
|
-
*/
|
|
45
|
-
list: ({ ...params }: PaginationMeta) => Promise<DuffelResponse<WebhooksListResponse[]>>;
|
|
46
|
-
/**
|
|
47
|
-
* Create a webhook
|
|
48
|
-
* @param {Object.<WebhooksCreateParams>} params - Endpoint options
|
|
49
|
-
*/
|
|
50
|
-
create: ({ events, url, }: WebhooksCreateParams) => Promise<DuffelResponse<WebhooksCreateResponse>>;
|
|
51
|
-
}
|
|
1
|
+
import { DuffelResponse, PaginationMeta, Webhooks as WebhooksType, WebhooksCreateParams, WebhooksCreateResponse, WebhooksListDeliveriesParams, WebhooksListDeliveriesResponse, WebhooksListResponse, WebhooksUpdateParams } from '../../types';
|
|
2
|
+
import { Resource } from '../../Resource';
|
|
3
|
+
import { Client } from '../../Client';
|
|
4
|
+
export declare class Webhooks extends Resource {
|
|
5
|
+
/**
|
|
6
|
+
* Endpoint path
|
|
7
|
+
*/
|
|
8
|
+
path: string;
|
|
9
|
+
constructor(client: Client);
|
|
10
|
+
/**
|
|
11
|
+
* Trigger a re-delivery of an event to a webhook.
|
|
12
|
+
* @param {string} id - Duffel's unique identifier for the webhook event
|
|
13
|
+
* @link https://duffel.com/docs/api/v1/webhooks/schema#webhooks-retry-delivering-a-webhook-event-url-parameters-id
|
|
14
|
+
*/
|
|
15
|
+
redeliver: (id: string) => Promise<DuffelResponse<unknown>>;
|
|
16
|
+
/**
|
|
17
|
+
* Send a ping, a "fake event" notification, to a webhook.
|
|
18
|
+
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
19
|
+
*/
|
|
20
|
+
ping: (id: string) => Promise<DuffelResponse<unknown>>;
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves a webhook event by its ID.
|
|
23
|
+
* @param {string} id- Duffel's unique identifier for the webhook event
|
|
24
|
+
*/
|
|
25
|
+
get: (id: string) => Promise<DuffelResponse<WebhooksType>>;
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve a paginated list of webhook deliveries
|
|
28
|
+
* @param {Object.<WebhooksListDeliveriesParams>} params - Endpoint options
|
|
29
|
+
*/
|
|
30
|
+
listDeliveries: ({ ...params }: WebhooksListDeliveriesParams) => Promise<DuffelResponse<WebhooksListDeliveriesResponse[]>>;
|
|
31
|
+
/**
|
|
32
|
+
* Delete a webhook
|
|
33
|
+
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
34
|
+
*/
|
|
35
|
+
delete: (id: string) => Promise<DuffelResponse<any>>;
|
|
36
|
+
/**
|
|
37
|
+
* Update a webhook
|
|
38
|
+
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
39
|
+
*/
|
|
40
|
+
update: (id: string, { active, events, url }: WebhooksUpdateParams) => Promise<DuffelResponse<any>>;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieve a paginated list of webhook
|
|
43
|
+
* @param {Object.<PaginationMeta>} params - Endpoint options
|
|
44
|
+
*/
|
|
45
|
+
list: ({ ...params }: PaginationMeta) => Promise<DuffelResponse<WebhooksListResponse[]>>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a webhook
|
|
48
|
+
* @param {Object.<WebhooksCreateParams>} params - Endpoint options
|
|
49
|
+
*/
|
|
50
|
+
create: ({ events, url, }: WebhooksCreateParams) => Promise<DuffelResponse<WebhooksCreateResponse>>;
|
|
51
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import { PaginationMeta } from 'types';
|
|
2
|
-
export interface Webhooks {
|
|
3
|
-
/**
|
|
4
|
-
* Whether the webhook receiver is actively being notified or not
|
|
5
|
-
*/
|
|
6
|
-
active: boolean;
|
|
7
|
-
/**
|
|
8
|
-
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
|
|
9
|
-
*/
|
|
10
|
-
created_at: string;
|
|
11
|
-
/**
|
|
12
|
-
* The events that this webhook will be subscribed to
|
|
13
|
-
*/
|
|
14
|
-
events: string[];
|
|
15
|
-
/**
|
|
16
|
-
* Duffel's unique identifier for the webhook receiver
|
|
17
|
-
*/
|
|
18
|
-
id: string;
|
|
19
|
-
/**
|
|
20
|
-
* The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
|
|
21
|
-
*/
|
|
22
|
-
live_mode: boolean;
|
|
23
|
-
/**
|
|
24
|
-
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the order change was updated
|
|
25
|
-
*/
|
|
26
|
-
updated_at: string;
|
|
27
|
-
/**
|
|
28
|
-
* The URL where your webhook will be received
|
|
29
|
-
*/
|
|
30
|
-
url: string;
|
|
31
|
-
}
|
|
32
|
-
export interface WebhooksListDeliveriesParams extends PaginationMeta {
|
|
33
|
-
delivery_success: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Filters the returned webhook deliveries by creation datetime.
|
|
36
|
-
*/
|
|
37
|
-
created_at?: PaginationMeta;
|
|
38
|
-
/**
|
|
39
|
-
* Filters webhook deliveries by the type of their related webhook event.
|
|
40
|
-
*/
|
|
41
|
-
type?: string;
|
|
42
|
-
/**
|
|
43
|
-
* Filters webhook deliveries by the ID of the related webhook endpoint.
|
|
44
|
-
*/
|
|
45
|
-
endpoint_id: string;
|
|
46
|
-
}
|
|
47
|
-
export interface WebhooksUpdateParams {
|
|
48
|
-
/**
|
|
49
|
-
* The desired active status of the webhook
|
|
50
|
-
*/
|
|
51
|
-
active: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* The desired events that the webhook should subscribe to
|
|
54
|
-
*/
|
|
55
|
-
events: string[];
|
|
56
|
-
/**
|
|
57
|
-
* The desired url of the webhook
|
|
58
|
-
*/
|
|
59
|
-
url: string;
|
|
60
|
-
}
|
|
61
|
-
export interface WebhooksCreateParams {
|
|
62
|
-
/**
|
|
63
|
-
* The desired events that the webhook should subscribe to
|
|
64
|
-
*/
|
|
65
|
-
events: string[];
|
|
66
|
-
/**
|
|
67
|
-
* The desired url of the webhook
|
|
68
|
-
*/
|
|
69
|
-
url: string;
|
|
70
|
-
}
|
|
71
|
-
export interface WebhooksListDeliveriesResponse {
|
|
72
|
-
/**
|
|
73
|
-
* The URL where your webhook will be received
|
|
74
|
-
*/
|
|
75
|
-
url: string;
|
|
76
|
-
endpoint_id: string;
|
|
77
|
-
/**
|
|
78
|
-
* Webhook deliveries will be included if they were successful.
|
|
79
|
-
*/
|
|
80
|
-
delivery_success?: boolean;
|
|
81
|
-
type: string;
|
|
82
|
-
response_status_code: 200;
|
|
83
|
-
response_body: string;
|
|
84
|
-
event_id: string;
|
|
85
|
-
/**
|
|
86
|
-
* The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
|
|
87
|
-
*/
|
|
88
|
-
live_mode: boolean;
|
|
89
|
-
/**
|
|
90
|
-
* Duffel's unique identifier for the webhook receiver
|
|
91
|
-
*/
|
|
92
|
-
id: string;
|
|
93
|
-
/**
|
|
94
|
-
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
|
|
95
|
-
*/
|
|
96
|
-
created_at: string;
|
|
97
|
-
}
|
|
98
|
-
export interface WebhooksListResponse extends Webhooks {
|
|
99
|
-
/**
|
|
100
|
-
* Webhook deliveries will be included if they were successful.
|
|
101
|
-
*/
|
|
102
|
-
delivery_success?: boolean;
|
|
103
|
-
}
|
|
104
|
-
export interface WebhooksCreateResponse {
|
|
105
|
-
secret: string;
|
|
106
|
-
url: string;
|
|
107
|
-
updated_at: string;
|
|
108
|
-
live_mode: boolean;
|
|
109
|
-
id: string;
|
|
110
|
-
events: string[];
|
|
111
|
-
created_at: string;
|
|
112
|
-
active: boolean;
|
|
113
|
-
}
|
|
1
|
+
import { PaginationMeta } from '../../types';
|
|
2
|
+
export interface Webhooks {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the webhook receiver is actively being notified or not
|
|
5
|
+
*/
|
|
6
|
+
active: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
|
|
9
|
+
*/
|
|
10
|
+
created_at: string;
|
|
11
|
+
/**
|
|
12
|
+
* The events that this webhook will be subscribed to
|
|
13
|
+
*/
|
|
14
|
+
events: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Duffel's unique identifier for the webhook receiver
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
|
|
21
|
+
*/
|
|
22
|
+
live_mode: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the order change was updated
|
|
25
|
+
*/
|
|
26
|
+
updated_at: string;
|
|
27
|
+
/**
|
|
28
|
+
* The URL where your webhook will be received
|
|
29
|
+
*/
|
|
30
|
+
url: string;
|
|
31
|
+
}
|
|
32
|
+
export interface WebhooksListDeliveriesParams extends PaginationMeta {
|
|
33
|
+
delivery_success: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Filters the returned webhook deliveries by creation datetime.
|
|
36
|
+
*/
|
|
37
|
+
created_at?: PaginationMeta;
|
|
38
|
+
/**
|
|
39
|
+
* Filters webhook deliveries by the type of their related webhook event.
|
|
40
|
+
*/
|
|
41
|
+
type?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Filters webhook deliveries by the ID of the related webhook endpoint.
|
|
44
|
+
*/
|
|
45
|
+
endpoint_id: string;
|
|
46
|
+
}
|
|
47
|
+
export interface WebhooksUpdateParams {
|
|
48
|
+
/**
|
|
49
|
+
* The desired active status of the webhook
|
|
50
|
+
*/
|
|
51
|
+
active: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The desired events that the webhook should subscribe to
|
|
54
|
+
*/
|
|
55
|
+
events: string[];
|
|
56
|
+
/**
|
|
57
|
+
* The desired url of the webhook
|
|
58
|
+
*/
|
|
59
|
+
url: string;
|
|
60
|
+
}
|
|
61
|
+
export interface WebhooksCreateParams {
|
|
62
|
+
/**
|
|
63
|
+
* The desired events that the webhook should subscribe to
|
|
64
|
+
*/
|
|
65
|
+
events: string[];
|
|
66
|
+
/**
|
|
67
|
+
* The desired url of the webhook
|
|
68
|
+
*/
|
|
69
|
+
url: string;
|
|
70
|
+
}
|
|
71
|
+
export interface WebhooksListDeliveriesResponse {
|
|
72
|
+
/**
|
|
73
|
+
* The URL where your webhook will be received
|
|
74
|
+
*/
|
|
75
|
+
url: string;
|
|
76
|
+
endpoint_id: string;
|
|
77
|
+
/**
|
|
78
|
+
* Webhook deliveries will be included if they were successful.
|
|
79
|
+
*/
|
|
80
|
+
delivery_success?: boolean;
|
|
81
|
+
type: string;
|
|
82
|
+
response_status_code: 200;
|
|
83
|
+
response_body: string;
|
|
84
|
+
event_id: string;
|
|
85
|
+
/**
|
|
86
|
+
* The live mode that the webhook was created in. It will only receive events for that same live mode. For example, you won't receive order.created events for orders that you created in the sandbox, if your webhook is for live_mode: true.
|
|
87
|
+
*/
|
|
88
|
+
live_mode: boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Duffel's unique identifier for the webhook receiver
|
|
91
|
+
*/
|
|
92
|
+
id: string;
|
|
93
|
+
/**
|
|
94
|
+
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
|
|
95
|
+
*/
|
|
96
|
+
created_at: string;
|
|
97
|
+
}
|
|
98
|
+
export interface WebhooksListResponse extends Webhooks {
|
|
99
|
+
/**
|
|
100
|
+
* Webhook deliveries will be included if they were successful.
|
|
101
|
+
*/
|
|
102
|
+
delivery_success?: boolean;
|
|
103
|
+
}
|
|
104
|
+
export interface WebhooksCreateResponse {
|
|
105
|
+
secret: string;
|
|
106
|
+
url: string;
|
|
107
|
+
updated_at: string;
|
|
108
|
+
live_mode: boolean;
|
|
109
|
+
id: string;
|
|
110
|
+
events: string[];
|
|
111
|
+
created_at: string;
|
|
112
|
+
active: boolean;
|
|
113
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Webhooks';
|
|
1
|
+
export * from './Webhooks';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Webhooks';
|
|
1
|
+
export * from './Webhooks';
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Resource } from '../../Resource';
|
|
2
|
-
import { Aircraft as AircraftType, DuffelResponse, PaginationMeta } from '../../types';
|
|
3
|
-
/** Aircraft are used to describe what passengers will fly in for a given trip
|
|
4
|
-
* @class
|
|
5
|
-
* @link https://duffel.com/docs/api/aircraft
|
|
6
|
-
*/
|
|
7
|
-
export declare class Aircraft extends Resource {
|
|
8
|
-
/**
|
|
9
|
-
* Endpoint path
|
|
10
|
-
*/
|
|
11
|
-
path: string;
|
|
12
|
-
constructor(args: any);
|
|
13
|
-
/**
|
|
14
|
-
* Retrieves an aircraft by its ID
|
|
15
|
-
* @param {string} id - Duffel's unique identifier for the aircraft
|
|
16
|
-
* @link https://duffel.com/docs/api/aircraft/get-aircraft-by-id
|
|
17
|
-
*/
|
|
18
|
-
get: (id: string) => Promise<DuffelResponse<AircraftType>>;
|
|
19
|
-
/**
|
|
20
|
-
* Retrieves a page of aircraft. The results may be returned in any order.
|
|
21
|
-
* @param {Object} [options] - Pagination options (optional: limit, after, before)
|
|
22
|
-
* @link https://duffel.com/docs/api/aircraft/get-aircraft
|
|
23
|
-
*/
|
|
24
|
-
list: (options?: PaginationMeta) => Promise<DuffelResponse<AircraftType[]>>;
|
|
25
|
-
/**
|
|
26
|
-
* Retrieves a generator of all aircraft. The results may be returned in any order.
|
|
27
|
-
* @link https://duffel.com/docs/api/aircraft/get-aircraft
|
|
28
|
-
*/
|
|
29
|
-
listWithGenerator: () => AsyncGenerator<DuffelResponse<AircraftType>, void, unknown>;
|
|
30
|
-
}
|
|
1
|
+
import { Resource } from '../../Resource';
|
|
2
|
+
import { Aircraft as AircraftType, DuffelResponse, PaginationMeta } from '../../types';
|
|
3
|
+
/** Aircraft are used to describe what passengers will fly in for a given trip
|
|
4
|
+
* @class
|
|
5
|
+
* @link https://duffel.com/docs/api/aircraft
|
|
6
|
+
*/
|
|
7
|
+
export declare class Aircraft extends Resource {
|
|
8
|
+
/**
|
|
9
|
+
* Endpoint path
|
|
10
|
+
*/
|
|
11
|
+
path: string;
|
|
12
|
+
constructor(args: any);
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves an aircraft by its ID
|
|
15
|
+
* @param {string} id - Duffel's unique identifier for the aircraft
|
|
16
|
+
* @link https://duffel.com/docs/api/aircraft/get-aircraft-by-id
|
|
17
|
+
*/
|
|
18
|
+
get: (id: string) => Promise<DuffelResponse<AircraftType>>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves a page of aircraft. The results may be returned in any order.
|
|
21
|
+
* @param {Object} [options] - Pagination options (optional: limit, after, before)
|
|
22
|
+
* @link https://duffel.com/docs/api/aircraft/get-aircraft
|
|
23
|
+
*/
|
|
24
|
+
list: (options?: PaginationMeta) => Promise<DuffelResponse<AircraftType[]>>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves a generator of all aircraft. The results may be returned in any order.
|
|
27
|
+
* @link https://duffel.com/docs/api/aircraft/get-aircraft
|
|
28
|
+
*/
|
|
29
|
+
listWithGenerator: () => AsyncGenerator<DuffelResponse<AircraftType>, void, unknown>;
|
|
30
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|