@duffel/api 1.9.1 → 1.9.4
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/Client.d.ts +9 -1
- package/dist/booking/Orders/OrdersTypes.d.ts +9 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/ClientType.d.ts +0 -8
- package/dist/types/index.d.ts +19 -11
- package/package.json +1 -1
package/dist/Client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DuffelResponse, SDKOptions } from './types';
|
|
1
|
+
import { DuffelResponse, SDKOptions, ApiResponseMeta, ApiResponseError } from './types';
|
|
2
2
|
export interface Config {
|
|
3
3
|
token: string;
|
|
4
4
|
basePath?: string;
|
|
@@ -6,6 +6,14 @@ export interface Config {
|
|
|
6
6
|
debug?: SDKOptions;
|
|
7
7
|
source?: string;
|
|
8
8
|
}
|
|
9
|
+
export declare class DuffelError extends Error {
|
|
10
|
+
meta: ApiResponseMeta;
|
|
11
|
+
errors: ApiResponseError[];
|
|
12
|
+
constructor({ meta, errors, }: {
|
|
13
|
+
meta: ApiResponseMeta;
|
|
14
|
+
errors: ApiResponseError[];
|
|
15
|
+
});
|
|
16
|
+
}
|
|
9
17
|
export declare class Client {
|
|
10
18
|
private token;
|
|
11
19
|
private basePath;
|
|
@@ -163,11 +163,11 @@ export interface OrderPassengerIdentityDocument {
|
|
|
163
163
|
*/
|
|
164
164
|
expires_on: string;
|
|
165
165
|
}
|
|
166
|
-
export interface CreateOrderPassenger extends OrderPassenger {
|
|
166
|
+
export interface CreateOrderPassenger extends Omit<OrderPassenger, 'type'> {
|
|
167
167
|
/**
|
|
168
168
|
* The passenger's identity documents. You may only provide one identity document per passenger. The identity document's type must be included in the offer's allowed_passenger_identity_document_types. If the offer's passenger_identity_documents_required is set to true, then an identity document must be provided.
|
|
169
169
|
*/
|
|
170
|
-
identity_documents
|
|
170
|
+
identity_documents?: OrderPassengerIdentityDocument[];
|
|
171
171
|
/**
|
|
172
172
|
* The passenger's email address
|
|
173
173
|
* @example "amelia@duffel.com"
|
|
@@ -178,6 +178,13 @@ export interface CreateOrderPassenger extends OrderPassenger {
|
|
|
178
178
|
* @example "+442080160509"
|
|
179
179
|
*/
|
|
180
180
|
phone_number: string;
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated This type is here just for the backward-compatibility until the field is officially removed from the API
|
|
183
|
+
*
|
|
184
|
+
* The type of the passenger
|
|
185
|
+
* @example "adult", "child", or "infant_without_seat"
|
|
186
|
+
*/
|
|
187
|
+
type?: DuffelPassengerType;
|
|
181
188
|
}
|
|
182
189
|
export interface OrderSliceSegment {
|
|
183
190
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PaymentIntents } from './DuffelPayments';
|
|
2
2
|
import { OfferRequests, Offers, OrderCancellations, Orders, OrderChangeRequests, OrderChangeOffers, OrderChanges, Payments, SeatMaps } from './booking';
|
|
3
|
-
import { Config } from './Client';
|
|
3
|
+
import { Config, DuffelError as _DuffelError } from './Client';
|
|
4
4
|
import { Aircraft, Airlines, Airports } from './supportingResources';
|
|
5
5
|
export interface DuffelAPIClient {
|
|
6
6
|
aircraft: Aircraft;
|
|
@@ -33,3 +33,4 @@ export declare class Duffel {
|
|
|
33
33
|
paymentIntents: PaymentIntents;
|
|
34
34
|
constructor(config: Config);
|
|
35
35
|
}
|
|
36
|
+
export declare const DuffelError: typeof _DuffelError;
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"node-fetch";import{URL as e,URLSearchParams as s}from"url";function i(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function r(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function h(t){return this instanceof h?(this.v=t,this):new h(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){a.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof h?Promise.resolve(s.value.v).then(p
|
|
1
|
+
import t from"node-fetch";import{URL as e,URLSearchParams as s}from"url";function i(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function r(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function h(t){return this instanceof h?(this.v=t,this):new h(t)}function a(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){a.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof h?Promise.resolve(s.value.v).then(c,p):u(a[0][2],s)}catch(t){u(a[0][3],t)}var s}function c(t){o("next",t)}function p(t){o("throw",t)}function u(t,e){t(e),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.9.3"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class n{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>r(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class c extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>r(this,void 0,void 0,(function*(){const{return_offers:e}=t,s=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends n{constructor(t){super(t),this.get=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>r(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class u extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class d extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.path="air/orders"}}class f extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class l extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class m extends n{constructor(t){super(t),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,e)=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class v extends n{constructor(t){super(t),this.create=t=>r(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class q extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}class g extends Error{constructor({meta:t,errors:e}){super(),this.meta=t,this.errors=e}}class y{constructor({token:i,basePath:h,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:h,data:a,params:n,compress:o=!0})=>r(this,void 0,void 0,(function*(){var r;let c,p;const u=new e(h,this.basePath),d={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=Object.entries(n).sort().filter((t=>null!==t[0]));u.search=new s(t).toString()}a&&(c=JSON.stringify({data:Object.assign({},a)})),(null===(r=this.debug)||void 0===r?void 0:r.verbose)&&(console.info("Endpoint: ",u.href),console.info("Method: ",i),a&&console.info("Body Parameters: ",a),n&&console.info("Query Parameters: ",n));const f=yield t(u.href,{method:i,headers:d,body:c,compress:o}),l=f.headers.get("content-type");if(p=l&&l.includes("json")?yield f.json():yield f.text(),!f.ok||"errors"in p&&p.errors)throw new g(p);return p})),this.token=i,this.basePath=h||"https://api.duffel.com",this.apiVersion=a||"beta",this.debug=n,this.source=o}paginatedRequest({path:t,params:e}){return a(this,arguments,(function*(){let s=yield h(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield h({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield h(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield h({data:t})}}))}}class $ extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class T extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class O extends n{constructor(t){super(t),this.get=t=>r(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class b{constructor(t){this.client=new y(t),this.aircraft=new $(this.client),this.airlines=new T(this.client),this.airports=new O(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new d(this.client),this.orderChangeRequests=new f(this.client),this.orderChangeOffers=new l(this.client),this.orderChanges=new m(this.client),this.orderCancellations=new u(this.client),this.payments=new v(this.client),this.seatMaps=new q(this.client),this.paymentIntents=new o(this.client)}}const w=g;export{b as Duffel,w 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 r(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function h(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function n(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),h=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){h.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):p(h[0][2],s)}catch(t){p(h[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}}!function(){const t={npm_package_version:"1.9.
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("node-fetch"),e=require("url");function s(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var i=s(t);function r(t,e){var s={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(s[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(s[i[r]]=t[i[r]])}return s}function h(t,e,s,i){return new(s||(s=Promise))((function(r,h){function a(t){try{o(i.next(t))}catch(t){h(t)}}function n(t){try{o(i.throw(t))}catch(t){h(t)}}function o(t){var e;t.done?r(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}o((i=i.apply(t,e||[])).next())}))}function a(t){return this instanceof a?(this.v=t,this):new a(t)}function n(t,e,s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,r=s.apply(t,e||[]),h=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){r[t]&&(i[t]=function(e){return new Promise((function(s,i){h.push([t,e,s,i])>1||o(t,e)}))})}function o(t,e){try{(s=r[t](e)).value instanceof a?Promise.resolve(s.value.v).then(u,c):p(h[0][2],s)}catch(t){p(h[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),h.shift(),h.length&&o(h[0][0],h[0][1])}}!function(){const t={npm_package_version:"1.9.3"};try{if(process)return process.env=Object.assign({},process.env),void Object.assign(process.env,t)}catch(t){}globalThis.process={env:t}}();class o{constructor(t){this.request=({method:t,path:e,data:s,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:e,data:s,params:i})})),this.paginatedRequest=({path:t,params:e})=>this.client.paginatedRequest({path:t,params:e}),this.client=t}}class u extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class c extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:e}=t,s=r(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:s,params:Object.assign({},null!=e&&{return_offers:e})})})),this.path="air/offer_requests"}}class p extends o{constructor(t){super(t),this.get=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:e})})),this.list=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.listWithGenerator=t=>{var{offer_request_id:e}=t,s=r(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},s),{offer_request_id:e})})},this.update=(t,e,s)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${e}`},s&&{data:s}))})),this.path="air/offers"}}class d extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=t=>this.paginatedRequest({path:this.path,params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.path="air/order_cancellations"}}class f extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:t})})),this.listWithGenerator=t=>this.paginatedRequest({path:"air/orders",params:t}),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.update=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:e}})})),this.path="air/orders"}}class l extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class m extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/order_change_offers"}}class v extends o{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=(t,e)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:e})})),this.path="air/order_changes"}}class q extends o{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}class y extends Error{constructor({meta:t,errors:e}){super(),this.meta=t,this.errors=e}}class ${constructor({token:t,basePath:s,apiVersion:r,debug:a,source:n}){this.request=({method:t,path:s,data:r,params:a,compress:n=!0})=>h(this,void 0,void 0,(function*(){var h;let o,u;const c=new e.URL(s,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=Object.entries(a).sort().filter((t=>null!==t[0]));c.search=new e.URLSearchParams(t).toString()}r&&(o=JSON.stringify({data:Object.assign({},r)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",c.href),console.info("Method: ",t),r&&console.info("Body Parameters: ",r),a&&console.info("Query Parameters: ",a));const d=yield i.default(c.href,{method:t,headers:p,body:o,compress:n}),f=d.headers.get("content-type");if(u=f&&f.includes("json")?yield d.json():yield d.text(),!d.ok||"errors"in u&&u.errors)throw new y(u);return u})),this.token=t,this.basePath=s||"https://api.duffel.com",this.apiVersion=r||"beta",this.debug=a,this.source=n}paginatedRequest({path:t,params:e}){return n(this,arguments,(function*(){let s=yield a(this.request({method:"GET",path:t,params:e}));for(const t of s.data)yield yield a({data:t});for(;s.meta&&"after"in s.meta&&s.meta.after;){s=yield a(this.request({method:"GET",path:t,params:{limit:s.meta.limit,after:s.meta.after}}));for(const t of s.data)yield yield a({data:t})}}))}}class T extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class b extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airlines"}}class O extends o{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}const _=y;exports.Duffel=class{constructor(t){this.client=new $(t),this.aircraft=new T(this.client),this.airlines=new b(this.client),this.airports=new O(this.client),this.offerRequests=new c(this.client),this.offers=new p(this.client),this.orders=new f(this.client),this.orderChangeRequests=new l(this.client),this.orderChangeOffers=new m(this.client),this.orderChanges=new v(this.client),this.orderCancellations=new d(this.client),this.payments=new q(this.client),this.seatMaps=new g(this.client),this.paymentIntents=new u(this.client)}},exports.DuffelError=_;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -63,14 +63,6 @@ export interface DuffelResponse<T_Data> {
|
|
|
63
63
|
*/
|
|
64
64
|
meta?: PaginationMeta;
|
|
65
65
|
}
|
|
66
|
-
export declare class DuffelError extends Error {
|
|
67
|
-
meta: ApiResponseMeta;
|
|
68
|
-
errors: ApiResponseError[];
|
|
69
|
-
constructor({ meta, errors, }: {
|
|
70
|
-
meta: ApiResponseMeta;
|
|
71
|
-
errors: ApiResponseError[];
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
66
|
export interface SDKOptions {
|
|
75
67
|
/**
|
|
76
68
|
* If `true` it will output the path and the method called
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1119,11 +1119,11 @@ interface OrderPassengerIdentityDocument {
|
|
|
1119
1119
|
*/
|
|
1120
1120
|
expires_on: string;
|
|
1121
1121
|
}
|
|
1122
|
-
interface CreateOrderPassenger extends OrderPassenger {
|
|
1122
|
+
interface CreateOrderPassenger extends Omit<OrderPassenger, 'type'> {
|
|
1123
1123
|
/**
|
|
1124
1124
|
* The passenger's identity documents. You may only provide one identity document per passenger. The identity document's type must be included in the offer's allowed_passenger_identity_document_types. If the offer's passenger_identity_documents_required is set to true, then an identity document must be provided.
|
|
1125
1125
|
*/
|
|
1126
|
-
identity_documents
|
|
1126
|
+
identity_documents?: OrderPassengerIdentityDocument[];
|
|
1127
1127
|
/**
|
|
1128
1128
|
* The passenger's email address
|
|
1129
1129
|
* @example "amelia@duffel.com"
|
|
@@ -1134,6 +1134,13 @@ interface CreateOrderPassenger extends OrderPassenger {
|
|
|
1134
1134
|
* @example "+442080160509"
|
|
1135
1135
|
*/
|
|
1136
1136
|
phone_number: string;
|
|
1137
|
+
/**
|
|
1138
|
+
* @deprecated This type is here just for the backward-compatibility until the field is officially removed from the API
|
|
1139
|
+
*
|
|
1140
|
+
* The type of the passenger
|
|
1141
|
+
* @example "adult", "child", or "infant_without_seat"
|
|
1142
|
+
*/
|
|
1143
|
+
type?: DuffelPassengerType;
|
|
1137
1144
|
}
|
|
1138
1145
|
interface OrderSliceSegment {
|
|
1139
1146
|
/**
|
|
@@ -2098,14 +2105,6 @@ interface DuffelResponse<T_Data> {
|
|
|
2098
2105
|
*/
|
|
2099
2106
|
meta?: PaginationMeta;
|
|
2100
2107
|
}
|
|
2101
|
-
declare class DuffelError extends Error {
|
|
2102
|
-
meta: ApiResponseMeta;
|
|
2103
|
-
errors: ApiResponseError[];
|
|
2104
|
-
constructor({ meta, errors, }: {
|
|
2105
|
-
meta: ApiResponseMeta;
|
|
2106
|
-
errors: ApiResponseError[];
|
|
2107
|
-
});
|
|
2108
|
-
}
|
|
2109
2108
|
interface SDKOptions {
|
|
2110
2109
|
/**
|
|
2111
2110
|
* If `true` it will output the path and the method called
|
|
@@ -2120,6 +2119,14 @@ interface Config {
|
|
|
2120
2119
|
debug?: SDKOptions;
|
|
2121
2120
|
source?: string;
|
|
2122
2121
|
}
|
|
2122
|
+
declare class DuffelError$1 extends Error {
|
|
2123
|
+
meta: ApiResponseMeta;
|
|
2124
|
+
errors: ApiResponseError[];
|
|
2125
|
+
constructor({ meta, errors, }: {
|
|
2126
|
+
meta: ApiResponseMeta;
|
|
2127
|
+
errors: ApiResponseError[];
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2123
2130
|
declare class Client {
|
|
2124
2131
|
private token;
|
|
2125
2132
|
private basePath;
|
|
@@ -2589,6 +2596,7 @@ declare class Duffel {
|
|
|
2589
2596
|
seatMaps: SeatMaps;
|
|
2590
2597
|
paymentIntents: PaymentIntents;
|
|
2591
2598
|
constructor(config: Config);
|
|
2592
|
-
}
|
|
2599
|
+
}
|
|
2600
|
+
declare const DuffelError: typeof DuffelError$1;
|
|
2593
2601
|
|
|
2594
2602
|
export { Aircraft$1 as Aircraft, Airline, Airport, ApiResponseError, ApiResponseMeta, BaggageType, CabinClass, City, ConfirmOrderChangePayment, CreateOfferRequest, CreateOfferRequestQueryParameters, CreateOrder, CreateOrderCancellation, CreateOrderChangeParameters, CreateOrderChangeRequest, CreateOrderPassenger, CreatePayment, CreatePaymentIntent, Duffel, DuffelAPIClient, DuffelError, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, DuffelResponse, FlightsConditions, ListOffersParams, ListOrderCancellationsParams, ListParamsOrders, LoyaltyProgrammeAccount, LoyaltyProgrammeAccounts, Offer, OfferAvailableService, OfferAvailableServiceBaggageMetadata, OfferAvailableServiceMetadataMap, OfferAvailableServiceType, OfferPassenger, OfferRequest, OfferRequestPassenger, OfferRequestSlice, OfferSlice, OfferSliceSegment, OfferSliceSegmentPassenger, OfferSliceSegmentPassengerBaggage, Order, 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, SDKOptions, Seat, SeatMap, SeatMapCabin, SeatMapCabinRow, SeatMapCabinRowSection, SeatMapCabinRowSectionAvailableService, SeatMapCabinRowSectionElement, SeatMapCabinRowSectionElementAmenity, SeatMapCabinRowSectionElementBassinet, SeatMapCabinRowSectionElementCloset, SeatMapCabinRowSectionElementEmpty, SeatMapCabinRowSectionElementExitRow, SeatMapCabinRowSectionElementGalley, SeatMapCabinRowSectionElementLavatory, SeatMapCabinRowSectionElementSeat, SeatMapCabinRowSectionElementStairs, SeatMapCabinRowSectionElementType, UpdateOffer, UpdateSingleOrder };
|