@duffel/api 1.27.0 → 1.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/booking/Offers/OfferTypes.d.ts +1 -1
- package/dist/booking/Orders/OrdersTypes.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/notifications/Webhooks/Webhooks.d.ts +51 -0
- package/dist/notifications/Webhooks/Webhooks.spec.d.ts +1 -0
- package/dist/notifications/Webhooks/WebhooksType.d.ts +113 -0
- package/dist/notifications/Webhooks/index.d.ts +1 -0
- package/dist/notifications/index.d.ts +1 -0
- package/dist/types/index.d.ts +168 -5
- package/dist/types/shared.d.ts +2 -2
- package/package.json +8 -8
|
@@ -6,7 +6,7 @@ import { CabinClass, FlightsConditions, LoyaltyProgrammeAccount, PassengerIdenti
|
|
|
6
6
|
export interface Offer {
|
|
7
7
|
/**
|
|
8
8
|
* The types of identity documents that may be provided for the passengers when creating an order based on this offer.
|
|
9
|
-
*
|
|
9
|
+
* If this is `[]`, then you must not provide identity documents.
|
|
10
10
|
*/
|
|
11
11
|
allowed_passenger_identity_document_types: PassengerIdentityDocumentType[];
|
|
12
12
|
/**
|
|
@@ -147,7 +147,7 @@ export interface OrderPassenger {
|
|
|
147
147
|
}
|
|
148
148
|
export interface OrderPassengerIdentityDocument {
|
|
149
149
|
/**
|
|
150
|
-
* The type of the identity document.
|
|
150
|
+
* The type of the identity document. This must be one of the allowed_passenger_identity_document_types on the offer.
|
|
151
151
|
*/
|
|
152
152
|
type: PassengerIdentityDocumentType;
|
|
153
153
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Aircraft, Airlines, Airports } from './supportingResources';
|
|
|
5
5
|
import { Suggestions } from './Places/Suggestions';
|
|
6
6
|
import { Refunds } from './DuffelPayments/Refunds';
|
|
7
7
|
import { Sessions } from './Links';
|
|
8
|
+
import { Webhooks } from './notifications';
|
|
8
9
|
export interface DuffelAPIClient {
|
|
9
10
|
aircraft: Aircraft;
|
|
10
11
|
airlines: Airlines;
|
|
@@ -39,6 +40,7 @@ export declare class Duffel {
|
|
|
39
40
|
partialOfferRequests: PartialOfferRequests;
|
|
40
41
|
suggestions: Suggestions;
|
|
41
42
|
refunds: Refunds;
|
|
43
|
+
webhooks: Webhooks;
|
|
42
44
|
constructor(config: Config);
|
|
43
45
|
}
|
|
44
46
|
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 h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)e.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(s[i[h]]=t[i[h]])}return s}function h(t,e,s,i){return new(s||(s=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 e;t.done?h(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 r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[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=h[t](e)).value instanceof r?Promise.resolve(s.value.v).then(c,u):p(a[0][2],s)}catch(t){p(a[0][3],t)}var s}function c(t){o("next",t)}function u(t){o("throw",t)}function p(t,e){t(e),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.26.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})=>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 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 c extends n{constructor(t){super(t),this.update=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:e}})})),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 u 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: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 p extends n{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=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)=>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 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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),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 m extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class v 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,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 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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),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"}}class T extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}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,c;let u,p;const d=new e(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 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())})),d.search=t.toString()}a&&(u=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const l=yield t(d.href,{method:i,headers:f,body:u,compress:o});(null===(c=this.debug)||void 0===c?void 0:c.verbose)&&l.headers.get("x-request-id")&&console.info("Request ID: ",l.headers.get("x-request-id"));const m=l.headers.get("content-type");if(p=m&&m.includes("json")?yield l.json():yield l.text(),!l.ok||"errors"in p&&p.errors)throw new T(Object.assign(Object.assign({},p),{headers:l.headers}));return Object.assign(Object.assign({},p),{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:e}){return a(this,arguments,(function*(){let s=yield r(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield r({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield r(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.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 _ 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 G 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 w 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 E extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="links/sessions"}}class x{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new b(this.client),this.airports=new _(this.client),this.airlineInitiatedChanges=new c(this.client),this.links=new E(this.client),this.offerRequests=new u(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 $(this.client),this.paymentIntents=new o(this.client),this.partialOfferRequests=new g(this.client),this.suggestions=new G(this.client),this.refunds=new w(this.client)}}const P=T;export{x as Duffel,P 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 h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)e.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(s[i[h]]=t[i[h]])}return s}function h(t,e,s,i){return new(s||(s=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 e;t.done?h(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 r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[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=h[t](e)).value instanceof r?Promise.resolve(s.value.v).then(u,d):c(a[0][2],s)}catch(t){c(a[0][3],t)}var s}function u(t){o("next",t)}function d(t){o("throw",t)}function c(t,e){t(e),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.28.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})=>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 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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:e}})})),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: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)=>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=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)=>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 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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),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,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 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,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),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"}}class T extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}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 e(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 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())})),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:e}){return a(this,arguments,(function*(){let s=yield r(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield r({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield r(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.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 G 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 w 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 e=i(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},e)})})),this.delete=t=>h(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:e,events:s,url:i})=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:e,events:s,url:i}})})),this.list=t=>h(this,void 0,void 0,(function*(){var e=i(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},e)})})),this.create=({events:t,url:e})=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:e}})})),this.path="air/webhooks"}}class x{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 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 G(this.client),this.refunds=new w(this.client),this.webhooks=new P(this.client)}}const S=T;export{x as Duffel,S as DuffelError};
|
|
2
2
|
//# sourceMappingURL=index.es.js.map
|
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 h(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 h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)e.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(s[i[h]]=t[i[h]])}return s}function r(t,e,s,i){return new(s||(s=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 e;t.done?h(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,h=s.apply(t,e||[]),r=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(e){return new Promise((function(s,i){r.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=h[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):d(r[0][2],s)}catch(t){d(r[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function d(t,e){t(e),r.shift(),r.length&&o(r[0][0],r[0][1])}}!function(){const t={npm_package_version:"1.26.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})=>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 u extends o{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 c extends o{constructor(t){super(t),this.update=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:e}})})),this.accept=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>r(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 o{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=h(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)=>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=h(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=h(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 f extends o{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 l extends o{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.getAvailableServices=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),this.path="air/orders"}}class v extends o{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 m extends o{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 q extends o{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 g extends o{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 $ extends o{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.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),this.path="air/partial_offer_requests"}}class T extends o{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 y extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}class O{constructor({token:t,basePath:s,apiVersion:h,debug:a,source:n}){this.request=({method:t,path:s,data:h,params:a,compress:n=!0})=>r(this,void 0,void 0,(function*(){var r,o;let u,c;const d=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())})),d.search=t.toString()}h&&(u=JSON.stringify({data:Object.assign({},h)})),(null===(r=this.debug)||void 0===r?void 0:r.verbose)&&(console.info("Endpoint: ",d.href),console.info("Method: ",t),h&&console.info("Body Parameters: ",h),a&&console.info("Query Parameters: ",a));const f=yield i.default(d.href,{method:t,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 y(Object.assign(Object.assign({},c),{headers:f.headers}));return Object.assign(Object.assign({},c),{headers:f.headers})})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=h||"v1",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 b extends o{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 _ extends o{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 E extends o{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 o{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 w extends o{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 x extends o{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="links/sessions"}}const P=y;exports.Duffel=class{constructor(t){this.client=new O(t),this.aircraft=new b(this.client),this.airlines=new _(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new c(this.client),this.links=new x(this.client),this.offerRequests=new d(this.client),this.offers=new p(this.client),this.orders=new l(this.client),this.orderChangeRequests=new v(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new q(this.client),this.orderCancellations=new f(this.client),this.payments=new g(this.client),this.seatMaps=new T(this.client),this.paymentIntents=new u(this.client),this.partialOfferRequests=new $(this.client),this.suggestions=new G(this.client),this.refunds=new w(this.client)}},exports.DuffelError=P;
|
|
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 h(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 h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)e.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(s[i[h]]=t[i[h]])}return s}function r(t,e,s,i){return new(s||(s=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 e;t.done?h(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,h=s.apply(t,e||[]),r=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(e){return new Promise((function(s,i){r.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=h[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,d):c(r[0][2],s)}catch(t){c(r[0][3],t)}var s}function u(t){o("next",t)}function d(t){o("throw",t)}function c(t,e){t(e),r.shift(),r.length&&o(r[0][0],r[0][1])}}!function(){const t={npm_package_version:"1.28.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})=>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 u extends o{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 d extends o{constructor(t){super(t),this.update=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:e}})})),this.accept=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>r(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 o{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=h(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)=>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=h(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=h(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 f extends o{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 l extends o{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.getAvailableServices=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:e})})),this.path="air/orders"}}class v extends o{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 m extends o{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 q extends o{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 g extends o{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 $ extends o{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.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:e})})),this.path="air/partial_offer_requests"}}class T extends o{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 y extends Error{constructor({meta:t,errors:e,headers:s}){super(),this.meta=t,this.errors=e,this.headers=s}}class O{constructor({token:t,basePath:s,apiVersion:h,debug:a,source:n}){this.request=({method:t,path:s,data:h,params:a,compress:n=!0})=>r(this,void 0,void 0,(function*(){var r,o;let u,d;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()}h&&(u=JSON.stringify({data:Object.assign({},h)})),(null===(r=this.debug)||void 0===r?void 0:r.verbose)&&(console.info("Endpoint: ",c.href),console.info("Method: ",t),h&&console.info("Body Parameters: ",h),a&&console.info("Query Parameters: ",a));const f=yield i.default(c.href,{method:t,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(d=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in d&&d.errors)throw new y(Object.assign(Object.assign({},d),{headers:f.headers}));return Object.assign(Object.assign({},d),{headers:f.headers})})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=h||"v1",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 b extends o{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 E extends o{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 G extends o{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 _ extends o{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 w extends o{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 P extends o{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="links/sessions"}}class x extends o{constructor(t){super(t),this.redeliver=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/events/${t}/actions/redeliver`})})),this.ping=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/ping`})})),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/events/${t}`})})),this.listDeliveries=t=>r(this,void 0,void 0,(function*(){var e=h(t,[]);return this.request({method:"GET",path:`${this.path}/deliveries`,params:Object.assign({},e)})})),this.delete=t=>r(this,void 0,void 0,(function*(){return this.request({method:"DELETE",path:`${this.path}/${t}`})})),this.update=(t,{active:e,events:s,url:i})=>r(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{active:e,events:s,url:i}})})),this.list=t=>r(this,void 0,void 0,(function*(){var e=h(t,[]);return this.request({method:"GET",path:this.path,params:Object.assign({},e)})})),this.create=({events:t,url:e})=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:{events:t,url:e}})})),this.path="air/webhooks"}}const S=y;exports.Duffel=class{constructor(t){this.client=new O(t),this.aircraft=new b(this.client),this.airlines=new E(this.client),this.airports=new G(this.client),this.airlineInitiatedChanges=new d(this.client),this.links=new P(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new l(this.client),this.orderChangeRequests=new v(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new q(this.client),this.orderCancellations=new f(this.client),this.payments=new g(this.client),this.seatMaps=new T(this.client),this.paymentIntents=new u(this.client),this.partialOfferRequests=new $(this.client),this.suggestions=new _(this.client),this.refunds=new w(this.client),this.webhooks=new x(this.client)}},exports.DuffelError=S;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Webhooks';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Webhooks';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ interface AirlineInitiatedChange {
|
|
|
64
64
|
interface Offer {
|
|
65
65
|
/**
|
|
66
66
|
* The types of identity documents that may be provided for the passengers when creating an order based on this offer.
|
|
67
|
-
*
|
|
67
|
+
* If this is `[]`, then you must not provide identity documents.
|
|
68
68
|
*/
|
|
69
69
|
allowed_passenger_identity_document_types: PassengerIdentityDocumentType[];
|
|
70
70
|
/**
|
|
@@ -1350,7 +1350,7 @@ interface OrderPassenger {
|
|
|
1350
1350
|
}
|
|
1351
1351
|
interface OrderPassengerIdentityDocument {
|
|
1352
1352
|
/**
|
|
1353
|
-
* The type of the identity document.
|
|
1353
|
+
* The type of the identity document. This must be one of the allowed_passenger_identity_document_types on the offer.
|
|
1354
1354
|
*/
|
|
1355
1355
|
type: PassengerIdentityDocumentType;
|
|
1356
1356
|
/**
|
|
@@ -2270,10 +2270,10 @@ declare type DuffelPassengerTitle = 'mr' | 'ms' | 'mrs' | 'MR' | 'MS' | 'MRS';
|
|
|
2270
2270
|
*/
|
|
2271
2271
|
declare type DuffelPassengerGender = 'm' | 'f';
|
|
2272
2272
|
/**
|
|
2273
|
-
* The type of the identity document.
|
|
2273
|
+
* The type of the identity document.
|
|
2274
2274
|
* This must be one of the `allowed_passenger_identity_document_types` on the offer.
|
|
2275
2275
|
*/
|
|
2276
|
-
declare type PassengerIdentityDocumentType = 'passport';
|
|
2276
|
+
declare type PassengerIdentityDocumentType = 'passport' | 'tax_id';
|
|
2277
2277
|
/**
|
|
2278
2278
|
* The type of the origin or destination
|
|
2279
2279
|
*/
|
|
@@ -2433,6 +2433,119 @@ interface SDKOptions {
|
|
|
2433
2433
|
verbose?: boolean;
|
|
2434
2434
|
}
|
|
2435
2435
|
|
|
2436
|
+
interface Webhooks$1 {
|
|
2437
|
+
/**
|
|
2438
|
+
* Whether the webhook receiver is actively being notified or not
|
|
2439
|
+
*/
|
|
2440
|
+
active: boolean;
|
|
2441
|
+
/**
|
|
2442
|
+
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
|
|
2443
|
+
*/
|
|
2444
|
+
created_at: string;
|
|
2445
|
+
/**
|
|
2446
|
+
* The events that this webhook will be subscribed to
|
|
2447
|
+
*/
|
|
2448
|
+
events: string[];
|
|
2449
|
+
/**
|
|
2450
|
+
* Duffel's unique identifier for the webhook receiver
|
|
2451
|
+
*/
|
|
2452
|
+
id: string;
|
|
2453
|
+
/**
|
|
2454
|
+
* 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.
|
|
2455
|
+
*/
|
|
2456
|
+
live_mode: boolean;
|
|
2457
|
+
/**
|
|
2458
|
+
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the order change was updated
|
|
2459
|
+
*/
|
|
2460
|
+
updated_at: string;
|
|
2461
|
+
/**
|
|
2462
|
+
* The URL where your webhook will be received
|
|
2463
|
+
*/
|
|
2464
|
+
url: string;
|
|
2465
|
+
}
|
|
2466
|
+
interface WebhooksListDeliveriesParams extends PaginationMeta {
|
|
2467
|
+
delivery_success: boolean;
|
|
2468
|
+
/**
|
|
2469
|
+
* Filters the returned webhook deliveries by creation datetime.
|
|
2470
|
+
*/
|
|
2471
|
+
created_at?: PaginationMeta;
|
|
2472
|
+
/**
|
|
2473
|
+
* Filters webhook deliveries by the type of their related webhook event.
|
|
2474
|
+
*/
|
|
2475
|
+
type?: string;
|
|
2476
|
+
/**
|
|
2477
|
+
* Filters webhook deliveries by the ID of the related webhook endpoint.
|
|
2478
|
+
*/
|
|
2479
|
+
endpoint_id: string;
|
|
2480
|
+
}
|
|
2481
|
+
interface WebhooksUpdateParams {
|
|
2482
|
+
/**
|
|
2483
|
+
* The desired active status of the webhook
|
|
2484
|
+
*/
|
|
2485
|
+
active: boolean;
|
|
2486
|
+
/**
|
|
2487
|
+
* The desired events that the webhook should subscribe to
|
|
2488
|
+
*/
|
|
2489
|
+
events: string[];
|
|
2490
|
+
/**
|
|
2491
|
+
* The desired url of the webhook
|
|
2492
|
+
*/
|
|
2493
|
+
url: string;
|
|
2494
|
+
}
|
|
2495
|
+
interface WebhooksCreateParams {
|
|
2496
|
+
/**
|
|
2497
|
+
* The desired events that the webhook should subscribe to
|
|
2498
|
+
*/
|
|
2499
|
+
events: string[];
|
|
2500
|
+
/**
|
|
2501
|
+
* The desired url of the webhook
|
|
2502
|
+
*/
|
|
2503
|
+
url: string;
|
|
2504
|
+
}
|
|
2505
|
+
interface WebhooksListDeliveriesResponse {
|
|
2506
|
+
/**
|
|
2507
|
+
* The URL where your webhook will be received
|
|
2508
|
+
*/
|
|
2509
|
+
url: string;
|
|
2510
|
+
endpoint_id: string;
|
|
2511
|
+
/**
|
|
2512
|
+
* Webhook deliveries will be included if they were successful.
|
|
2513
|
+
*/
|
|
2514
|
+
delivery_success?: boolean;
|
|
2515
|
+
type: string;
|
|
2516
|
+
response_status_code: 200;
|
|
2517
|
+
response_body: string;
|
|
2518
|
+
event_id: string;
|
|
2519
|
+
/**
|
|
2520
|
+
* 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.
|
|
2521
|
+
*/
|
|
2522
|
+
live_mode: boolean;
|
|
2523
|
+
/**
|
|
2524
|
+
* Duffel's unique identifier for the webhook receiver
|
|
2525
|
+
*/
|
|
2526
|
+
id: string;
|
|
2527
|
+
/**
|
|
2528
|
+
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the webhook was created
|
|
2529
|
+
*/
|
|
2530
|
+
created_at: string;
|
|
2531
|
+
}
|
|
2532
|
+
interface WebhooksListResponse extends Webhooks$1 {
|
|
2533
|
+
/**
|
|
2534
|
+
* Webhook deliveries will be included if they were successful.
|
|
2535
|
+
*/
|
|
2536
|
+
delivery_success?: boolean;
|
|
2537
|
+
}
|
|
2538
|
+
interface WebhooksCreateResponse {
|
|
2539
|
+
secret: string;
|
|
2540
|
+
url: string;
|
|
2541
|
+
updated_at: string;
|
|
2542
|
+
live_mode: boolean;
|
|
2543
|
+
id: string;
|
|
2544
|
+
events: string[];
|
|
2545
|
+
created_at: string;
|
|
2546
|
+
active: boolean;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2436
2549
|
interface Config {
|
|
2437
2550
|
token: string;
|
|
2438
2551
|
basePath?: string;
|
|
@@ -3177,6 +3290,55 @@ declare class Sessions extends Resource {
|
|
|
3177
3290
|
create: (data: SessionParameters) => Promise<DuffelResponse<Session>>;
|
|
3178
3291
|
}
|
|
3179
3292
|
|
|
3293
|
+
declare class Webhooks extends Resource {
|
|
3294
|
+
/**
|
|
3295
|
+
* Endpoint path
|
|
3296
|
+
*/
|
|
3297
|
+
path: string;
|
|
3298
|
+
constructor(client: Client);
|
|
3299
|
+
/**
|
|
3300
|
+
* Trigger a re-delivery of an event to a webhook.
|
|
3301
|
+
* @param {string} id - Duffel's unique identifier for the webhook event
|
|
3302
|
+
* @link https://duffel.com/docs/api/v1/webhooks/schema#webhooks-retry-delivering-a-webhook-event-url-parameters-id
|
|
3303
|
+
*/
|
|
3304
|
+
redeliver: (id: string) => Promise<DuffelResponse<unknown>>;
|
|
3305
|
+
/**
|
|
3306
|
+
* Send a ping, a "fake event" notification, to a webhook.
|
|
3307
|
+
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
3308
|
+
*/
|
|
3309
|
+
ping: (id: string) => Promise<DuffelResponse<unknown>>;
|
|
3310
|
+
/**
|
|
3311
|
+
* Retrieves a webhook event by its ID.
|
|
3312
|
+
* @param {string} id- Duffel's unique identifier for the webhook event
|
|
3313
|
+
*/
|
|
3314
|
+
get: (id: string) => Promise<DuffelResponse<Webhooks$1>>;
|
|
3315
|
+
/**
|
|
3316
|
+
* Retrieve a paginated list of webhook deliveries
|
|
3317
|
+
* @param {Object.<WebhooksListDeliveriesParams>} params - Endpoint options
|
|
3318
|
+
*/
|
|
3319
|
+
listDeliveries: ({ ...params }: WebhooksListDeliveriesParams) => Promise<DuffelResponse<WebhooksListDeliveriesResponse[]>>;
|
|
3320
|
+
/**
|
|
3321
|
+
* Delete a webhook
|
|
3322
|
+
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
3323
|
+
*/
|
|
3324
|
+
delete: (id: string) => Promise<DuffelResponse<any>>;
|
|
3325
|
+
/**
|
|
3326
|
+
* Update a webhook
|
|
3327
|
+
* @param {string} id - Duffel's unique identifier for the webhook receiver
|
|
3328
|
+
*/
|
|
3329
|
+
update: (id: string, { active, events, url }: WebhooksUpdateParams) => Promise<DuffelResponse<any>>;
|
|
3330
|
+
/**
|
|
3331
|
+
* Retrieve a paginated list of webhook
|
|
3332
|
+
* @param {Object.<PaginationMeta>} params - Endpoint options
|
|
3333
|
+
*/
|
|
3334
|
+
list: ({ ...params }: PaginationMeta) => Promise<DuffelResponse<WebhooksListResponse[]>>;
|
|
3335
|
+
/**
|
|
3336
|
+
* Create a webhook
|
|
3337
|
+
* @param {Object.<WebhooksCreateParams>} params - Endpoint options
|
|
3338
|
+
*/
|
|
3339
|
+
create: ({ events, url, }: WebhooksCreateParams) => Promise<DuffelResponse<WebhooksCreateResponse>>;
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3180
3342
|
interface DuffelAPIClient {
|
|
3181
3343
|
aircraft: Aircraft;
|
|
3182
3344
|
airlines: Airlines;
|
|
@@ -3211,8 +3373,9 @@ declare class Duffel {
|
|
|
3211
3373
|
partialOfferRequests: PartialOfferRequests;
|
|
3212
3374
|
suggestions: Suggestions;
|
|
3213
3375
|
refunds: Refunds;
|
|
3376
|
+
webhooks: Webhooks;
|
|
3214
3377
|
constructor(config: Config);
|
|
3215
3378
|
}
|
|
3216
3379
|
declare const DuffelError: typeof DuffelError$1;
|
|
3217
3380
|
|
|
3218
|
-
export { AddServices, Aircraft$1 as Aircraft, Airline, AirlineInitiatedChange, AirlineInitiatedChangeActionTaken, AirlineInitiatedChangeAvailableAction, Airport, ApiResponseError, ApiResponseMeta, BaggageType, CabinClass, City, ConfirmOrderChangePayment, CreateOfferRequest, CreateOfferRequestPassenger, CreateOfferRequestPassengerFareType, CreateOfferRequestPrivateFare, CreateOfferRequestQueryParameters, CreateOrder, CreateOrderCancellation, CreateOrderChangeParameters, CreateOrderChangeRequest, CreateOrderPassenger, CreatePayment, CreatePaymentIntent, Duffel, DuffelAPIClient, DuffelError, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, DuffelResponse, FlightsConditions, ListOffersParams, ListOrderCancellationsParams, ListParamsOrders, LoyaltyProgrammeAccount, LoyaltyProgrammeAccounts, Offer, OfferAvailableService, OfferAvailableServiceBaggage, OfferAvailableServiceBaggageMetadata, OfferAvailableServiceCFAR, OfferAvailableServiceCFARMetadata, OfferAvailableServiceCommon, OfferPassenger, OfferPrivateFare, OfferRequest, OfferRequestPassenger, OfferRequestSlice, OfferSlice, OfferSliceSegment, OfferSliceSegmentPassenger, OfferSliceSegmentPassengerBaggage, OfferSliceSegmentStop, Order, OrderAvailableService, OrderCancellation, OrderChange, OrderChangeOffer, OrderChangeOfferSlice, OrderChangeOfferSlices, OrderChangeOffers$1 as OrderChangeOffers, OrderChangeRequestResponse, OrderChangeSliceResponse, OrderDocument, OrderDocumentsType, OrderPassenger, OrderPassengerIdentityDocument, OrderPayment, OrderPaymentStatus, OrderSegmentPassenger, OrderSegmentPassengerBaggage, OrderService, OrderServiceBaggageMetadata, OrderSlice, OrderSliceSegment, PaginationMeta, PassengerIdentityDocumentType, Payment, PaymentIntent, PaymentRequirements, PaymentType, Place, PlaceType, Places, SDKOptions, Seat, SeatMap, SeatMapCabin, SeatMapCabinRow, SeatMapCabinRowSection, SeatMapCabinRowSectionAvailableService, SeatMapCabinRowSectionElement, SeatMapCabinRowSectionElementAmenity, SeatMapCabinRowSectionElementBassinet, SeatMapCabinRowSectionElementCloset, SeatMapCabinRowSectionElementEmpty, SeatMapCabinRowSectionElementExitRow, SeatMapCabinRowSectionElementGalley, SeatMapCabinRowSectionElementLavatory, SeatMapCabinRowSectionElementSeat, SeatMapCabinRowSectionElementStairs, SeatMapCabinRowSectionElementType, UpdateOffer, UpdateSingleOrder };
|
|
3381
|
+
export { AddServices, Aircraft$1 as Aircraft, Airline, AirlineInitiatedChange, AirlineInitiatedChangeActionTaken, AirlineInitiatedChangeAvailableAction, Airport, ApiResponseError, ApiResponseMeta, BaggageType, CabinClass, City, ConfirmOrderChangePayment, CreateOfferRequest, CreateOfferRequestPassenger, CreateOfferRequestPassengerFareType, CreateOfferRequestPrivateFare, CreateOfferRequestQueryParameters, CreateOrder, CreateOrderCancellation, CreateOrderChangeParameters, CreateOrderChangeRequest, CreateOrderPassenger, CreatePayment, CreatePaymentIntent, Duffel, DuffelAPIClient, DuffelError, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, DuffelResponse, FlightsConditions, ListOffersParams, ListOrderCancellationsParams, ListParamsOrders, LoyaltyProgrammeAccount, LoyaltyProgrammeAccounts, Offer, OfferAvailableService, OfferAvailableServiceBaggage, OfferAvailableServiceBaggageMetadata, OfferAvailableServiceCFAR, OfferAvailableServiceCFARMetadata, OfferAvailableServiceCommon, OfferPassenger, OfferPrivateFare, OfferRequest, OfferRequestPassenger, OfferRequestSlice, OfferSlice, OfferSliceSegment, OfferSliceSegmentPassenger, OfferSliceSegmentPassengerBaggage, OfferSliceSegmentStop, Order, OrderAvailableService, OrderCancellation, OrderChange, OrderChangeOffer, OrderChangeOfferSlice, OrderChangeOfferSlices, OrderChangeOffers$1 as OrderChangeOffers, OrderChangeRequestResponse, OrderChangeSliceResponse, OrderDocument, OrderDocumentsType, OrderPassenger, OrderPassengerIdentityDocument, OrderPayment, OrderPaymentStatus, OrderSegmentPassenger, OrderSegmentPassengerBaggage, OrderService, OrderServiceBaggageMetadata, OrderSlice, OrderSliceSegment, PaginationMeta, PassengerIdentityDocumentType, Payment, PaymentIntent, PaymentRequirements, PaymentType, Place, PlaceType, Places, SDKOptions, Seat, SeatMap, SeatMapCabin, SeatMapCabinRow, SeatMapCabinRowSection, SeatMapCabinRowSectionAvailableService, SeatMapCabinRowSectionElement, SeatMapCabinRowSectionElementAmenity, SeatMapCabinRowSectionElementBassinet, SeatMapCabinRowSectionElementCloset, SeatMapCabinRowSectionElementEmpty, SeatMapCabinRowSectionElementExitRow, SeatMapCabinRowSectionElementGalley, SeatMapCabinRowSectionElementLavatory, SeatMapCabinRowSectionElementSeat, SeatMapCabinRowSectionElementStairs, SeatMapCabinRowSectionElementType, UpdateOffer, UpdateSingleOrder, Webhooks$1 as Webhooks, WebhooksCreateParams, WebhooksCreateResponse, WebhooksListDeliveriesParams, WebhooksListDeliveriesResponse, WebhooksListResponse, WebhooksUpdateParams };
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -69,10 +69,10 @@ export declare type DuffelPassengerTitle = 'mr' | 'ms' | 'mrs' | 'MR' | 'MS' | '
|
|
|
69
69
|
*/
|
|
70
70
|
export declare type DuffelPassengerGender = 'm' | 'f';
|
|
71
71
|
/**
|
|
72
|
-
* The type of the identity document.
|
|
72
|
+
* The type of the identity document.
|
|
73
73
|
* This must be one of the `allowed_passenger_identity_document_types` on the offer.
|
|
74
74
|
*/
|
|
75
|
-
export declare type PassengerIdentityDocumentType = 'passport';
|
|
75
|
+
export declare type PassengerIdentityDocumentType = 'passport' | 'tax_id';
|
|
76
76
|
/**
|
|
77
77
|
* The type of the origin or destination
|
|
78
78
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duffel/api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.0",
|
|
4
4
|
"description": "Javascript client library for the Duffel API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"node-fetch": "2.6.9"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "7.21.
|
|
60
|
-
"@babel/preset-env": "7.
|
|
61
|
-
"@babel/preset-typescript": "7.21.
|
|
62
|
-
"@commitlint/cli": "17.
|
|
59
|
+
"@babel/core": "7.21.4",
|
|
60
|
+
"@babel/preset-env": "7.21.4",
|
|
61
|
+
"@babel/preset-typescript": "7.21.4",
|
|
62
|
+
"@commitlint/cli": "17.5.1",
|
|
63
63
|
"@commitlint/config-angular": "17.4.4",
|
|
64
|
-
"@commitlint/cz-commitlint": "17.
|
|
64
|
+
"@commitlint/cz-commitlint": "17.5.0",
|
|
65
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",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"colors": "1.4.0",
|
|
72
72
|
"commitizen": "4.3.0",
|
|
73
73
|
"dotenv": "16.0.3",
|
|
74
|
-
"eslint": "8.
|
|
75
|
-
"eslint-config-prettier": "8.
|
|
74
|
+
"eslint": "8.36.0",
|
|
75
|
+
"eslint-config-prettier": "8.8.0",
|
|
76
76
|
"eslint-plugin-spellcheck": "0.0.20",
|
|
77
77
|
"husky": "8.0.3",
|
|
78
78
|
"jest": "29.0.3",
|