@getivy/node-sdk 0.1.0-alpha.34 → 0.1.0-alpha.35
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/CHANGELOG.md +44 -0
- package/README.md +2 -0
- package/core.d.ts +7 -4
- package/core.d.ts.map +1 -1
- package/core.js +16 -9
- package/core.js.map +1 -1
- package/core.mjs +16 -9
- package/core.mjs.map +1 -1
- package/index.d.mts +3 -0
- package/index.d.ts +3 -0
- package/index.d.ts.map +1 -1
- package/index.js +6 -2
- package/index.js.map +1 -1
- package/index.mjs +6 -2
- package/index.mjs.map +1 -1
- package/package.json +4 -5
- package/resources/banks.d.ts +3 -3
- package/resources/banks.d.ts.map +1 -1
- package/resources/checkoutsession.d.ts +16 -19
- package/resources/checkoutsession.d.ts.map +1 -1
- package/resources/orders.d.ts +10 -6
- package/resources/orders.d.ts.map +1 -1
- package/resources/payouts.d.ts +132 -92
- package/resources/payouts.d.ts.map +1 -1
- package/resources/payouts.js +3 -4
- package/resources/payouts.js.map +1 -1
- package/resources/payouts.mjs +3 -4
- package/resources/payouts.mjs.map +1 -1
- package/resources/refunds.d.ts +4 -0
- package/resources/refunds.d.ts.map +1 -1
- package/resources/refunds.js +4 -0
- package/resources/refunds.js.map +1 -1
- package/resources/refunds.mjs +4 -0
- package/resources/refunds.mjs.map +1 -1
- package/resources/reports.d.ts +4 -0
- package/resources/reports.d.ts.map +1 -1
- package/resources/reports.js +4 -0
- package/resources/reports.js.map +1 -1
- package/resources/reports.mjs +4 -0
- package/resources/reports.mjs.map +1 -1
- package/resources/subaccounts.d.ts +0 -2
- package/resources/subaccounts.d.ts.map +1 -1
- package/src/core.ts +17 -8
- package/src/index.ts +11 -0
- package/src/resources/banks.ts +9 -0
- package/src/resources/checkoutsession.ts +8 -28
- package/src/resources/orders.ts +8 -4
- package/src/resources/payouts.ts +129 -128
- package/src/resources/refunds.ts +4 -0
- package/src/resources/reports.ts +4 -0
- package/src/resources/subaccounts.ts +0 -4
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/core.ts
CHANGED
|
@@ -170,6 +170,7 @@ export class APIPromise<T> extends Promise<T> {
|
|
|
170
170
|
|
|
171
171
|
export abstract class APIClient {
|
|
172
172
|
baseURL: string;
|
|
173
|
+
#baseURLOverridden: boolean;
|
|
173
174
|
maxRetries: number;
|
|
174
175
|
timeout: number;
|
|
175
176
|
httpAgent: Agent | undefined;
|
|
@@ -179,18 +180,21 @@ export abstract class APIClient {
|
|
|
179
180
|
|
|
180
181
|
constructor({
|
|
181
182
|
baseURL,
|
|
183
|
+
baseURLOverridden,
|
|
182
184
|
maxRetries = 2,
|
|
183
185
|
timeout = 60000, // 1 minute
|
|
184
186
|
httpAgent,
|
|
185
187
|
fetch: overriddenFetch,
|
|
186
188
|
}: {
|
|
187
189
|
baseURL: string;
|
|
190
|
+
baseURLOverridden: boolean;
|
|
188
191
|
maxRetries?: number | undefined;
|
|
189
192
|
timeout: number | undefined;
|
|
190
193
|
httpAgent: Agent | undefined;
|
|
191
194
|
fetch: Fetch | undefined;
|
|
192
195
|
}) {
|
|
193
196
|
this.baseURL = baseURL;
|
|
197
|
+
this.#baseURLOverridden = baseURLOverridden;
|
|
194
198
|
this.maxRetries = validatePositiveInteger('maxRetries', maxRetries);
|
|
195
199
|
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
196
200
|
this.httpAgent = httpAgent;
|
|
@@ -213,7 +217,7 @@ export abstract class APIClient {
|
|
|
213
217
|
protected defaultHeaders(opts: FinalRequestOptions): Headers {
|
|
214
218
|
return {
|
|
215
219
|
Accept: 'application/json',
|
|
216
|
-
'Content-Type': 'application/json',
|
|
220
|
+
...(['head', 'get'].includes(opts.method) ? {} : { 'Content-Type': 'application/json' }),
|
|
217
221
|
'User-Agent': this.getUserAgent(),
|
|
218
222
|
...getPlatformHeaders(),
|
|
219
223
|
...this.authHeaders(opts),
|
|
@@ -295,12 +299,12 @@ export abstract class APIClient {
|
|
|
295
299
|
return null;
|
|
296
300
|
}
|
|
297
301
|
|
|
298
|
-
buildRequest<Req>(
|
|
302
|
+
async buildRequest<Req>(
|
|
299
303
|
inputOptions: FinalRequestOptions<Req>,
|
|
300
304
|
{ retryCount = 0 }: { retryCount?: number } = {},
|
|
301
|
-
): { req: RequestInit; url: string; timeout: number } {
|
|
305
|
+
): Promise<{ req: RequestInit; url: string; timeout: number }> {
|
|
302
306
|
const options = { ...inputOptions };
|
|
303
|
-
const { method, path, query, headers: headers = {} } = options;
|
|
307
|
+
const { method, path, query, defaultBaseURL, headers: headers = {} } = options;
|
|
304
308
|
|
|
305
309
|
const body =
|
|
306
310
|
ArrayBuffer.isView(options.body) || (options.__binaryRequest && typeof options.body === 'string') ?
|
|
@@ -310,7 +314,7 @@ export abstract class APIClient {
|
|
|
310
314
|
: null;
|
|
311
315
|
const contentLength = this.calculateContentLength(body);
|
|
312
316
|
|
|
313
|
-
const url = this.buildURL(path!, query);
|
|
317
|
+
const url = this.buildURL(path!, query, defaultBaseURL);
|
|
314
318
|
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
|
|
315
319
|
options.timeout = options.timeout ?? this.timeout;
|
|
316
320
|
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
|
|
@@ -446,7 +450,9 @@ export abstract class APIClient {
|
|
|
446
450
|
|
|
447
451
|
await this.prepareOptions(options);
|
|
448
452
|
|
|
449
|
-
const { req, url, timeout } = this.buildRequest(options, {
|
|
453
|
+
const { req, url, timeout } = await this.buildRequest(options, {
|
|
454
|
+
retryCount: maxRetries - retriesRemaining,
|
|
455
|
+
});
|
|
450
456
|
|
|
451
457
|
await this.prepareRequest(req, { url, options });
|
|
452
458
|
|
|
@@ -503,11 +509,12 @@ export abstract class APIClient {
|
|
|
503
509
|
return new PagePromise<PageClass, Item>(this, request, Page);
|
|
504
510
|
}
|
|
505
511
|
|
|
506
|
-
buildURL<Req>(path: string, query: Req | null | undefined): string {
|
|
512
|
+
buildURL<Req>(path: string, query: Req | null | undefined, defaultBaseURL?: string | undefined): string {
|
|
513
|
+
const baseURL = (!this.#baseURLOverridden && defaultBaseURL) || this.baseURL;
|
|
507
514
|
const url =
|
|
508
515
|
isAbsoluteURL(path) ?
|
|
509
516
|
new URL(path)
|
|
510
|
-
: new URL(
|
|
517
|
+
: new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
|
|
511
518
|
|
|
512
519
|
const defaultQuery = this.defaultQuery();
|
|
513
520
|
if (!isEmptyObj(defaultQuery)) {
|
|
@@ -792,6 +799,7 @@ export type RequestOptions<
|
|
|
792
799
|
query?: Req | undefined;
|
|
793
800
|
body?: Req | null | undefined;
|
|
794
801
|
headers?: Headers | undefined;
|
|
802
|
+
defaultBaseURL?: string | undefined;
|
|
795
803
|
|
|
796
804
|
maxRetries?: number;
|
|
797
805
|
stream?: boolean | undefined;
|
|
@@ -813,6 +821,7 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
|
|
|
813
821
|
query: true,
|
|
814
822
|
body: true,
|
|
815
823
|
headers: true,
|
|
824
|
+
defaultBaseURL: true,
|
|
816
825
|
|
|
817
826
|
maxRetries: true,
|
|
818
827
|
stream: true,
|
package/src/index.ts
CHANGED
|
@@ -117,6 +117,8 @@ export interface ClientOptions {
|
|
|
117
117
|
*
|
|
118
118
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
119
119
|
* much longer than this timeout before the promise succeeds or fails.
|
|
120
|
+
*
|
|
121
|
+
* @unit milliseconds
|
|
120
122
|
*/
|
|
121
123
|
timeout?: number | undefined;
|
|
122
124
|
|
|
@@ -208,6 +210,7 @@ export class Ivy extends Core.APIClient {
|
|
|
208
210
|
|
|
209
211
|
super({
|
|
210
212
|
baseURL: options.baseURL || environments[options.environment || 'production'],
|
|
213
|
+
baseURLOverridden: baseURL ? baseURL !== environments[options.environment || 'production'] : false,
|
|
211
214
|
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
212
215
|
httpAgent: options.httpAgent,
|
|
213
216
|
maxRetries: options.maxRetries,
|
|
@@ -234,6 +237,13 @@ export class Ivy extends Core.APIClient {
|
|
|
234
237
|
balance: API.Balance = new API.Balance(this);
|
|
235
238
|
webhooksubscription: API.Webhooksubscription = new API.Webhooksubscription(this);
|
|
236
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Check whether the base URL is set to its default.
|
|
242
|
+
*/
|
|
243
|
+
#baseURLOverridden(): boolean {
|
|
244
|
+
return this.baseURL !== environments[this._options.environment || 'production'];
|
|
245
|
+
}
|
|
246
|
+
|
|
237
247
|
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
238
248
|
return this._options.defaultQuery;
|
|
239
249
|
}
|
|
@@ -284,6 +294,7 @@ Ivy.Reports = Reports;
|
|
|
284
294
|
Ivy.Subaccounts = Subaccounts;
|
|
285
295
|
Ivy.Balance = Balance;
|
|
286
296
|
Ivy.Webhooksubscription = Webhooksubscription;
|
|
297
|
+
|
|
287
298
|
export declare namespace Ivy {
|
|
288
299
|
export type RequestOptions = Core.RequestOptions;
|
|
289
300
|
|
package/src/resources/banks.ts
CHANGED
|
@@ -312,6 +312,9 @@ export interface BankRetrieveResponse {
|
|
|
312
312
|
| 'SEK_ACCOUNT_TO_ACCOUNT'
|
|
313
313
|
| 'SUMCLEARING'
|
|
314
314
|
| 'STRAKSCLEARING'
|
|
315
|
+
| 'SWIFT'
|
|
316
|
+
| 'INTERNAL'
|
|
317
|
+
| 'TARGET'
|
|
315
318
|
>;
|
|
316
319
|
|
|
317
320
|
/**
|
|
@@ -643,6 +646,9 @@ export namespace BankListResponse {
|
|
|
643
646
|
| 'SEK_ACCOUNT_TO_ACCOUNT'
|
|
644
647
|
| 'SUMCLEARING'
|
|
645
648
|
| 'STRAKSCLEARING'
|
|
649
|
+
| 'SWIFT'
|
|
650
|
+
| 'INTERNAL'
|
|
651
|
+
| 'TARGET'
|
|
646
652
|
>;
|
|
647
653
|
|
|
648
654
|
/**
|
|
@@ -975,6 +981,9 @@ export namespace BankSearchResponse {
|
|
|
975
981
|
| 'SEK_ACCOUNT_TO_ACCOUNT'
|
|
976
982
|
| 'SUMCLEARING'
|
|
977
983
|
| 'STRAKSCLEARING'
|
|
984
|
+
| 'SWIFT'
|
|
985
|
+
| 'INTERNAL'
|
|
986
|
+
| 'TARGET'
|
|
978
987
|
>;
|
|
979
988
|
|
|
980
989
|
/**
|
|
@@ -344,7 +344,7 @@ export interface CheckoutsessionCreateResponse {
|
|
|
344
344
|
|
|
345
345
|
incentiveMode?: string;
|
|
346
346
|
|
|
347
|
-
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
347
|
+
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'fi' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
348
348
|
|
|
349
349
|
mandate?: CheckoutsessionCreateResponse.Mandate;
|
|
350
350
|
|
|
@@ -600,7 +600,7 @@ export interface CheckoutsessionCreateResponse {
|
|
|
600
600
|
| 'SS'
|
|
601
601
|
| 'XK';
|
|
602
602
|
|
|
603
|
-
metadata?:
|
|
603
|
+
metadata?: { [key: string]: unknown };
|
|
604
604
|
|
|
605
605
|
offsetProject?: string;
|
|
606
606
|
|
|
@@ -1859,7 +1859,7 @@ export interface CheckoutsessionRetrieveResponse {
|
|
|
1859
1859
|
|
|
1860
1860
|
incentiveMode?: string;
|
|
1861
1861
|
|
|
1862
|
-
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
1862
|
+
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'fi' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
1863
1863
|
|
|
1864
1864
|
mandate?: CheckoutsessionRetrieveResponse.Mandate;
|
|
1865
1865
|
|
|
@@ -2115,7 +2115,7 @@ export interface CheckoutsessionRetrieveResponse {
|
|
|
2115
2115
|
| 'SS'
|
|
2116
2116
|
| 'XK';
|
|
2117
2117
|
|
|
2118
|
-
metadata?:
|
|
2118
|
+
metadata?: { [key: string]: unknown };
|
|
2119
2119
|
|
|
2120
2120
|
offsetProject?: string;
|
|
2121
2121
|
|
|
@@ -3374,7 +3374,7 @@ export interface CheckoutsessionExpireResponse {
|
|
|
3374
3374
|
|
|
3375
3375
|
incentiveMode?: string;
|
|
3376
3376
|
|
|
3377
|
-
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
3377
|
+
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'fi' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
3378
3378
|
|
|
3379
3379
|
mandate?: CheckoutsessionExpireResponse.Mandate;
|
|
3380
3380
|
|
|
@@ -3630,7 +3630,7 @@ export interface CheckoutsessionExpireResponse {
|
|
|
3630
3630
|
| 'SS'
|
|
3631
3631
|
| 'XK';
|
|
3632
3632
|
|
|
3633
|
-
metadata?:
|
|
3633
|
+
metadata?: { [key: string]: unknown };
|
|
3634
3634
|
|
|
3635
3635
|
offsetProject?: string;
|
|
3636
3636
|
|
|
@@ -4647,7 +4647,7 @@ export interface CheckoutsessionCreateParams {
|
|
|
4647
4647
|
*/
|
|
4648
4648
|
lineItems?: Array<CheckoutsessionCreateParams.LineItem>;
|
|
4649
4649
|
|
|
4650
|
-
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
4650
|
+
locale?: 'de' | 'nl' | 'en' | 'fr' | 'es' | 'fi' | 'it' | 'pt' | 'sv' | 'pl' | 'sk' | 'lt';
|
|
4651
4651
|
|
|
4652
4652
|
mandate?: CheckoutsessionCreateParams.Mandate;
|
|
4653
4653
|
|
|
@@ -4911,7 +4911,7 @@ export interface CheckoutsessionCreateParams {
|
|
|
4911
4911
|
* Any data which will be stored and returned for this checkout session and
|
|
4912
4912
|
* corresponding order
|
|
4913
4913
|
*/
|
|
4914
|
-
metadata?:
|
|
4914
|
+
metadata?: { [key: string]: unknown };
|
|
4915
4915
|
|
|
4916
4916
|
/**
|
|
4917
4917
|
* The mode in which the payment should be processed. If direct is used, you need
|
|
@@ -5337,8 +5337,6 @@ export namespace CheckoutsessionCreateParams {
|
|
|
5337
5337
|
|
|
5338
5338
|
export namespace SettlementDestination {
|
|
5339
5339
|
export interface FinancialAddress {
|
|
5340
|
-
psuData: FinancialAddress.PsuData | null;
|
|
5341
|
-
|
|
5342
5340
|
type: 'iban' | 'sort_code' | 'bank_code' | 'bban';
|
|
5343
5341
|
|
|
5344
5342
|
bankCode?: FinancialAddress.BankCode;
|
|
@@ -5347,28 +5345,10 @@ export namespace CheckoutsessionCreateParams {
|
|
|
5347
5345
|
|
|
5348
5346
|
iban?: FinancialAddress.Iban;
|
|
5349
5347
|
|
|
5350
|
-
paymentReference?: string;
|
|
5351
|
-
|
|
5352
5348
|
sortCode?: FinancialAddress.SortCode;
|
|
5353
5349
|
}
|
|
5354
5350
|
|
|
5355
5351
|
export namespace FinancialAddress {
|
|
5356
|
-
export interface PsuData {
|
|
5357
|
-
branchNumber?: string;
|
|
5358
|
-
|
|
5359
|
-
clientId?: string;
|
|
5360
|
-
|
|
5361
|
-
ipAddress?: string;
|
|
5362
|
-
|
|
5363
|
-
oib?: string;
|
|
5364
|
-
|
|
5365
|
-
psuId?: string;
|
|
5366
|
-
|
|
5367
|
-
ssn?: string;
|
|
5368
|
-
|
|
5369
|
-
username?: string;
|
|
5370
|
-
}
|
|
5371
|
-
|
|
5372
5352
|
export interface BankCode {
|
|
5373
5353
|
accountHolderName: string;
|
|
5374
5354
|
|
package/src/resources/orders.ts
CHANGED
|
@@ -146,7 +146,7 @@ export interface OrderCreateResponse {
|
|
|
146
146
|
* Set of key-value pairs that you can attach to an object. This can be useful for
|
|
147
147
|
* storing additional information about the object in a structured format.
|
|
148
148
|
*/
|
|
149
|
-
metadata?:
|
|
149
|
+
metadata?: { [key: string]: unknown };
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
152
|
* The project related to the order.
|
|
@@ -1104,7 +1104,8 @@ export namespace OrderCreateResponse {
|
|
|
1104
1104
|
| 'account_limit_exceeded'
|
|
1105
1105
|
| 'bank_under_maintenance'
|
|
1106
1106
|
| 'pin_blocked'
|
|
1107
|
-
| 'payment_not_settled'
|
|
1107
|
+
| 'payment_not_settled'
|
|
1108
|
+
| 'unsupported_bank_account';
|
|
1108
1109
|
}
|
|
1109
1110
|
|
|
1110
1111
|
export interface StatusHistoryList {
|
|
@@ -1130,6 +1131,7 @@ export namespace OrderCreateResponse {
|
|
|
1130
1131
|
| 'PAYMENT_SUCCEEDED'
|
|
1131
1132
|
| 'PAYMENT_INITIATED'
|
|
1132
1133
|
| 'ORDER_CANCELED'
|
|
1134
|
+
| 'ORDER_EXPIRED_BY_MERCHANT'
|
|
1133
1135
|
| 'ORDER_REFUND_INITIATED'
|
|
1134
1136
|
| 'ORDER_REFUNDED'
|
|
1135
1137
|
| 'REFUND_CHARGE_SUCCEEDED'
|
|
@@ -1291,7 +1293,7 @@ export interface OrderRetrieveResponse {
|
|
|
1291
1293
|
* Set of key-value pairs that you can attach to an object. This can be useful for
|
|
1292
1294
|
* storing additional information about the object in a structured format.
|
|
1293
1295
|
*/
|
|
1294
|
-
metadata?:
|
|
1296
|
+
metadata?: { [key: string]: unknown };
|
|
1295
1297
|
|
|
1296
1298
|
/**
|
|
1297
1299
|
* The project related to the order.
|
|
@@ -2249,7 +2251,8 @@ export namespace OrderRetrieveResponse {
|
|
|
2249
2251
|
| 'account_limit_exceeded'
|
|
2250
2252
|
| 'bank_under_maintenance'
|
|
2251
2253
|
| 'pin_blocked'
|
|
2252
|
-
| 'payment_not_settled'
|
|
2254
|
+
| 'payment_not_settled'
|
|
2255
|
+
| 'unsupported_bank_account';
|
|
2253
2256
|
}
|
|
2254
2257
|
|
|
2255
2258
|
export interface StatusHistoryList {
|
|
@@ -2275,6 +2278,7 @@ export namespace OrderRetrieveResponse {
|
|
|
2275
2278
|
| 'PAYMENT_SUCCEEDED'
|
|
2276
2279
|
| 'PAYMENT_INITIATED'
|
|
2277
2280
|
| 'ORDER_CANCELED'
|
|
2281
|
+
| 'ORDER_EXPIRED_BY_MERCHANT'
|
|
2278
2282
|
| 'ORDER_REFUND_INITIATED'
|
|
2279
2283
|
| 'ORDER_REFUNDED'
|
|
2280
2284
|
| 'REFUND_CHARGE_SUCCEEDED'
|