@duffel/api 1.4.0 → 1.7.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.
@@ -192,6 +192,28 @@ interface OfferPassenger {
192
192
  * The type of the passenger.
193
193
  */
194
194
  type?: 'adult';
195
+ /**
196
+ * The passenger's family name. Only `space`, `-`, `'`, and letters from the `ASCII`, `Latin-1 Supplement` and `Latin
197
+ * Extended-A` (with the exceptions of `Æ`, `æ`, `IJ`, `ij`, `Œ`, `œ`, `Þ`, , and `ð`) Unicode charts are accepted. All
198
+ * other characters will result in a validation error. The minimum length is 1 character, and the maximum is 20
199
+ * characters.
200
+ *
201
+ * This is only required if you're also including **Loyalty Programme Accounts**.
202
+ */
203
+ family_name?: string;
204
+ /**
205
+ * The passenger's given name. Only `space`, `-`, `'`, and letters from the `ASCII`, `Latin-1 Supplement` and `Latin
206
+ * Extended-A` (with the exceptions of `Æ`, `æ`, `IJ`, `ij`, `Œ`, `œ`, `Þ`, , and `ð`) Unicode charts are accepted. All
207
+ * other characters will result in a validation error. The minimum length is 1 character, and the maximum is 20
208
+ * characters.
209
+ *
210
+ * This is only required if you're also including **Loyalty Programme Accounts**.
211
+ */
212
+ given_name?: string;
213
+ /**
214
+ * The **Loyalty Programme Accounts** for this passenger.
215
+ */
216
+ loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
195
217
  /**
196
218
  * The identifier for the passenger, unique within this Offer Request and across all Offer Requests.
197
219
  * This ID will be generated by Duffel unless you had optionally provided one.
@@ -361,6 +383,24 @@ interface ListOffersParams extends PaginationMeta {
361
383
  * By default the sorting order will be ascending, if you wish to sort in descending order a - will need to be prepended to the sorting attribute (i.e: `-total_amount`).
362
384
  */
363
385
  sort?: 'total_amount' | 'total_duration';
386
+ }
387
+ interface LoyaltyProgrammeAccounts {
388
+ /**
389
+ * The passenger's account number for this Loyalty Programme Account
390
+ */
391
+ account_number: string;
392
+ /**
393
+ * The IATA code for the airline that this Loyalty Programme Account belongs to
394
+ */
395
+ airline_iata_code: string;
396
+ }
397
+ interface UpdateOffer {
398
+ type: string;
399
+ loyalty_programme_accounts: LoyaltyProgrammeAccounts;
400
+ id: string;
401
+ given_name: string;
402
+ family_name: string;
403
+ age: number;
364
404
  }
365
405
 
366
406
  interface OfferRequestSlice {
@@ -1050,6 +1090,10 @@ interface OrderPassenger {
1050
1090
  * @return "adult", "child", or "infant_without_seat"
1051
1091
  */
1052
1092
  infant_passenger_id?: string | null;
1093
+ /**
1094
+ * The **Loyalty Programme Accounts** for this passenger.
1095
+ */
1096
+ loyalty_programme_accounts?: LoyaltyProgrammeAccount[];
1053
1097
  }
1054
1098
  interface OrderPassengerIdentityDocument {
1055
1099
  /**
@@ -1713,6 +1757,119 @@ interface Airport {
1713
1757
  time_zone: string;
1714
1758
  }
1715
1759
 
1760
+ interface PaymentIntent {
1761
+ /**
1762
+ * The amount of the Payment Intent that covers the cost of the flight being sold and any additional markup.
1763
+ * The card payment will be charged this amount.
1764
+ */
1765
+ amount: string;
1766
+ /**
1767
+ * The [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) code of the country that issued the card used to confirm the Payment Intent.
1768
+ * It will be null until the Payment Intent is confirmed.
1769
+ */
1770
+ card_country_code: string | null;
1771
+ /**
1772
+ * The last four digits of the card used to confirm the Payment Intent.
1773
+ * It will be null until the Payment Intent is confirmed.
1774
+ */
1775
+ card_last_four_digits: string | null;
1776
+ /**
1777
+ * The card network in which the Payment Intent was processed on.
1778
+ * It will be null until the Payment Intent is confirmed.
1779
+ */
1780
+ card_network: 'amex' | 'cartes_bancaires' | 'diners' | 'discover' | 'interac' | 'jcb' | 'mastercard' | 'unionpay' | 'visa' | 'unknown' | null;
1781
+ /**
1782
+ * This value is used when displaying the payment collection form to securely identify and transmit the values to Duffel.
1783
+ */
1784
+ client_token: string;
1785
+ /**
1786
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was confirmed
1787
+ */
1788
+ confirmed_at: string;
1789
+ /**
1790
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was created
1791
+ */
1792
+ created_at: string;
1793
+ /**
1794
+ * The currency of the `amount`, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1795
+ * The card payment will be charged in this currency.
1796
+ * If it's different to your Balance currency, it will be converted to your Balance currency before the Balance is topped up.
1797
+ */
1798
+ currency: string;
1799
+ /**
1800
+ * The amount of the fees to process the Payment Intent.
1801
+ * It will be `null` until the Payment Intent is confirmed.
1802
+ */
1803
+ fees_amount: string | null;
1804
+ /**
1805
+ * The currency of the fees_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1806
+ * This currency will match your Balance currency.
1807
+ * It will be null until the Payment Intent is confirmed.
1808
+ */
1809
+ fees_currency: string | null;
1810
+ /**
1811
+ * Duffel's unique identifier for the `Payment Intent`
1812
+ */
1813
+ id: string;
1814
+ /**
1815
+ * Whether the Payment Intent was created in live mode. This field will be set to `true` if the Payment Intent was created in live mode, or `false` if it was created in test mode.
1816
+ */
1817
+ live_mode: boolean;
1818
+ /**
1819
+ * The amount of the Payment Intent that was added to the Balance.
1820
+ * It'll be `amount` (in the Balance currency) less the `fees_amount`.
1821
+ * It will be `null` until the Payment Intent is confirmed.
1822
+ */
1823
+ net_amount: string | null;
1824
+ /**
1825
+ * The currency of the net_amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1826
+ * This currency will match your Balance currency.
1827
+ * It will be null until the Payment Intent is confirmed.
1828
+ */
1829
+ net_currency: string | null;
1830
+ /**
1831
+ * The Refunds for this Payment Intent
1832
+ * @link https://duffel.com/docs/api/payment-intents/schema#payment-intents-schema-refunds
1833
+ */
1834
+ refunds: {
1835
+ amount: string;
1836
+ arrival: string;
1837
+ created_at: string;
1838
+ currency: string;
1839
+ destination: string;
1840
+ id: string;
1841
+ live_mode: boolean;
1842
+ net_amount: string;
1843
+ net_currency: string;
1844
+ payment_intent_id: string;
1845
+ status: 'succeeded' | 'pending' | 'failed';
1846
+ updated_at: string;
1847
+ }[];
1848
+ /**
1849
+ * The status of this Payment Intent
1850
+ */
1851
+ status: null | 'requires_payment_method' | 'requires_confirmation' | 'requires_action' | 'processing' | 'requires_capture' | 'cancelled' | 'succeeded';
1852
+ /**
1853
+ * The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) datetime at which the Payment Intent was updated
1854
+ */
1855
+ updated_at: string;
1856
+ }
1857
+ interface CreatePaymentIntent {
1858
+ /**
1859
+ * This is the amount that the card payment being taken will be charged.
1860
+ * It should be enough to cover the service(s) you want to sell (enough to book an Offer for example) and the processing fees.
1861
+ * If the currency is different from your Balance currency you should also account for foreign exchange.
1862
+ * It can be higher than that, in which case the remainder will be considered your markup.
1863
+ * If it's higher than the maximum allowed for you organisation you will get a validation error. By default the maximum is 5,000.00 GBP (or equivalent in the same currency). If you need a maximum higher than the default please get in touch with us via help@duffel.com.
1864
+ */
1865
+ amount: string;
1866
+ /**
1867
+ * The currency of the amount, as an [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code.
1868
+ * This is going to be the currency that the card payment being taken in will be charged in.
1869
+ */
1870
+ currency: string;
1871
+ }
1872
+
1716
1873
  /**
1717
1874
  * The metropolitan area where the airport is located.
1718
1875
  * Only present for airports which are registered with IATA as belonging to a metropolitan area.
@@ -1938,7 +2095,7 @@ interface DuffelResponse<T_Data> {
1938
2095
  declare class DuffelError extends Error {
1939
2096
  meta: ApiResponseMeta;
1940
2097
  errors: ApiResponseError[];
1941
- constructor({ meta, errors }: {
2098
+ constructor({ meta, errors, }: {
1942
2099
  meta: ApiResponseMeta;
1943
2100
  errors: ApiResponseError[];
1944
2101
  });
@@ -1965,14 +2122,14 @@ declare class Client {
1965
2122
  private apiVersion;
1966
2123
  private debug;
1967
2124
  constructor({ token, basePath, apiVersion, debug }: Config);
1968
- request: <T_Data = any>({ method, path, data, params, compress }: {
2125
+ request: <T_Data = any>({ method, path, data, params, compress, }: {
1969
2126
  method: string;
1970
2127
  path: string;
1971
2128
  data?: Record<string, any> | undefined;
1972
2129
  params?: Record<string, any> | undefined;
1973
2130
  compress?: boolean | undefined;
1974
2131
  }) => Promise<DuffelResponse<T_Data>>;
1975
- paginatedRequest<T_Data = any>({ path, params }: {
2132
+ paginatedRequest<T_Data = any>({ path, params, }: {
1976
2133
  path: string;
1977
2134
  params?: Record<string, any>;
1978
2135
  }): AsyncGenerator<DuffelResponse<T_Data>, void, unknown>;
@@ -1981,18 +2138,44 @@ declare class Client {
1981
2138
  declare class Resource {
1982
2139
  private client;
1983
2140
  constructor(client: Client);
1984
- protected request: <T_Data = any>({ method, path, data, params }: {
2141
+ protected request: <T_Data = any>({ method, path, data, params, }: {
1985
2142
  method: string;
1986
2143
  path: string;
1987
2144
  data?: Record<string, any> | undefined;
1988
2145
  params?: Record<string, any> | undefined;
1989
2146
  }) => Promise<DuffelResponse<T_Data>>;
1990
- protected paginatedRequest: <T_Data = any>({ path, params }: {
2147
+ protected paginatedRequest: <T_Data = any>({ path, params, }: {
1991
2148
  path: string;
1992
2149
  params?: Record<string, any> | undefined;
1993
2150
  }) => AsyncGenerator<DuffelResponse<T_Data>, void, unknown>;
1994
2151
  }
1995
2152
 
2153
+ declare class PaymentIntents extends Resource {
2154
+ /**
2155
+ * Endpoint path
2156
+ */
2157
+ path: string;
2158
+ constructor(args: any);
2159
+ /**
2160
+ * You should use this API to get the complete, up-to-date information about a Payment Intent.
2161
+ * @param {string} id - Duffel's unique identifier for the Payment Intent
2162
+ * @link https://duffel.com/docs/api/payment-intents/get-payment-intent-by-id
2163
+ */
2164
+ get: (id: string) => Promise<DuffelResponse<PaymentIntent>>;
2165
+ /**
2166
+ * Once you've successfully collected the customer's card details, using the `client_token` from when you first created the Payment Intent, you then need to confirm it using this endpoint.
2167
+ * Once confirmed, the amount charged to your customer's card will be added to your `Balance` (minus any Duffel Payment fees).
2168
+ */
2169
+ confirm: (id: string) => Promise<DuffelResponse<PaymentIntent>>;
2170
+ /**
2171
+ * To begin the process of collecting a card payment from your customer, you need to create a Payment Intent.
2172
+ * The Payment Intent will contain a `client_token` that you use to collect the card payment in your application.
2173
+ * If the Payment Intent is created in test mode you should use a [test card](https://duffel.com/docs/api/overview/test-mode/test-card-numbers).
2174
+ * @param {Object.<CreatePaymentIntent>} params - Endpoint params (amount and string)
2175
+ */
2176
+ create: (params: CreatePaymentIntent) => Promise<DuffelResponse<PaymentIntent>>;
2177
+ }
2178
+
1996
2179
  /**
1997
2180
  * To search for flights, you'll need to create an `offer request`.
1998
2181
  * An offer request describes the passengers and where and when they want to travel (in the form of a list of `slices`).
@@ -2034,6 +2217,14 @@ declare class OfferRequests extends Resource {
2034
2217
  create: (options: Partial<CreateOfferRequest & CreateOfferRequestQueryParameters>) => Promise<DuffelResponse<OfferRequest>>;
2035
2218
  }
2036
2219
 
2220
+ interface UpdateOfferBodyParameters {
2221
+ loyalty_programme_accounts: LoyaltyProgrammeAccounts[];
2222
+ given_name: string;
2223
+ family_name: string;
2224
+ }
2225
+ interface UpdateOfferBodyParametersWithoutLoyalty {
2226
+ loyalty_programme_accounts: never;
2227
+ }
2037
2228
  /**
2038
2229
  * Each offer represents flights you can buy from an airline at a particular price that meet your search criteria.
2039
2230
  * @class
@@ -2068,6 +2259,15 @@ declare class Offers extends Resource {
2068
2259
  * @link https://duffel.com/docs/api/offers/get-offers
2069
2260
  */
2070
2261
  listWithGenerator: ({ offer_request_id, ...params }: ListOffersParams) => AsyncGenerator<DuffelResponse<Offer>, void, unknown>;
2262
+ /**
2263
+ * Some offer passenger fields are updateable. Each field that can be updated is detailed in the request object.
2264
+ * @param {string} offerId - Duffel's unique identifier for the offer
2265
+ * @param {string} passengerId - The identifier for the passenger. This ID will be generated by Duffel
2266
+ * @param {string} params.family_name - The passenger's family name. Only space, -, ', and letters from the ASCII, Latin-1 Supplement and Latin Extended-A (with the exceptions of Æ, æ, IJ, ij, Œ, œ, Þ, and ð) Unicode charts are accepted. All other characters will result in a validation error. The minimum length is 1 character, and the maximum is 20 characters. This is only required if you're also including Loyalty Programme Accounts.
2267
+ * @param {string} params.given_name - The passenger's given name. Only space, -, ', and letters from the ASCII, Latin-1 Supplement and Latin Extended-A (with the exceptions of Æ, æ, IJ, ij, Œ, œ, Þ, and ð) Unicode charts are accepted. All other characters will result in a validation error. The minimum length is 1 character, and the maximum is 20 characters. This is only required if you're also including Loyalty Programme Accounts.
2268
+ * @param {Object.<LoyaltyProgrammeAccounts>} params.loyalty_programme_accounts - The Loyalty Programme Accounts for this passenger
2269
+ */
2270
+ update: (offerId: string, passengerId: string, params?: UpdateOfferBodyParameters | UpdateOfferBodyParametersWithoutLoyalty | undefined) => Promise<DuffelResponse<UpdateOffer>>;
2071
2271
  }
2072
2272
 
2073
2273
  declare class OrderCancellations extends Resource {
@@ -2370,7 +2570,8 @@ declare class Duffel {
2370
2570
  orderCancellations: OrderCancellations;
2371
2571
  payments: Payments;
2372
2572
  seatMaps: SeatMaps;
2573
+ paymentIntents: PaymentIntents;
2373
2574
  constructor(config: Config);
2374
2575
  }
2375
2576
 
2376
- export { Aircraft$1 as Aircraft, Airline, Airport, ApiResponseError, ApiResponseMeta, BaggageType, CabinClass, City, ConfirmOrderChangePayment, CreateOfferRequest, CreateOfferRequestQueryParameters, CreateOrder, CreateOrderCancellation, CreateOrderChangeParameters, CreateOrderChangeRequest, CreateOrderPassenger, CreatePayment, Duffel, DuffelAPIClient, DuffelError, DuffelPassengerGender, DuffelPassengerTitle, DuffelPassengerType, DuffelResponse, FlightsConditions, ListOffersParams, ListParamsOrders, LoyaltyProgrammeAccount, 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, PaymentRequirements, PaymentType, Place, PlaceType, SDKOptions, Seat, SeatMap, SeatMapCabin, SeatMapCabinRow, SeatMapCabinRowSection, SeatMapCabinRowSectionAvailableService, SeatMapCabinRowSectionElement, SeatMapCabinRowSectionElementAmenity, SeatMapCabinRowSectionElementBassinet, SeatMapCabinRowSectionElementCloset, SeatMapCabinRowSectionElementEmpty, SeatMapCabinRowSectionElementExitRow, SeatMapCabinRowSectionElementGalley, SeatMapCabinRowSectionElementLavatory, SeatMapCabinRowSectionElementSeat, SeatMapCabinRowSectionElementStairs, SeatMapCabinRowSectionElementType, UpdateSingleOrder, ValidationError };
2577
+ 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, 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, ValidationError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duffel/api",
3
- "version": "1.4.0",
3
+ "version": "1.7.0",
4
4
  "description": "Javascript client library for the Duffel API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -22,19 +22,30 @@
22
22
  "dev": "ts-node ./src/index.ts",
23
23
  "lint": "eslint . --ext .ts,.tsx",
24
24
  "test": "jest",
25
- "pre-push-check": "yarn lint && yarn test && yarn build:test",
25
+ "pre-commit-check": "yarn lint-staged && yarn test && yarn build:test",
26
26
  "prepare": "husky install",
27
27
  "example": "ts-node ./examples/example.ts",
28
28
  "get-version": "echo $npm_package_version",
29
29
  "release": "npx semantic-release",
30
30
  "commit": "git-cz",
31
- "commitlint": "commitlint"
31
+ "commitlint": "commitlint",
32
+ "prettier": "prettier --write --loglevel=warn .",
33
+ "prettier-check": "prettier --check ."
32
34
  },
33
35
  "config": {
34
36
  "commitizen": {
35
37
  "path": "@commitlint/cz-commitlint"
36
38
  }
37
39
  },
40
+ "lint-staged": {
41
+ "*.{ts,tsx}": [
42
+ "eslint",
43
+ "prettier --write"
44
+ ],
45
+ "*.{js,jsx,md,yml,yaml}": [
46
+ "prettier --write"
47
+ ]
48
+ },
38
49
  "dependencies": {
39
50
  "@types/node": "^16.0.0",
40
51
  "isomorphic-unfetch": "^3.1.0"
@@ -43,9 +54,9 @@
43
54
  "@babel/core": "^7.15.5",
44
55
  "@babel/preset-env": "^7.15.4",
45
56
  "@babel/preset-typescript": "^7.14.5",
46
- "@commitlint/cli": "^13.1.0",
47
- "@commitlint/config-angular": "^13.1.0",
48
- "@commitlint/cz-commitlint": "^13.1.0",
57
+ "@commitlint/cli": "^14.1.0",
58
+ "@commitlint/config-angular": "^14.1.0",
59
+ "@commitlint/cz-commitlint": "^14.1.0",
49
60
  "@rollup/plugin-commonjs": "^21.0.0",
50
61
  "@rollup/plugin-multi-entry": "^4.0.0",
51
62
  "@rollup/plugin-node-resolve": "^13.0.0",
@@ -56,10 +67,13 @@
56
67
  "commitizen": "^4.2.4",
57
68
  "dotenv": "^10.0.0",
58
69
  "eslint": "^7.26.0",
70
+ "eslint-config-prettier": "^8.3.0",
59
71
  "eslint-plugin-spellcheck": "^0.0.19",
60
72
  "husky": "^7.0.0",
61
73
  "jest": "^26.6.3",
74
+ "lint-staged": "^12.0.1",
62
75
  "nock": "^13.1.0",
76
+ "prettier": "^2.4.1",
63
77
  "rollup": "^2.51.2",
64
78
  "rollup-plugin-dts": "^4.0.0",
65
79
  "rollup-plugin-inject-process-env": "^1.3.1",