-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfinancial-accounts.ts
446 lines (387 loc) · 13 KB
/
financial-accounts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../resource';
import { isRequestOptions } from '../../core';
import * as Core from '../../core';
import * as BalancesAPI from './balances';
import { BalanceListParams, BalanceListResponse, BalanceListResponsesSinglePage, Balances } from './balances';
import * as CreditConfigurationAPI from './credit-configuration';
import {
CreditConfiguration as CreditConfigurationAPICreditConfiguration,
CreditConfigurationUpdateParams,
FinancialAccountCreditConfig,
} from './credit-configuration';
import * as FinancialTransactionsAPI from './financial-transactions';
import { FinancialTransactionListParams, FinancialTransactions } from './financial-transactions';
import * as LoanTapesAPI from './loan-tapes';
import { LoanTape, LoanTapeListParams, LoanTapes, LoanTapesCursorPage } from './loan-tapes';
import * as StatementsAPI from './statements/statements';
import { Statement, StatementListParams, Statements, StatementsCursorPage } from './statements/statements';
import { SinglePage } from '../../pagination';
export class FinancialAccounts extends APIResource {
balances: BalancesAPI.Balances = new BalancesAPI.Balances(this._client);
financialTransactions: FinancialTransactionsAPI.FinancialTransactions =
new FinancialTransactionsAPI.FinancialTransactions(this._client);
creditConfiguration: CreditConfigurationAPI.CreditConfiguration =
new CreditConfigurationAPI.CreditConfiguration(this._client);
statements: StatementsAPI.Statements = new StatementsAPI.Statements(this._client);
loanTapes: LoanTapesAPI.LoanTapes = new LoanTapesAPI.LoanTapes(this._client);
/**
* Create a new financial account
*/
create(
params: FinancialAccountCreateParams,
options?: Core.RequestOptions,
): Core.APIPromise<FinancialAccount> {
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
return this._client.post('/v1/financial_accounts', {
body,
...options,
headers: {
...(idempotencyKey != null ? { 'Idempotency-Key': idempotencyKey } : undefined),
...options?.headers,
},
});
}
/**
* Get a financial account
*/
retrieve(financialAccountToken: string, options?: Core.RequestOptions): Core.APIPromise<FinancialAccount> {
return this._client.get(`/v1/financial_accounts/${financialAccountToken}`, options);
}
/**
* Update a financial account
*/
update(
financialAccountToken: string,
body?: FinancialAccountUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<FinancialAccount>;
update(financialAccountToken: string, options?: Core.RequestOptions): Core.APIPromise<FinancialAccount>;
update(
financialAccountToken: string,
body: FinancialAccountUpdateParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<FinancialAccount> {
if (isRequestOptions(body)) {
return this.update(financialAccountToken, {}, body);
}
return this._client.patch(`/v1/financial_accounts/${financialAccountToken}`, { body, ...options });
}
/**
* Retrieve information on your financial accounts including routing and account
* number.
*/
list(
query?: FinancialAccountListParams,
options?: Core.RequestOptions,
): Core.PagePromise<FinancialAccountsSinglePage, FinancialAccount>;
list(options?: Core.RequestOptions): Core.PagePromise<FinancialAccountsSinglePage, FinancialAccount>;
list(
query: FinancialAccountListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<FinancialAccountsSinglePage, FinancialAccount> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/v1/financial_accounts', FinancialAccountsSinglePage, {
query,
...options,
});
}
/**
* Update issuing account state to charged off
*/
chargeOff(
financialAccountToken: string,
body: FinancialAccountChargeOffParams,
options?: Core.RequestOptions,
): Core.APIPromise<CreditConfigurationAPI.FinancialAccountCreditConfig> {
return this._client.post(`/v1/financial_accounts/${financialAccountToken}/charge_off`, {
body,
...options,
});
}
}
export class FinancialAccountsSinglePage extends SinglePage<FinancialAccount> {}
export class FinancialTransactionsSinglePage extends SinglePage<FinancialTransaction> {}
export interface FinancialAccount {
/**
* Globally unique identifier for the account
*/
token: string;
account_token: string | null;
created: string;
credit_configuration: FinancialAccount.CreditConfiguration | null;
/**
* Whether financial account is for the benefit of another entity
*/
is_for_benefit_of: boolean;
nickname: string | null;
type: 'ISSUING' | 'RESERVE' | 'OPERATING';
updated: string;
account_number?: string | null;
routing_number?: string | null;
}
export namespace FinancialAccount {
export interface CreditConfiguration {
/**
* Reason for the financial account being marked as Charged Off
*/
charged_off_reason: 'DELINQUENT' | 'FRAUD' | null;
credit_limit: number | null;
/**
* Globally unique identifier for the credit product
*/
credit_product_token: string | null;
external_bank_account_token: string | null;
/**
* State of the financial account
*/
financial_account_state: 'PENDING' | 'CURRENT' | 'DELINQUENT' | 'CHARGED_OFF' | null;
is_spend_blocked: boolean;
/**
* Tier assigned to the financial account
*/
tier: string | null;
}
}
export interface FinancialTransaction {
/**
* Globally unique identifier.
*/
token: string;
/**
* Status types:
*
* - `CARD` - Issuing card transaction.
* - `ACH` - Transaction over ACH.
* - `TRANSFER` - Internal transfer of funds between financial accounts in your
* program.
*/
category: 'ACH' | 'CARD' | 'TRANSFER';
/**
* Date and time when the financial transaction first occurred. UTC time zone.
*/
created: string;
/**
* 3-digit alphabetic ISO 4217 code for the settling currency of the transaction.
*/
currency: string;
/**
* A string that provides a description of the financial transaction; may be useful
* to display to users.
*/
descriptor: string;
/**
* A list of all financial events that have modified this financial transaction.
*/
events: Array<FinancialTransaction.Event>;
/**
* Pending amount of the transaction in the currency's smallest unit (e.g., cents),
* including any acquirer fees. The value of this field will go to zero over time
* once the financial transaction is settled.
*/
pending_amount: number;
/**
* APPROVED transactions were successful while DECLINED transactions were declined
* by user, Lithic, or the network.
*/
result: 'APPROVED' | 'DECLINED';
/**
* Amount of the transaction that has been settled in the currency's smallest unit
* (e.g., cents), including any acquirer fees. This may change over time.
*/
settled_amount: number;
/**
* Status types:
*
* - `DECLINED` - The transaction was declined.
* - `EXPIRED` - The authorization as it has passed its expiration time. Card
* transaction only.
* - `PENDING` - The transaction is expected to settle.
* - `RETURNED` - The transaction has been returned.
* - `SETTLED` - The transaction is completed.
* - `VOIDED` - The transaction was voided. Card transaction only.
*/
status: 'DECLINED' | 'EXPIRED' | 'PENDING' | 'RETURNED' | 'SETTLED' | 'VOIDED';
/**
* Date and time when the financial transaction was last updated. UTC time zone.
*/
updated: string;
}
export namespace FinancialTransaction {
export interface Event {
/**
* Globally unique identifier.
*/
token?: string;
/**
* Amount of the financial event that has been settled in the currency's smallest
* unit (e.g., cents).
*/
amount?: number;
/**
* Date and time when the financial event occurred. UTC time zone.
*/
created?: string;
/**
* APPROVED financial events were successful while DECLINED financial events were
* declined by user, Lithic, or the network.
*/
result?: 'APPROVED' | 'DECLINED';
type?:
| 'ACH_ORIGINATION_CANCELLED'
| 'ACH_ORIGINATION_INITIATED'
| 'ACH_ORIGINATION_PROCESSED'
| 'ACH_ORIGINATION_RELEASED'
| 'ACH_ORIGINATION_REVIEWED'
| 'ACH_ORIGINATION_SETTLED'
| 'ACH_RECEIPT_PROCESSED'
| 'ACH_RECEIPT_SETTLED'
| 'ACH_RETURN_INITIATED'
| 'ACH_RETURN_PROCESSED'
| 'AUTHORIZATION'
| 'AUTHORIZATION_ADVICE'
| 'AUTHORIZATION_EXPIRY'
| 'AUTHORIZATION_REVERSAL'
| 'BALANCE_INQUIRY'
| 'BILLING_ERROR'
| 'BILLING_ERROR_REVERSAL'
| 'CARD_TO_CARD'
| 'CASH_BACK'
| 'CASH_BACK_REVERSAL'
| 'CLEARING'
| 'CORRECTION_CREDIT'
| 'CORRECTION_DEBIT'
| 'CREDIT_AUTHORIZATION'
| 'CREDIT_AUTHORIZATION_ADVICE'
| 'CURRENCY_CONVERSION'
| 'CURRENCY_CONVERSION_REVERSAL'
| 'DISPUTE_WON'
| 'EXTERNAL_ACH_CANCELED'
| 'EXTERNAL_ACH_INITIATED'
| 'EXTERNAL_ACH_RELEASED'
| 'EXTERNAL_ACH_REVERSED'
| 'EXTERNAL_ACH_SETTLED'
| 'EXTERNAL_CHECK_CANCELED'
| 'EXTERNAL_CHECK_INITIATED'
| 'EXTERNAL_CHECK_RELEASED'
| 'EXTERNAL_CHECK_REVERSED'
| 'EXTERNAL_CHECK_SETTLED'
| 'EXTERNAL_TRANSFER_CANCELED'
| 'EXTERNAL_TRANSFER_INITIATED'
| 'EXTERNAL_TRANSFER_RELEASED'
| 'EXTERNAL_TRANSFER_REVERSED'
| 'EXTERNAL_TRANSFER_SETTLED'
| 'EXTERNAL_WIRE_CANCELED'
| 'EXTERNAL_WIRE_INITIATED'
| 'EXTERNAL_WIRE_RELEASED'
| 'EXTERNAL_WIRE_REVERSED'
| 'EXTERNAL_WIRE_SETTLED'
| 'FINANCIAL_AUTHORIZATION'
| 'FINANCIAL_CREDIT_AUTHORIZATION'
| 'INTEREST'
| 'INTEREST_REVERSAL'
| 'LATE_PAYMENT'
| 'LATE_PAYMENT_REVERSAL'
| 'PROVISIONAL_CREDIT'
| 'PROVISIONAL_CREDIT_REVERSAL'
| 'RETURN'
| 'RETURN_REVERSAL'
| 'TRANSFER'
| 'TRANSFER_INSUFFICIENT_FUNDS'
| 'RETURNED_PAYMENT'
| 'RETURNED_PAYMENT_REVERSAL';
}
}
export interface FinancialAccountCreateParams {
/**
* Body param:
*/
nickname: string;
/**
* Body param:
*/
type: 'OPERATING';
/**
* Body param:
*/
account_token?: string;
/**
* Body param:
*/
is_for_benefit_of?: boolean;
/**
* Header param:
*/
'Idempotency-Key'?: string;
}
export interface FinancialAccountUpdateParams {
nickname?: string;
}
export interface FinancialAccountListParams {
/**
* List financial accounts for a given account_token or business_account_token
*/
account_token?: string;
/**
* List financial accounts for a given business_account_token
*/
business_account_token?: string;
/**
* List financial accounts of a given type
*/
type?: 'ISSUING' | 'OPERATING' | 'RESERVE';
}
export interface FinancialAccountChargeOffParams {
/**
* Reason for the financial account being marked as Charged Off
*/
reason: 'DELINQUENT' | 'FRAUD';
}
FinancialAccounts.FinancialAccountsSinglePage = FinancialAccountsSinglePage;
FinancialAccounts.Balances = Balances;
FinancialAccounts.BalanceListResponsesSinglePage = BalanceListResponsesSinglePage;
FinancialAccounts.FinancialTransactions = FinancialTransactions;
FinancialAccounts.CreditConfiguration = CreditConfigurationAPICreditConfiguration;
FinancialAccounts.StatementsCursorPage = StatementsCursorPage;
FinancialAccounts.LoanTapes = LoanTapes;
FinancialAccounts.LoanTapesCursorPage = LoanTapesCursorPage;
export declare namespace FinancialAccounts {
export {
type FinancialAccount as FinancialAccount,
type FinancialTransaction as FinancialTransaction,
FinancialAccountsSinglePage as FinancialAccountsSinglePage,
type FinancialAccountCreateParams as FinancialAccountCreateParams,
type FinancialAccountUpdateParams as FinancialAccountUpdateParams,
type FinancialAccountListParams as FinancialAccountListParams,
type FinancialAccountChargeOffParams as FinancialAccountChargeOffParams,
};
export {
Balances as Balances,
type BalanceListResponse as BalanceListResponse,
BalanceListResponsesSinglePage as BalanceListResponsesSinglePage,
type BalanceListParams as BalanceListParams,
};
export {
FinancialTransactions as FinancialTransactions,
type FinancialTransactionListParams as FinancialTransactionListParams,
};
export {
CreditConfigurationAPICreditConfiguration as CreditConfiguration,
type FinancialAccountCreditConfig as FinancialAccountCreditConfig,
type CreditConfigurationUpdateParams as CreditConfigurationUpdateParams,
};
export {
type Statements as Statements,
type Statement as Statement,
StatementsCursorPage as StatementsCursorPage,
type StatementListParams as StatementListParams,
};
export {
LoanTapes as LoanTapes,
type LoanTape as LoanTape,
LoanTapesCursorPage as LoanTapesCursorPage,
type LoanTapeListParams as LoanTapeListParams,
};
}