@duffel/api 1.24.1 → 1.26.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/OfferRequests/OfferRequestsTypes.d.ts +104 -10
- package/dist/booking/Offers/OfferTypes.d.ts +44 -0
- package/dist/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +148 -11
- package/package.json +10 -10
|
@@ -22,6 +22,83 @@ export interface OfferRequestSlice {
|
|
|
22
22
|
*/
|
|
23
23
|
destination_type: PlaceType;
|
|
24
24
|
}
|
|
25
|
+
interface CreateOfferRequestPassengerCommon {
|
|
26
|
+
/**
|
|
27
|
+
* The passenger's family name. Only `space`, `-`, `'`, and letters from the
|
|
28
|
+
* `ASCII`, `Latin-1 Supplement` and `Latin Extended-A` (with the exceptions
|
|
29
|
+
* of `Æ`, `æ`, `IJ`, `ij`, `Œ`, `œ`, `Þ`, and `ð`) Unicode charts are accepted.
|
|
30
|
+
* All other characters will result in a validation error. The minimum length
|
|
31
|
+
* is 1 character, and the maximum is 20 characters.
|
|
32
|
+
*
|
|
33
|
+
* This is only required if you're also including
|
|
34
|
+
* **Loyalty Programme Accounts**.
|
|
35
|
+
*/
|
|
36
|
+
family_name?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The passenger's given name. Only `space`, `-`, `'`, and letters from the
|
|
39
|
+
* `ASCII`, `Latin-1 Supplement` and `Latin Extended-A` (with the exceptions
|
|
40
|
+
* of `Æ`, `æ`, `IJ`, `ij`, `Œ`, `œ`, `Þ`, and `ð`) Unicode charts are accepted.
|
|
41
|
+
* All other characters will result in a validation error. The minimum length
|
|
42
|
+
* is 1 character, and the maximum is 20 characters.
|
|
43
|
+
*
|
|
44
|
+
* This is only required if you're also including
|
|
45
|
+
* **Loyalty Programme Accounts**.
|
|
46
|
+
*/
|
|
47
|
+
given_name?: string;
|
|
48
|
+
/**
|
|
49
|
+
* The **Loyalty Programme Accounts** for this passenger.
|
|
50
|
+
*/
|
|
51
|
+
loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
|
|
52
|
+
}
|
|
53
|
+
interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
|
|
54
|
+
age?: never;
|
|
55
|
+
fare_type?: never;
|
|
56
|
+
/**
|
|
57
|
+
* The type of the passenger. If the passenger is aged 18 or over, you should
|
|
58
|
+
* specify a `type` of `adult`. If a passenger is aged under 18, you should
|
|
59
|
+
* specify their `age` instead of a `type`. A passenger can have only a type
|
|
60
|
+
* or an age, but not both.
|
|
61
|
+
*/
|
|
62
|
+
type: Extract<DuffelPassengerType, 'adult'>;
|
|
63
|
+
}
|
|
64
|
+
interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
|
|
65
|
+
/**
|
|
66
|
+
* The age of the passenger on the `departure_date` of the final slice. e.g.
|
|
67
|
+
* if you a searching for a round trip and the passenger is 15 years old at
|
|
68
|
+
* the time of the outbound flight, but they then have their birthday and are
|
|
69
|
+
* 16 years old for the inbound flight, you must set the age to 16. You should
|
|
70
|
+
* specify an `age` for passengers who are under 18 years old. A passenger can
|
|
71
|
+
* have only a type or an age, but not both. You can optionally pass age with
|
|
72
|
+
* `fare_type` though.
|
|
73
|
+
*/
|
|
74
|
+
age: number;
|
|
75
|
+
fare_type?: never;
|
|
76
|
+
type?: never;
|
|
77
|
+
}
|
|
78
|
+
export declare type CreateOfferRequestPassengerFareType = 'accompanying_adult' | 'contract_bulk' | 'contract_bulk_child' | 'contract_bulk_infant_with_seat' | 'contract_bulk_infant_without_seat' | 'frequent_flyer' | 'group_inclusive_tour' | 'group_inclusive_tour_child' | 'humanitarian' | 'individual_inclusive_tour_child' | 'marine' | 'seat_only' | 'student' | 'teacher' | 'tour_operator_inclusive' | 'tour_operator_inclusive_infant' | 'unaccompanied_child' | 'visiting_friends_and_family';
|
|
79
|
+
interface CreateOfferRequestPassengerWithFareType extends CreateOfferRequestPassengerCommon {
|
|
80
|
+
/**
|
|
81
|
+
* The age of the passenger on the `departure_date` of the final slice. e.g.
|
|
82
|
+
* if you a searching for a round trip and the passenger is 15 years old at
|
|
83
|
+
* the time of the outbound flight, but they then have their birthday and are
|
|
84
|
+
* 16 years old for the inbound flight, you must set the age to 16. You should
|
|
85
|
+
* specify an `age` for passengers who are under 18 years old. A passenger can
|
|
86
|
+
* have only a type or an age, but not both. You can optionally pass age with
|
|
87
|
+
* `fare_type` though.
|
|
88
|
+
*/
|
|
89
|
+
age?: number;
|
|
90
|
+
/**
|
|
91
|
+
* The fare type of the passenger. If the passenger is aged less than 18, you
|
|
92
|
+
* should pass in age as well.
|
|
93
|
+
*/
|
|
94
|
+
fare_type: CreateOfferRequestPassengerFareType;
|
|
95
|
+
type?: never;
|
|
96
|
+
}
|
|
97
|
+
export declare type CreateOfferRequestPassenger = CreateOfferRequestAdultPassenger | CreateOfferRequestNonAdultPassenger | CreateOfferRequestPassengerWithFareType;
|
|
98
|
+
export interface CreateOfferRequestPrivateFare {
|
|
99
|
+
corporate_code: string;
|
|
100
|
+
tracking_reference: string;
|
|
101
|
+
}
|
|
25
102
|
/**
|
|
26
103
|
* The passengers who want to travel. A passenger will have only a type or an age.
|
|
27
104
|
*/
|
|
@@ -116,24 +193,40 @@ export interface OfferRequest {
|
|
|
116
193
|
}
|
|
117
194
|
export interface CreateOfferRequest {
|
|
118
195
|
/**
|
|
119
|
-
* The cabin that the passengers want to travel in
|
|
196
|
+
* The cabin that the passengers want to travel in.
|
|
120
197
|
*/
|
|
121
198
|
cabin_class?: CabinClass;
|
|
122
199
|
/**
|
|
123
|
-
* The
|
|
124
|
-
*
|
|
200
|
+
* The maximum number of connections within any slice of the offer. For
|
|
201
|
+
* example 0 means a direct flight which will have a single segment within
|
|
202
|
+
* each slice and 1 means a maximum of two segments within each slice of the
|
|
203
|
+
* offer.
|
|
125
204
|
*/
|
|
126
|
-
|
|
205
|
+
max_connections?: 0 | 1 | 2;
|
|
127
206
|
/**
|
|
128
|
-
* The
|
|
129
|
-
*
|
|
207
|
+
* The passengers who want to travel. If you specify an `age` for a passenger,
|
|
208
|
+
* the `type` may differ for the same passenger in different offers due to
|
|
209
|
+
* airline's different rules. E.g. one airline may treat a 14 year old as an
|
|
210
|
+
* adult, and another as a young adult. You may only specify an `age` or a
|
|
211
|
+
* `type` – not both.
|
|
130
212
|
*/
|
|
131
|
-
|
|
213
|
+
passengers: CreateOfferRequestPassenger[];
|
|
132
214
|
/**
|
|
133
|
-
* The
|
|
134
|
-
*
|
|
215
|
+
* The private fare codes for this Offer Request. You can pass in multiple
|
|
216
|
+
* airlines with their specific private fare codes. The key is the airline's
|
|
217
|
+
* IATA code that provided the private fare code. The `corporate_code` is
|
|
218
|
+
* provided to you by the airline and the `tracking_reference` is to identify
|
|
219
|
+
* your business by the airlines.
|
|
135
220
|
*/
|
|
136
|
-
|
|
221
|
+
private_fares?: {
|
|
222
|
+
[iataCode: string]: CreateOfferRequestPrivateFare[];
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* The [slices](https://duffel.com/docs/api/overview/key-principles) that make
|
|
226
|
+
* up this offer request. One-way journeys can be expressed using one slice,
|
|
227
|
+
* whereas return trips will need two.
|
|
228
|
+
*/
|
|
229
|
+
slices: Omit<OfferRequestSlice, 'origin_type' | 'destination_type'>[];
|
|
137
230
|
}
|
|
138
231
|
export interface CreateOfferRequestQueryParameters {
|
|
139
232
|
/**
|
|
@@ -144,3 +237,4 @@ export interface CreateOfferRequestQueryParameters {
|
|
|
144
237
|
*/
|
|
145
238
|
return_offers?: boolean;
|
|
146
239
|
}
|
|
240
|
+
export {};
|
|
@@ -65,6 +65,10 @@ export interface Offer {
|
|
|
65
65
|
* The payment requirements for this offer
|
|
66
66
|
*/
|
|
67
67
|
payment_requirements: PaymentRequirements;
|
|
68
|
+
/**
|
|
69
|
+
* The private fares applied on this offer.
|
|
70
|
+
*/
|
|
71
|
+
private_fares: OfferPrivateFare[];
|
|
68
72
|
/**
|
|
69
73
|
* The slices that make up this offer. Each slice will include one or more segments,
|
|
70
74
|
* the specific flights that the airline is offering to take the passengers from the slice's `origin` to its `destination`.
|
|
@@ -230,6 +234,20 @@ export interface PaymentRequirements {
|
|
|
230
234
|
*/
|
|
231
235
|
requires_instant_payment: boolean;
|
|
232
236
|
}
|
|
237
|
+
export interface OfferPrivateFare {
|
|
238
|
+
/**
|
|
239
|
+
* The corporate code that was applied, if any.
|
|
240
|
+
*/
|
|
241
|
+
corporate_code?: string;
|
|
242
|
+
/**
|
|
243
|
+
* The tracking reference that was applied, if any.
|
|
244
|
+
*/
|
|
245
|
+
tracking_reference?: string;
|
|
246
|
+
/**
|
|
247
|
+
* The type of private fare applied.
|
|
248
|
+
*/
|
|
249
|
+
type: 'corporate' | 'leisure' | 'negotiated';
|
|
250
|
+
}
|
|
233
251
|
export interface OfferPassenger {
|
|
234
252
|
/**
|
|
235
253
|
* The age of the passenger on the departure_date of the final slice.
|
|
@@ -378,6 +396,32 @@ export interface OfferSliceSegment {
|
|
|
378
396
|
* Additional segment-specific information about the passengers included in the offer (e.g. their baggage allowance and the cabin class they will be travelling in)
|
|
379
397
|
*/
|
|
380
398
|
passengers: OfferSliceSegmentPassenger[];
|
|
399
|
+
/**
|
|
400
|
+
* Additional segment-specific information about the stops, if any, included in the segment
|
|
401
|
+
*/
|
|
402
|
+
stops?: OfferSliceSegmentStop[];
|
|
403
|
+
}
|
|
404
|
+
export interface OfferSliceSegmentStop {
|
|
405
|
+
/**
|
|
406
|
+
* Duffel's unique identifier for the Stop
|
|
407
|
+
*/
|
|
408
|
+
id: string;
|
|
409
|
+
/**
|
|
410
|
+
* The airport at which the Stop happens
|
|
411
|
+
*/
|
|
412
|
+
airport: Airport;
|
|
413
|
+
/**
|
|
414
|
+
* The ISO 8601 datetime at which the Stop is scheduled to arrive, in the airport's timezone (see destination.timezone)
|
|
415
|
+
*/
|
|
416
|
+
arrivingAt: string;
|
|
417
|
+
/**
|
|
418
|
+
* The ISO 8601 datetime at which the Stop is scheduled to depart, in the airport's timezone (see origin.timezone)
|
|
419
|
+
*/
|
|
420
|
+
departingAt: string;
|
|
421
|
+
/**
|
|
422
|
+
* The duration of the Stop, represented as a ISO 8601 duration
|
|
423
|
+
*/
|
|
424
|
+
duration: string;
|
|
381
425
|
}
|
|
382
426
|
export interface OfferSliceSegmentPassenger {
|
|
383
427
|
/**
|
package/dist/index.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import t from"node-fetch";import{URL as s,URLSearchParams as e}from"url";function i(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function h(t,s,e,i){return new(e||(e=Promise))((function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e((function(t){t(s)}))).then(a,n)}o((i=i.apply(t,s||[])).next())}))}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}function o(t,s){try{(e=h[t](s)).value instanceof r?Promise.resolve(e.value.v).then(c,p):u(a[0][2],e)}catch(t){u(a[0][3],t)}var e}function c(t){o("next",t)}function p(t){o("throw",t)}function u(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.24.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:s,data:e,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:i})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class c extends n{constructor(t){super(t),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})})),this.path="air/airline_initiated_changes"}}class 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=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:s}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class u extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.path="air/offers"}}class 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,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class 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,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})})),this.path="air/order_changes"}}class q extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}class T extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}}class y{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:r,data:a,params:n,compress:o=!0})=>h(this,void 0,void 0,(function*(){var h;let c,p;const u=new s(r,this.basePath),d={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=new e;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([s,e])=>{Array.isArray(e)?e.forEach((e=>t.append(s,e.toString()))):t.append(s,e.toString())})),u.search=t.toString()}a&&(c=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",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 T(Object.assign(Object.assign({},p),{headers:f.headers}));return Object.assign(Object.assign({},p),{headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v1",this.debug=n,this.source=o}paginatedRequest({path:t,params:s}){return a(this,arguments,(function*(){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield r({data:t})}}))}}class O extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class _ 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 G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class b extends 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 P{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new _(this.client),this.airports=new G(this.client),this.airlineInitiatedChanges=new c(this.client),this.links=new E(this.client),this.offerRequests=new p(this.client),this.offers=new u(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 b(this.client),this.refunds=new w(this.client)}}const x=T;export{P as Duffel,x as DuffelError};
|
|
1
|
+
import t from"node-fetch";import{URL as s,URLSearchParams as e}from"url";function i(t,s){var e={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&s.indexOf(i)<0&&(e[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var h=0;for(i=Object.getOwnPropertySymbols(t);h<i.length;h++)s.indexOf(i[h])<0&&Object.prototype.propertyIsEnumerable.call(t,i[h])&&(e[i[h]]=t[i[h]])}return e}function h(t,s,e,i){return new(e||(e=Promise))((function(h,r){function a(t){try{o(i.next(t))}catch(t){r(t)}}function n(t){try{o(i.throw(t))}catch(t){r(t)}}function o(t){var s;t.done?h(t.value):(s=t.value,s instanceof e?s:new e((function(t){t(s)}))).then(a,n)}o((i=i.apply(t,s||[])).next())}))}function r(t){return this instanceof r?(this.v=t,this):new r(t)}function a(t,s,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i,h=e.apply(t,s||[]),a=[];return i={},n("next"),n("throw"),n("return"),i[Symbol.asyncIterator]=function(){return this},i;function n(t){h[t]&&(i[t]=function(s){return new Promise((function(e,i){a.push([t,s,e,i])>1||o(t,s)}))})}function o(t,s){try{(e=h[t](s)).value instanceof r?Promise.resolve(e.value.v).then(c,p):u(a[0][2],e)}catch(t){u(a[0][3],t)}var e}function c(t){o("next",t)}function p(t){o("throw",t)}function u(t,s){t(s),a.shift(),a.length&&o(a[0][0],a[0][1])}}!function(){const t={npm_package_version:"1.25.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:s,data:e,params:i})=>h(this,void 0,void 0,(function*(){return this.client.request({method:t,path:s,data:e,params:i})})),this.paginatedRequest=({path:t,params:s})=>this.client.paginatedRequest({path:t,params:s}),this.client=t}}class o extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.confirm=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="payments/payment_intents"}}class c extends n{constructor(t){super(t),this.update=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{action_taken:s}})})),this.accept=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/accept`})})),this.list=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:this.path,params:{order_id:t}})})),this.path="air/airline_initiated_changes"}}class 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=()=>this.paginatedRequest({path:this.path}),this.create=t=>h(this,void 0,void 0,(function*(){const{return_offers:s}=t,e=i(t,["return_offers"]);return this.request({method:"POST",path:`${this.path}/`,data:e,params:Object.assign({},null!=s&&{return_offers:s})})})),this.path="air/offer_requests"}}class u extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.list=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.request({method:"GET",path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.listWithGenerator=t=>{var{offer_request_id:s}=t,e=i(t,["offer_request_id"]);return this.paginatedRequest({path:this.path,params:Object.assign(Object.assign({},e),{offer_request_id:s})})},this.update=(t,s,e)=>h(this,void 0,void 0,(function*(){return this.request(Object.assign({method:"PATCH",path:`${this.path}/${t}/passengers/${s}`},e&&{data:e}))})),this.path="air/offers"}}class 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,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"PATCH",path:`${this.path}/${t}`,data:{options:s}})})),this.getAvailableServices=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/available_services`})})),this.addServices=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/services`,data:s})})),this.path="air/orders"}}class l extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/order_change_requests"}}class 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,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/${t}/actions/confirm`,data:s})})),this.path="air/order_changes"}}class q extends n{constructor(t){super(t),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:this.path,data:t})})),this.path="air/payments"}}class g extends n{constructor(t){super(t),this.get=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`,params:s})})),this.create=t=>h(this,void 0,void 0,(function*(){return this.request({method:"POST",path:`${this.path}/`,data:t})})),this.getFaresById=(t,s)=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}/fares`,params:s})})),this.path="air/partial_offer_requests"}}class $ extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}`,params:t})})),this.path="air/seat_maps"}}class T extends Error{constructor({meta:t,errors:s,headers:e}){super(),this.meta=t,this.errors=s,this.headers=e}}class y{constructor({token:i,basePath:r,apiVersion:a,debug:n,source:o}){this.request=({method:i,path:r,data:a,params:n,compress:o=!0})=>h(this,void 0,void 0,(function*(){var h;let c,p;const u=new s(r,this.basePath),d={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(n){const t=new e;Object.entries(n).sort().filter((t=>null!==t[0])).forEach((([s,e])=>{Array.isArray(e)?e.forEach((e=>t.append(s,e.toString()))):t.append(s,e.toString())})),u.search=t.toString()}a&&(c=JSON.stringify({data:Object.assign({},a)})),(null===(h=this.debug)||void 0===h?void 0:h.verbose)&&(console.info("Endpoint: ",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 T(Object.assign(Object.assign({},p),{headers:f.headers}));return Object.assign(Object.assign({},p),{headers:f.headers})})),this.token=i,this.basePath=r||"https://api.duffel.com",this.apiVersion=a||"v1",this.debug=n,this.source=o}paginatedRequest({path:t,params:s}){return a(this,arguments,(function*(){let e=yield r(this.request({method:"GET",path:t,params:s}));for(const t of e.data)yield yield r({data:t});for(;e.meta&&"after"in e.meta&&e.meta.after;){e=yield r(this.request({method:"GET",path:t,params:{limit:e.meta.limit,after:e.meta.after}}));for(const t of e.data)yield yield r({data:t})}}))}}class O extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/aircraft"}}class _ 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 G extends n{constructor(t){super(t),this.get=t=>h(this,void 0,void 0,(function*(){return this.request({method:"GET",path:`${this.path}/${t}`})})),this.list=t=>this.request({method:"GET",path:this.path,params:t}),this.listWithGenerator=()=>this.paginatedRequest({path:this.path}),this.path="air/airports"}}class b extends 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 P{constructor(t){this.client=new y(t),this.aircraft=new O(this.client),this.airlines=new _(this.client),this.airports=new G(this.client),this.airlineInitiatedChanges=new c(this.client),this.links=new E(this.client),this.offerRequests=new p(this.client),this.offers=new u(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 b(this.client),this.refunds=new w(this.client)}}const x=T;export{P as Duffel,x 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):p(r[0][2],s)}catch(t){p(r[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),r.shift(),r.length&&o(r[0][0],r[0][1])}}!function(){const t={npm_package_version:"1.24.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 p 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 d 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 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.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 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.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;let o,u;const c=new e.URL(s,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),c.search=t.toString()}h&&(o=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 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(Object.assign(Object.assign({},u),{headers:d.headers}));return Object.assign(Object.assign({},u),{headers:d.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 _ 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 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/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 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"}}const x=y;exports.Duffel=class{constructor(t){this.client=new O(t),this.aircraft=new _(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new c(this.client),this.links=new P(this.client),this.offerRequests=new p(this.client),this.offers=new d(this.client),this.orders=new l(this.client),this.orderChangeRequests=new m(this.client),this.orderChangeOffers=new v(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=x;
|
|
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):p(r[0][2],s)}catch(t){p(r[0][3],t)}var s}function u(t){o("next",t)}function c(t){o("throw",t)}function p(t,e){t(e),r.shift(),r.length&&o(r[0][0],r[0][1])}}!function(){const t={npm_package_version:"1.25.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 p 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 d 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 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.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 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.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;let o,u;const c=new e.URL(s,this.basePath),p={"User-Agent":[`Duffel/${this.apiVersion}`,`duffel_api_javascript/${process.env.npm_package_version}`,this.source?`source/${this.source}`:""].join(" ").trim(),Accept:"application/json","Accept-Encoding":"gzip","Content-Type":"application/json","Duffel-Version":this.apiVersion,Authorization:`Bearer ${this.token}`};if(a){const t=new e.URLSearchParams;Object.entries(a).sort().filter((t=>null!==t[0])).forEach((([e,s])=>{Array.isArray(s)?s.forEach((s=>t.append(e,s.toString()))):t.append(e,s.toString())})),c.search=t.toString()}h&&(o=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 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(Object.assign(Object.assign({},u),{headers:d.headers}));return Object.assign(Object.assign({},u),{headers:d.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 _ 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 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/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 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"}}const x=y;exports.Duffel=class{constructor(t){this.client=new O(t),this.aircraft=new _(this.client),this.airlines=new b(this.client),this.airports=new E(this.client),this.airlineInitiatedChanges=new c(this.client),this.links=new P(this.client),this.offerRequests=new p(this.client),this.offers=new d(this.client),this.orders=new l(this.client),this.orderChangeRequests=new m(this.client),this.orderChangeOffers=new v(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=x;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.d.ts
CHANGED
|
@@ -123,6 +123,10 @@ interface Offer {
|
|
|
123
123
|
* The payment requirements for this offer
|
|
124
124
|
*/
|
|
125
125
|
payment_requirements: PaymentRequirements;
|
|
126
|
+
/**
|
|
127
|
+
* The private fares applied on this offer.
|
|
128
|
+
*/
|
|
129
|
+
private_fares: OfferPrivateFare[];
|
|
126
130
|
/**
|
|
127
131
|
* The slices that make up this offer. Each slice will include one or more segments,
|
|
128
132
|
* the specific flights that the airline is offering to take the passengers from the slice's `origin` to its `destination`.
|
|
@@ -288,6 +292,20 @@ interface PaymentRequirements {
|
|
|
288
292
|
*/
|
|
289
293
|
requires_instant_payment: boolean;
|
|
290
294
|
}
|
|
295
|
+
interface OfferPrivateFare {
|
|
296
|
+
/**
|
|
297
|
+
* The corporate code that was applied, if any.
|
|
298
|
+
*/
|
|
299
|
+
corporate_code?: string;
|
|
300
|
+
/**
|
|
301
|
+
* The tracking reference that was applied, if any.
|
|
302
|
+
*/
|
|
303
|
+
tracking_reference?: string;
|
|
304
|
+
/**
|
|
305
|
+
* The type of private fare applied.
|
|
306
|
+
*/
|
|
307
|
+
type: 'corporate' | 'leisure' | 'negotiated';
|
|
308
|
+
}
|
|
291
309
|
interface OfferPassenger {
|
|
292
310
|
/**
|
|
293
311
|
* The age of the passenger on the departure_date of the final slice.
|
|
@@ -436,6 +454,32 @@ interface OfferSliceSegment {
|
|
|
436
454
|
* Additional segment-specific information about the passengers included in the offer (e.g. their baggage allowance and the cabin class they will be travelling in)
|
|
437
455
|
*/
|
|
438
456
|
passengers: OfferSliceSegmentPassenger[];
|
|
457
|
+
/**
|
|
458
|
+
* Additional segment-specific information about the stops, if any, included in the segment
|
|
459
|
+
*/
|
|
460
|
+
stops?: OfferSliceSegmentStop[];
|
|
461
|
+
}
|
|
462
|
+
interface OfferSliceSegmentStop {
|
|
463
|
+
/**
|
|
464
|
+
* Duffel's unique identifier for the Stop
|
|
465
|
+
*/
|
|
466
|
+
id: string;
|
|
467
|
+
/**
|
|
468
|
+
* The airport at which the Stop happens
|
|
469
|
+
*/
|
|
470
|
+
airport: Airport;
|
|
471
|
+
/**
|
|
472
|
+
* The ISO 8601 datetime at which the Stop is scheduled to arrive, in the airport's timezone (see destination.timezone)
|
|
473
|
+
*/
|
|
474
|
+
arrivingAt: string;
|
|
475
|
+
/**
|
|
476
|
+
* The ISO 8601 datetime at which the Stop is scheduled to depart, in the airport's timezone (see origin.timezone)
|
|
477
|
+
*/
|
|
478
|
+
departingAt: string;
|
|
479
|
+
/**
|
|
480
|
+
* The duration of the Stop, represented as a ISO 8601 duration
|
|
481
|
+
*/
|
|
482
|
+
duration: string;
|
|
439
483
|
}
|
|
440
484
|
interface OfferSliceSegmentPassenger {
|
|
441
485
|
/**
|
|
@@ -530,6 +574,83 @@ interface OfferRequestSlice {
|
|
|
530
574
|
*/
|
|
531
575
|
destination_type: PlaceType;
|
|
532
576
|
}
|
|
577
|
+
interface CreateOfferRequestPassengerCommon {
|
|
578
|
+
/**
|
|
579
|
+
* The passenger's family name. Only `space`, `-`, `'`, and letters from the
|
|
580
|
+
* `ASCII`, `Latin-1 Supplement` and `Latin Extended-A` (with the exceptions
|
|
581
|
+
* of `Æ`, `æ`, `IJ`, `ij`, `Œ`, `œ`, `Þ`, and `ð`) Unicode charts are accepted.
|
|
582
|
+
* All other characters will result in a validation error. The minimum length
|
|
583
|
+
* is 1 character, and the maximum is 20 characters.
|
|
584
|
+
*
|
|
585
|
+
* This is only required if you're also including
|
|
586
|
+
* **Loyalty Programme Accounts**.
|
|
587
|
+
*/
|
|
588
|
+
family_name?: string;
|
|
589
|
+
/**
|
|
590
|
+
* The passenger's given name. Only `space`, `-`, `'`, and letters from the
|
|
591
|
+
* `ASCII`, `Latin-1 Supplement` and `Latin Extended-A` (with the exceptions
|
|
592
|
+
* of `Æ`, `æ`, `IJ`, `ij`, `Œ`, `œ`, `Þ`, and `ð`) Unicode charts are accepted.
|
|
593
|
+
* All other characters will result in a validation error. The minimum length
|
|
594
|
+
* is 1 character, and the maximum is 20 characters.
|
|
595
|
+
*
|
|
596
|
+
* This is only required if you're also including
|
|
597
|
+
* **Loyalty Programme Accounts**.
|
|
598
|
+
*/
|
|
599
|
+
given_name?: string;
|
|
600
|
+
/**
|
|
601
|
+
* The **Loyalty Programme Accounts** for this passenger.
|
|
602
|
+
*/
|
|
603
|
+
loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
|
|
604
|
+
}
|
|
605
|
+
interface CreateOfferRequestAdultPassenger extends CreateOfferRequestPassengerCommon {
|
|
606
|
+
age?: never;
|
|
607
|
+
fare_type?: never;
|
|
608
|
+
/**
|
|
609
|
+
* The type of the passenger. If the passenger is aged 18 or over, you should
|
|
610
|
+
* specify a `type` of `adult`. If a passenger is aged under 18, you should
|
|
611
|
+
* specify their `age` instead of a `type`. A passenger can have only a type
|
|
612
|
+
* or an age, but not both.
|
|
613
|
+
*/
|
|
614
|
+
type: Extract<DuffelPassengerType, 'adult'>;
|
|
615
|
+
}
|
|
616
|
+
interface CreateOfferRequestNonAdultPassenger extends CreateOfferRequestPassengerCommon {
|
|
617
|
+
/**
|
|
618
|
+
* The age of the passenger on the `departure_date` of the final slice. e.g.
|
|
619
|
+
* if you a searching for a round trip and the passenger is 15 years old at
|
|
620
|
+
* the time of the outbound flight, but they then have their birthday and are
|
|
621
|
+
* 16 years old for the inbound flight, you must set the age to 16. You should
|
|
622
|
+
* specify an `age` for passengers who are under 18 years old. A passenger can
|
|
623
|
+
* have only a type or an age, but not both. You can optionally pass age with
|
|
624
|
+
* `fare_type` though.
|
|
625
|
+
*/
|
|
626
|
+
age: number;
|
|
627
|
+
fare_type?: never;
|
|
628
|
+
type?: never;
|
|
629
|
+
}
|
|
630
|
+
declare type CreateOfferRequestPassengerFareType = 'accompanying_adult' | 'contract_bulk' | 'contract_bulk_child' | 'contract_bulk_infant_with_seat' | 'contract_bulk_infant_without_seat' | 'frequent_flyer' | 'group_inclusive_tour' | 'group_inclusive_tour_child' | 'humanitarian' | 'individual_inclusive_tour_child' | 'marine' | 'seat_only' | 'student' | 'teacher' | 'tour_operator_inclusive' | 'tour_operator_inclusive_infant' | 'unaccompanied_child' | 'visiting_friends_and_family';
|
|
631
|
+
interface CreateOfferRequestPassengerWithFareType extends CreateOfferRequestPassengerCommon {
|
|
632
|
+
/**
|
|
633
|
+
* The age of the passenger on the `departure_date` of the final slice. e.g.
|
|
634
|
+
* if you a searching for a round trip and the passenger is 15 years old at
|
|
635
|
+
* the time of the outbound flight, but they then have their birthday and are
|
|
636
|
+
* 16 years old for the inbound flight, you must set the age to 16. You should
|
|
637
|
+
* specify an `age` for passengers who are under 18 years old. A passenger can
|
|
638
|
+
* have only a type or an age, but not both. You can optionally pass age with
|
|
639
|
+
* `fare_type` though.
|
|
640
|
+
*/
|
|
641
|
+
age?: number;
|
|
642
|
+
/**
|
|
643
|
+
* The fare type of the passenger. If the passenger is aged less than 18, you
|
|
644
|
+
* should pass in age as well.
|
|
645
|
+
*/
|
|
646
|
+
fare_type: CreateOfferRequestPassengerFareType;
|
|
647
|
+
type?: never;
|
|
648
|
+
}
|
|
649
|
+
declare type CreateOfferRequestPassenger = CreateOfferRequestAdultPassenger | CreateOfferRequestNonAdultPassenger | CreateOfferRequestPassengerWithFareType;
|
|
650
|
+
interface CreateOfferRequestPrivateFare {
|
|
651
|
+
corporate_code: string;
|
|
652
|
+
tracking_reference: string;
|
|
653
|
+
}
|
|
533
654
|
/**
|
|
534
655
|
* The passengers who want to travel. A passenger will have only a type or an age.
|
|
535
656
|
*/
|
|
@@ -624,24 +745,40 @@ interface OfferRequest {
|
|
|
624
745
|
}
|
|
625
746
|
interface CreateOfferRequest {
|
|
626
747
|
/**
|
|
627
|
-
* The cabin that the passengers want to travel in
|
|
748
|
+
* The cabin that the passengers want to travel in.
|
|
628
749
|
*/
|
|
629
750
|
cabin_class?: CabinClass;
|
|
630
751
|
/**
|
|
631
|
-
* The
|
|
632
|
-
*
|
|
752
|
+
* The maximum number of connections within any slice of the offer. For
|
|
753
|
+
* example 0 means a direct flight which will have a single segment within
|
|
754
|
+
* each slice and 1 means a maximum of two segments within each slice of the
|
|
755
|
+
* offer.
|
|
633
756
|
*/
|
|
634
|
-
|
|
757
|
+
max_connections?: 0 | 1 | 2;
|
|
635
758
|
/**
|
|
636
|
-
* The
|
|
637
|
-
*
|
|
759
|
+
* The passengers who want to travel. If you specify an `age` for a passenger,
|
|
760
|
+
* the `type` may differ for the same passenger in different offers due to
|
|
761
|
+
* airline's different rules. E.g. one airline may treat a 14 year old as an
|
|
762
|
+
* adult, and another as a young adult. You may only specify an `age` or a
|
|
763
|
+
* `type` – not both.
|
|
638
764
|
*/
|
|
639
|
-
|
|
765
|
+
passengers: CreateOfferRequestPassenger[];
|
|
640
766
|
/**
|
|
641
|
-
* The
|
|
642
|
-
*
|
|
767
|
+
* The private fare codes for this Offer Request. You can pass in multiple
|
|
768
|
+
* airlines with their specific private fare codes. The key is the airline's
|
|
769
|
+
* IATA code that provided the private fare code. The `corporate_code` is
|
|
770
|
+
* provided to you by the airline and the `tracking_reference` is to identify
|
|
771
|
+
* your business by the airlines.
|
|
643
772
|
*/
|
|
644
|
-
|
|
773
|
+
private_fares?: {
|
|
774
|
+
[iataCode: string]: CreateOfferRequestPrivateFare[];
|
|
775
|
+
};
|
|
776
|
+
/**
|
|
777
|
+
* The [slices](https://duffel.com/docs/api/overview/key-principles) that make
|
|
778
|
+
* up this offer request. One-way journeys can be expressed using one slice,
|
|
779
|
+
* whereas return trips will need two.
|
|
780
|
+
*/
|
|
781
|
+
slices: Omit<OfferRequestSlice, 'origin_type' | 'destination_type'>[];
|
|
645
782
|
}
|
|
646
783
|
interface CreateOfferRequestQueryParameters {
|
|
647
784
|
/**
|
|
@@ -3078,4 +3215,4 @@ declare class Duffel {
|
|
|
3078
3215
|
}
|
|
3079
3216
|
declare const DuffelError: typeof DuffelError$1;
|
|
3080
3217
|
|
|
3081
|
-
export { AddServices, Aircraft$1 as Aircraft, Airline, AirlineInitiatedChange, AirlineInitiatedChangeActionTaken, AirlineInitiatedChangeAvailableAction, 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, OfferAvailableServiceBaggage, OfferAvailableServiceBaggageMetadata, OfferAvailableServiceCFAR, OfferAvailableServiceCFARMetadata, OfferAvailableServiceCommon, OfferPassenger, OfferRequest, OfferRequestPassenger, OfferRequestSlice, OfferSlice, OfferSliceSegment, OfferSliceSegmentPassenger, OfferSliceSegmentPassengerBaggage, 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 };
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duffel/api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.0",
|
|
4
4
|
"description": "Javascript client library for the Duffel API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@types/node": "^17.0.21",
|
|
55
55
|
"@types/node-fetch": "^2.6.2",
|
|
56
|
-
"node-fetch": "2.6.
|
|
56
|
+
"node-fetch": "2.6.9"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "7.
|
|
59
|
+
"@babel/core": "7.21.0",
|
|
60
60
|
"@babel/preset-env": "7.20.2",
|
|
61
|
-
"@babel/preset-typescript": "7.
|
|
62
|
-
"@commitlint/cli": "17.4.
|
|
63
|
-
"@commitlint/config-angular": "17.4.
|
|
64
|
-
"@commitlint/cz-commitlint": "17.4.
|
|
61
|
+
"@babel/preset-typescript": "7.21.0",
|
|
62
|
+
"@commitlint/cli": "17.4.4",
|
|
63
|
+
"@commitlint/config-angular": "17.4.4",
|
|
64
|
+
"@commitlint/cz-commitlint": "17.4.4",
|
|
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,14 +71,14 @@
|
|
|
71
71
|
"colors": "1.4.0",
|
|
72
72
|
"commitizen": "4.3.0",
|
|
73
73
|
"dotenv": "16.0.3",
|
|
74
|
-
"eslint": "8.
|
|
74
|
+
"eslint": "8.34.0",
|
|
75
75
|
"eslint-config-prettier": "8.5.0",
|
|
76
76
|
"eslint-plugin-spellcheck": "0.0.20",
|
|
77
77
|
"husky": "8.0.3",
|
|
78
78
|
"jest": "29.0.3",
|
|
79
|
-
"lint-staged": "13.1.
|
|
79
|
+
"lint-staged": "13.1.2",
|
|
80
80
|
"nock": "13.2.9",
|
|
81
|
-
"prettier": "2.8.
|
|
81
|
+
"prettier": "2.8.4",
|
|
82
82
|
"rollup": "2.79.1",
|
|
83
83
|
"rollup-plugin-dts": "4.2.3",
|
|
84
84
|
"rollup-plugin-inject-process-env": "1.3.1",
|