modern-treasury 0.0.1
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/.eslintrc.js +10 -0
- package/.prettierrc +6 -0
- package/LICENSE +7 -0
- package/README.md +198 -0
- package/build +10 -0
- package/core.ts +746 -0
- package/dist/cjs/core.d.ts +215 -0
- package/dist/cjs/core.js +815 -0
- package/dist/cjs/core.js.map +1 -0
- package/dist/cjs/index.d.ts +118 -0
- package/dist/cjs/index.js +128 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/pagination.d.ts +14 -0
- package/dist/cjs/pagination.js +22 -0
- package/dist/cjs/pagination.js.map +1 -0
- package/dist/cjs/resource.d.ts +11 -0
- package/dist/cjs/resource.js +16 -0
- package/dist/cjs/resource.js.map +1 -0
- package/dist/cjs/resources/counterparties.d.ts +500 -0
- package/dist/cjs/resources/counterparties.js +57 -0
- package/dist/cjs/resources/counterparties.js.map +1 -0
- package/dist/cjs/resources/documents.d.ts +66 -0
- package/dist/cjs/resources/documents.js +23 -0
- package/dist/cjs/resources/documents.js.map +1 -0
- package/dist/cjs/resources/events.d.ts +53 -0
- package/dist/cjs/resources/events.js +22 -0
- package/dist/cjs/resources/events.js.map +1 -0
- package/dist/cjs/resources/expected-payments.d.ts +928 -0
- package/dist/cjs/resources/expected-payments.js +31 -0
- package/dist/cjs/resources/expected-payments.js.map +1 -0
- package/dist/cjs/resources/external-accounts.d.ts +597 -0
- package/dist/cjs/resources/external-accounts.js +51 -0
- package/dist/cjs/resources/external-accounts.js.map +1 -0
- package/dist/cjs/resources/incoming-payment-details.d.ts +487 -0
- package/dist/cjs/resources/incoming-payment-details.js +35 -0
- package/dist/cjs/resources/incoming-payment-details.js.map +1 -0
- package/dist/cjs/resources/index.d.ts +15 -0
- package/dist/cjs/resources/index.js +46 -0
- package/dist/cjs/resources/index.js.map +1 -0
- package/dist/cjs/resources/internal-accounts.d.ts +666 -0
- package/dist/cjs/resources/internal-accounts.js +31 -0
- package/dist/cjs/resources/internal-accounts.js.map +1 -0
- package/dist/cjs/resources/line-items.d.ts +90 -0
- package/dist/cjs/resources/line-items.js +38 -0
- package/dist/cjs/resources/line-items.js.map +1 -0
- package/dist/cjs/resources/paper-items.d.ts +279 -0
- package/dist/cjs/resources/paper-items.js +25 -0
- package/dist/cjs/resources/paper-items.js.map +1 -0
- package/dist/cjs/resources/payment-orders/index.d.ts +2 -0
- package/dist/cjs/resources/payment-orders/index.js +33 -0
- package/dist/cjs/resources/payment-orders/index.js.map +1 -0
- package/dist/cjs/resources/payment-orders/payment-orders.d.ts +2180 -0
- package/dist/cjs/resources/payment-orders/payment-orders.js +56 -0
- package/dist/cjs/resources/payment-orders/payment-orders.js.map +1 -0
- package/dist/cjs/resources/payment-orders/reversals.d.ts +46 -0
- package/dist/cjs/resources/payment-orders/reversals.js +23 -0
- package/dist/cjs/resources/payment-orders/reversals.js.map +1 -0
- package/dist/cjs/resources/returns.d.ts +487 -0
- package/dist/cjs/resources/returns.js +31 -0
- package/dist/cjs/resources/returns.js.map +1 -0
- package/dist/cjs/resources/top-level.d.ts +3 -0
- package/dist/cjs/resources/top-level.js +4 -0
- package/dist/cjs/resources/top-level.js.map +1 -0
- package/dist/cjs/resources/transactions.d.ts +377 -0
- package/dist/cjs/resources/transactions.js +31 -0
- package/dist/cjs/resources/transactions.js.map +1 -0
- package/dist/cjs/resources/validations.d.ts +97 -0
- package/dist/cjs/resources/validations.js +16 -0
- package/dist/cjs/resources/validations.js.map +1 -0
- package/dist/cjs/resources/webhooks.d.ts +31 -0
- package/dist/cjs/resources/webhooks.js +44 -0
- package/dist/cjs/resources/webhooks.js.map +1 -0
- package/dist/cjs/tests/api-resources/counterparties.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/counterparties.test.js +275 -0
- package/dist/cjs/tests/api-resources/counterparties.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/documents.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/documents.test.js +78 -0
- package/dist/cjs/tests/api-resources/documents.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/events.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/events.test.js +100 -0
- package/dist/cjs/tests/api-resources/events.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/expected-payments.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/expected-payments.test.js +176 -0
- package/dist/cjs/tests/api-resources/expected-payments.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/external-accounts.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/external-accounts.test.js +248 -0
- package/dist/cjs/tests/api-resources/external-accounts.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/incoming-payment-details.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/incoming-payment-details.test.js +130 -0
- package/dist/cjs/tests/api-resources/incoming-payment-details.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/internal-accounts.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/internal-accounts.test.js +144 -0
- package/dist/cjs/tests/api-resources/internal-accounts.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/line-items.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/line-items.test.js +123 -0
- package/dist/cjs/tests/api-resources/line-items.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/paper-items.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/paper-items.test.js +96 -0
- package/dist/cjs/tests/api-resources/paper-items.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.js +77 -0
- package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/returns.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/returns.test.js +116 -0
- package/dist/cjs/tests/api-resources/returns.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/top-level.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/top-level.test.js +59 -0
- package/dist/cjs/tests/api-resources/top-level.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/transactions.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/transactions.test.js +134 -0
- package/dist/cjs/tests/api-resources/transactions.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/validations.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/validations.test.js +62 -0
- package/dist/cjs/tests/api-resources/validations.test.js.map +1 -0
- package/dist/cjs/tests/api-resources/webhooks.test.d.ts +1 -0
- package/dist/cjs/tests/api-resources/webhooks.test.js +100 -0
- package/dist/cjs/tests/api-resources/webhooks.test.js.map +1 -0
- package/dist/cjs/tests/form.test.d.ts +1 -0
- package/dist/cjs/tests/form.test.js +61 -0
- package/dist/cjs/tests/form.test.js.map +1 -0
- package/dist/cjs/tests/index.test.d.ts +1 -0
- package/dist/cjs/tests/index.test.js +57 -0
- package/dist/cjs/tests/index.test.js.map +1 -0
- package/dist/cjs/tests/responses.test.d.ts +1 -0
- package/dist/cjs/tests/responses.test.js +60 -0
- package/dist/cjs/tests/responses.test.js.map +1 -0
- package/index.ts +175 -0
- package/jest.config.js +8 -0
- package/package.json +47 -0
- package/pagination.ts +36 -0
- package/resource.ts +22 -0
- package/resources/counterparties.ts +666 -0
- package/resources/documents.ts +97 -0
- package/resources/events.ts +86 -0
- package/resources/expected-payments.ts +1016 -0
- package/resources/external-accounts.ts +762 -0
- package/resources/incoming-payment-details.ts +592 -0
- package/resources/index.ts +16 -0
- package/resources/internal-accounts.ts +774 -0
- package/resources/line-items.ts +138 -0
- package/resources/paper-items.ts +317 -0
- package/resources/payment-orders/index.ts +3 -0
- package/resources/payment-orders/payment-orders.ts +2486 -0
- package/resources/payment-orders/reversals.ts +72 -0
- package/resources/returns.ts +545 -0
- package/resources/top-level.ts +5 -0
- package/resources/transactions.ts +441 -0
- package/resources/validations.ts +115 -0
- package/resources/webhooks.ts +48 -0
- package/tests/api-resources/counterparties.test.ts +237 -0
- package/tests/api-resources/documents.test.ts +40 -0
- package/tests/api-resources/events.test.ts +62 -0
- package/tests/api-resources/expected-payments.test.ts +138 -0
- package/tests/api-resources/external-accounts.test.ts +210 -0
- package/tests/api-resources/incoming-payment-details.test.ts +92 -0
- package/tests/api-resources/internal-accounts.test.ts +103 -0
- package/tests/api-resources/line-items.test.ts +85 -0
- package/tests/api-resources/paper-items.test.ts +58 -0
- package/tests/api-resources/payment-orders/payment-orders.test.ts +39 -0
- package/tests/api-resources/returns.test.ts +78 -0
- package/tests/api-resources/top-level.test.ts +21 -0
- package/tests/api-resources/transactions.test.ts +96 -0
- package/tests/api-resources/validations.test.ts +24 -0
- package/tests/api-resources/webhooks.test.ts +102 -0
- package/tests/form.test.ts +27 -0
- package/tests/index.test.ts +62 -0
- package/tests/responses.test.ts +25 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.json +36 -0
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless.
|
|
2
|
+
|
|
3
|
+
import * as Core from '~/core';
|
|
4
|
+
import { APIResource } from '~/resource';
|
|
5
|
+
import { isRequestOptions } from '~/core';
|
|
6
|
+
import { Page, PageParams } from '~/pagination';
|
|
7
|
+
|
|
8
|
+
export class Transactions extends APIResource {
|
|
9
|
+
/**
|
|
10
|
+
* Get details on a single transaction.
|
|
11
|
+
*/
|
|
12
|
+
retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<Transaction>> {
|
|
13
|
+
return this.get(`/api/transactions/${id}`, options);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Update a single transaction.
|
|
18
|
+
*/
|
|
19
|
+
update(
|
|
20
|
+
id: string,
|
|
21
|
+
body?: TransactionUpdateParams,
|
|
22
|
+
options?: Core.RequestOptions,
|
|
23
|
+
): Promise<Core.APIResponse<Transaction>>;
|
|
24
|
+
update(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<Transaction>>;
|
|
25
|
+
update(
|
|
26
|
+
id: string,
|
|
27
|
+
body: TransactionUpdateParams | Core.RequestOptions = {},
|
|
28
|
+
options?: Core.RequestOptions,
|
|
29
|
+
): Promise<Core.APIResponse<Transaction>> {
|
|
30
|
+
if (isRequestOptions(body)) {
|
|
31
|
+
return this.update(id, {}, body);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this.patch(`/api/transactions/${id}`, { body, ...options });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Get a list of all transactions.
|
|
39
|
+
*/
|
|
40
|
+
list(query?: TransactionListParams, options?: Core.RequestOptions): Core.PagePromise<TransactionsPage>;
|
|
41
|
+
list(options?: Core.RequestOptions): Core.PagePromise<TransactionsPage>;
|
|
42
|
+
list(
|
|
43
|
+
query: TransactionListParams | Core.RequestOptions = {},
|
|
44
|
+
options?: Core.RequestOptions,
|
|
45
|
+
): Core.PagePromise<TransactionsPage> {
|
|
46
|
+
if (isRequestOptions(query)) {
|
|
47
|
+
return this.list({}, query);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return this.getAPIList('/api/transactions', TransactionsPage, { query, ...options });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class TransactionsPage extends Page<Transaction> {}
|
|
55
|
+
|
|
56
|
+
export interface Transaction {
|
|
57
|
+
/**
|
|
58
|
+
* Value in specified currency's smallest unit. e.g. $10 would be represented
|
|
59
|
+
* as 1000.
|
|
60
|
+
*/
|
|
61
|
+
amount?: number;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The date on which the transaction occurred.
|
|
65
|
+
*/
|
|
66
|
+
as_of_date?: string | null;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The time on which the transaction occurred. Depending on the granularity of the
|
|
70
|
+
* timestamp information received from the bank, it may be `null`.
|
|
71
|
+
*/
|
|
72
|
+
as_of_time?: string | null;
|
|
73
|
+
|
|
74
|
+
created_at?: string;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Currency that this transaction is denominated in.
|
|
78
|
+
*/
|
|
79
|
+
currency?:
|
|
80
|
+
| 'AED'
|
|
81
|
+
| 'AFN'
|
|
82
|
+
| 'ALL'
|
|
83
|
+
| 'AMD'
|
|
84
|
+
| 'ANG'
|
|
85
|
+
| 'AOA'
|
|
86
|
+
| 'ARS'
|
|
87
|
+
| 'AUD'
|
|
88
|
+
| 'AWG'
|
|
89
|
+
| 'AZN'
|
|
90
|
+
| 'BAM'
|
|
91
|
+
| 'BBD'
|
|
92
|
+
| 'BCH'
|
|
93
|
+
| 'BDT'
|
|
94
|
+
| 'BGN'
|
|
95
|
+
| 'BHD'
|
|
96
|
+
| 'BIF'
|
|
97
|
+
| 'BMD'
|
|
98
|
+
| 'BND'
|
|
99
|
+
| 'BOB'
|
|
100
|
+
| 'BRL'
|
|
101
|
+
| 'BSD'
|
|
102
|
+
| 'BTC'
|
|
103
|
+
| 'BTN'
|
|
104
|
+
| 'BWP'
|
|
105
|
+
| 'BYN'
|
|
106
|
+
| 'BYR'
|
|
107
|
+
| 'BZD'
|
|
108
|
+
| 'CAD'
|
|
109
|
+
| 'CDF'
|
|
110
|
+
| 'CHF'
|
|
111
|
+
| 'CLF'
|
|
112
|
+
| 'CLP'
|
|
113
|
+
| 'CNH'
|
|
114
|
+
| 'CNY'
|
|
115
|
+
| 'COP'
|
|
116
|
+
| 'CRC'
|
|
117
|
+
| 'CUC'
|
|
118
|
+
| 'CUP'
|
|
119
|
+
| 'CVE'
|
|
120
|
+
| 'CZK'
|
|
121
|
+
| 'DJF'
|
|
122
|
+
| 'DKK'
|
|
123
|
+
| 'DOP'
|
|
124
|
+
| 'DZD'
|
|
125
|
+
| 'EEK'
|
|
126
|
+
| 'EGP'
|
|
127
|
+
| 'ERN'
|
|
128
|
+
| 'ETB'
|
|
129
|
+
| 'EUR'
|
|
130
|
+
| 'FJD'
|
|
131
|
+
| 'FKP'
|
|
132
|
+
| 'GBP'
|
|
133
|
+
| 'GBX'
|
|
134
|
+
| 'GEL'
|
|
135
|
+
| 'GGP'
|
|
136
|
+
| 'GHS'
|
|
137
|
+
| 'GIP'
|
|
138
|
+
| 'GMD'
|
|
139
|
+
| 'GNF'
|
|
140
|
+
| 'GTQ'
|
|
141
|
+
| 'GYD'
|
|
142
|
+
| 'HKD'
|
|
143
|
+
| 'HNL'
|
|
144
|
+
| 'HRK'
|
|
145
|
+
| 'HTG'
|
|
146
|
+
| 'HUF'
|
|
147
|
+
| 'IDR'
|
|
148
|
+
| 'ILS'
|
|
149
|
+
| 'IMP'
|
|
150
|
+
| 'INR'
|
|
151
|
+
| 'IQD'
|
|
152
|
+
| 'IRR'
|
|
153
|
+
| 'ISK'
|
|
154
|
+
| 'JEP'
|
|
155
|
+
| 'JMD'
|
|
156
|
+
| 'JOD'
|
|
157
|
+
| 'JPY'
|
|
158
|
+
| 'KES'
|
|
159
|
+
| 'KGS'
|
|
160
|
+
| 'KHR'
|
|
161
|
+
| 'KMF'
|
|
162
|
+
| 'KPW'
|
|
163
|
+
| 'KRW'
|
|
164
|
+
| 'KWD'
|
|
165
|
+
| 'KYD'
|
|
166
|
+
| 'KZT'
|
|
167
|
+
| 'LAK'
|
|
168
|
+
| 'LBP'
|
|
169
|
+
| 'LKR'
|
|
170
|
+
| 'LRD'
|
|
171
|
+
| 'LSL'
|
|
172
|
+
| 'LTL'
|
|
173
|
+
| 'LVL'
|
|
174
|
+
| 'LYD'
|
|
175
|
+
| 'MAD'
|
|
176
|
+
| 'MDL'
|
|
177
|
+
| 'MGA'
|
|
178
|
+
| 'MKD'
|
|
179
|
+
| 'MMK'
|
|
180
|
+
| 'MNT'
|
|
181
|
+
| 'MOP'
|
|
182
|
+
| 'MRO'
|
|
183
|
+
| 'MRU'
|
|
184
|
+
| 'MTL'
|
|
185
|
+
| 'MUR'
|
|
186
|
+
| 'MVR'
|
|
187
|
+
| 'MWK'
|
|
188
|
+
| 'MXN'
|
|
189
|
+
| 'MYR'
|
|
190
|
+
| 'MZN'
|
|
191
|
+
| 'NAD'
|
|
192
|
+
| 'NGN'
|
|
193
|
+
| 'NIO'
|
|
194
|
+
| 'NOK'
|
|
195
|
+
| 'NPR'
|
|
196
|
+
| 'NZD'
|
|
197
|
+
| 'OMR'
|
|
198
|
+
| 'PAB'
|
|
199
|
+
| 'PEN'
|
|
200
|
+
| 'PGK'
|
|
201
|
+
| 'PHP'
|
|
202
|
+
| 'PKR'
|
|
203
|
+
| 'PLN'
|
|
204
|
+
| 'PYG'
|
|
205
|
+
| 'QAR'
|
|
206
|
+
| 'RON'
|
|
207
|
+
| 'RSD'
|
|
208
|
+
| 'RUB'
|
|
209
|
+
| 'RWF'
|
|
210
|
+
| 'SAR'
|
|
211
|
+
| 'SBD'
|
|
212
|
+
| 'SCR'
|
|
213
|
+
| 'SDG'
|
|
214
|
+
| 'SEK'
|
|
215
|
+
| 'SGD'
|
|
216
|
+
| 'SHP'
|
|
217
|
+
| 'SKK'
|
|
218
|
+
| 'SLL'
|
|
219
|
+
| 'SOS'
|
|
220
|
+
| 'SRD'
|
|
221
|
+
| 'SSP'
|
|
222
|
+
| 'STD'
|
|
223
|
+
| 'SVC'
|
|
224
|
+
| 'SYP'
|
|
225
|
+
| 'SZL'
|
|
226
|
+
| 'THB'
|
|
227
|
+
| 'TJS'
|
|
228
|
+
| 'TMM'
|
|
229
|
+
| 'TMT'
|
|
230
|
+
| 'TND'
|
|
231
|
+
| 'TOP'
|
|
232
|
+
| 'TRY'
|
|
233
|
+
| 'TTD'
|
|
234
|
+
| 'TWD'
|
|
235
|
+
| 'TZS'
|
|
236
|
+
| 'UAH'
|
|
237
|
+
| 'UGX'
|
|
238
|
+
| 'USD'
|
|
239
|
+
| 'UYU'
|
|
240
|
+
| 'UZS'
|
|
241
|
+
| 'VEF'
|
|
242
|
+
| 'VES'
|
|
243
|
+
| 'VND'
|
|
244
|
+
| 'VUV'
|
|
245
|
+
| 'WST'
|
|
246
|
+
| 'XAF'
|
|
247
|
+
| 'XAG'
|
|
248
|
+
| 'XAU'
|
|
249
|
+
| 'XBA'
|
|
250
|
+
| 'XBB'
|
|
251
|
+
| 'XBC'
|
|
252
|
+
| 'XBD'
|
|
253
|
+
| 'XCD'
|
|
254
|
+
| 'XDR'
|
|
255
|
+
| 'XFU'
|
|
256
|
+
| 'XOF'
|
|
257
|
+
| 'XPD'
|
|
258
|
+
| 'XPF'
|
|
259
|
+
| 'XPT'
|
|
260
|
+
| 'XTS'
|
|
261
|
+
| 'YER'
|
|
262
|
+
| 'ZAR'
|
|
263
|
+
| 'ZMK'
|
|
264
|
+
| 'ZMW'
|
|
265
|
+
| 'ZWD'
|
|
266
|
+
| 'ZWL'
|
|
267
|
+
| 'ZWN'
|
|
268
|
+
| 'ZWR';
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* This field contains additional information that the bank provided about the
|
|
272
|
+
* transaction. This is structured data. Some of the data in here might overlap
|
|
273
|
+
* with what is in the `vendor_description`. For example, the OBI could be a part
|
|
274
|
+
* of the vendor description, and it would also be included in here. The attributes
|
|
275
|
+
* that are passed through the details field will vary based on your banking
|
|
276
|
+
* partner. Currently, the following keys may be in the details object:
|
|
277
|
+
* `originator_name`, `originator_to_beneficiary_information`.
|
|
278
|
+
*/
|
|
279
|
+
details?: Record<string, string>;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Either `credit` or `debit`.
|
|
283
|
+
*/
|
|
284
|
+
direction?: string;
|
|
285
|
+
|
|
286
|
+
discarded_at?: string | null;
|
|
287
|
+
|
|
288
|
+
id?: string;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The ID of the relevant Internal Account.
|
|
292
|
+
*/
|
|
293
|
+
internal_account_id?: string;
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* This field will be true if this object exists in the live environment or false
|
|
297
|
+
* if it exists in the test environment.
|
|
298
|
+
*/
|
|
299
|
+
live_mode?: boolean;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Additional data represented as key-value pairs. Both the key and value must be
|
|
303
|
+
* strings.
|
|
304
|
+
*/
|
|
305
|
+
metadata?: Record<string, string>;
|
|
306
|
+
|
|
307
|
+
object?: string;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* This field will be `true` if the transaction has posted to the account.
|
|
311
|
+
*/
|
|
312
|
+
posted?: boolean;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* This field will be `true` if a transaction is reconciled by the Modern Treasury
|
|
316
|
+
* system. This means that it has transaction line items that sum up to the
|
|
317
|
+
* transaction's amount.
|
|
318
|
+
*/
|
|
319
|
+
reconciled?: boolean;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* The type of the transaction. Can be one of `ach`, `wire`, `check`, `rtp`,
|
|
323
|
+
* `book`, or `sen`.
|
|
324
|
+
*/
|
|
325
|
+
type?:
|
|
326
|
+
| 'ach'
|
|
327
|
+
| 'au_becs'
|
|
328
|
+
| 'bacs'
|
|
329
|
+
| 'book'
|
|
330
|
+
| 'card'
|
|
331
|
+
| 'check'
|
|
332
|
+
| 'eft'
|
|
333
|
+
| 'interac'
|
|
334
|
+
| 'provxchange'
|
|
335
|
+
| 'rtp'
|
|
336
|
+
| 'sen'
|
|
337
|
+
| 'sepa'
|
|
338
|
+
| 'signet'
|
|
339
|
+
| 'wire';
|
|
340
|
+
|
|
341
|
+
updated_at?: string;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* When applicable, the bank-given code that determines the transaction's category.
|
|
345
|
+
* For most banks this is the BAI2/BTRS transaction code.
|
|
346
|
+
*/
|
|
347
|
+
vendor_code?: string | null;
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* The type of vendor_code being reported. Can be one of `bai2`, `swift`,
|
|
351
|
+
* `cleartouch`, or `silvergate`.
|
|
352
|
+
*/
|
|
353
|
+
vendor_code_type?:
|
|
354
|
+
| 'bai2'
|
|
355
|
+
| 'bankprov'
|
|
356
|
+
| 'bnk_dev'
|
|
357
|
+
| 'cleartouch'
|
|
358
|
+
| 'cross_river'
|
|
359
|
+
| 'currencycloud'
|
|
360
|
+
| 'dc_bank'
|
|
361
|
+
| 'dwolla'
|
|
362
|
+
| 'goldman_sachs'
|
|
363
|
+
| 'iso20022'
|
|
364
|
+
| 'jpmc'
|
|
365
|
+
| 'mx'
|
|
366
|
+
| 'signet'
|
|
367
|
+
| 'silvergate'
|
|
368
|
+
| 'swift'
|
|
369
|
+
| null;
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* An identifier given to this transaction by the bank, often `null`.
|
|
373
|
+
*/
|
|
374
|
+
vendor_customer_id?: string | null;
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* The transaction detail text that often appears in on your bank statement and in
|
|
378
|
+
* your banking portal.
|
|
379
|
+
*/
|
|
380
|
+
vendor_description?: string | null;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* An identifier given to this transaction by the bank.
|
|
384
|
+
*/
|
|
385
|
+
vendor_id?: string | null;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export interface TransactionUpdateParams {
|
|
389
|
+
/**
|
|
390
|
+
* Additional data in the form of key-value pairs. Pairs can be removed by passing
|
|
391
|
+
* an empty string or `null` as the value.
|
|
392
|
+
*/
|
|
393
|
+
metadata?: Record<string, string>;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface TransactionListParams extends PageParams {
|
|
397
|
+
/**
|
|
398
|
+
* Filters transactions with an `as_of_date` starting on or before the specified
|
|
399
|
+
* date (YYYY-MM-DD).
|
|
400
|
+
*/
|
|
401
|
+
as_of_date_end?: string;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* Filters transactions with an `as_of_date` starting on or after the specified
|
|
405
|
+
* date (YYYY-MM-DD).
|
|
406
|
+
*/
|
|
407
|
+
as_of_date_start?: string;
|
|
408
|
+
|
|
409
|
+
counterparty_id?: string;
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Filters for transactions including the queried string in the description.
|
|
413
|
+
*/
|
|
414
|
+
description?: string;
|
|
415
|
+
|
|
416
|
+
direction?: string;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Specify `internal_account_id` if you wish to see transactions to/from a specific
|
|
420
|
+
* account.
|
|
421
|
+
*/
|
|
422
|
+
internal_account_id?: string;
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* For example, if you want to query for records with metadata key `Type` and value
|
|
426
|
+
* `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query
|
|
427
|
+
* parameters.
|
|
428
|
+
*/
|
|
429
|
+
metadata?: Record<string, string>;
|
|
430
|
+
|
|
431
|
+
payment_type?: string;
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Either `true` or `false`.
|
|
435
|
+
*/
|
|
436
|
+
posted?: boolean;
|
|
437
|
+
|
|
438
|
+
transactable_type?: string;
|
|
439
|
+
|
|
440
|
+
virtual_account_id?: string;
|
|
441
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless.
|
|
2
|
+
|
|
3
|
+
import * as Core from '~/core';
|
|
4
|
+
import { APIResource } from '~/resource';
|
|
5
|
+
|
|
6
|
+
export class Validations extends APIResource {
|
|
7
|
+
/**
|
|
8
|
+
* Validates the routing number information supplied without creating a routing
|
|
9
|
+
* detail
|
|
10
|
+
*/
|
|
11
|
+
validateRoutingNumber(
|
|
12
|
+
query: ValidationValidateRoutingNumberParams,
|
|
13
|
+
options?: Core.RequestOptions,
|
|
14
|
+
): Promise<Core.APIResponse<RoutingNumberLookupRequest>> {
|
|
15
|
+
return this.get('/api/validations/routing_numbers', { query, ...options });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface RoutingNumberLookupRequest {
|
|
20
|
+
/**
|
|
21
|
+
* The address of the bank.
|
|
22
|
+
*/
|
|
23
|
+
bank_address?: RoutingNumberLookupRequest.BankAddress;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The name of the bank.
|
|
27
|
+
*/
|
|
28
|
+
bank_name?: string;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The routing number of the bank.
|
|
32
|
+
*/
|
|
33
|
+
routing_number?: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* One of `aba`, `au_bsb`, `br_codigo`, `ca_cpa`, `cnaps`, `gb_sort_code`,
|
|
37
|
+
* `in_ifsc`, `my_branch_code`, or `swift`. In sandbox mode we currently only
|
|
38
|
+
* support `aba` and `swift` with routing numbers '123456789' and 'GRINUST0XXX'
|
|
39
|
+
* respectively.
|
|
40
|
+
*/
|
|
41
|
+
routing_number_type?: 'aba' | 'au_bsb' | 'ca_cpa' | 'gb_sort_code' | 'swift';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* An array of payment types that are supported for this routing number. This can
|
|
45
|
+
* include `ach`, `wire`, `rtp`, `sepa`, `bacs`, `au_becs` currently.
|
|
46
|
+
*/
|
|
47
|
+
supported_payment_types?: Array<
|
|
48
|
+
| 'ach'
|
|
49
|
+
| 'au_becs'
|
|
50
|
+
| 'bacs'
|
|
51
|
+
| 'book'
|
|
52
|
+
| 'card'
|
|
53
|
+
| 'check'
|
|
54
|
+
| 'eft'
|
|
55
|
+
| 'interac'
|
|
56
|
+
| 'provxchange'
|
|
57
|
+
| 'rtp'
|
|
58
|
+
| 'sen'
|
|
59
|
+
| 'sepa'
|
|
60
|
+
| 'signet'
|
|
61
|
+
| 'wire'
|
|
62
|
+
>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export namespace RoutingNumberLookupRequest {
|
|
66
|
+
export interface BankAddress {
|
|
67
|
+
/**
|
|
68
|
+
* Country code conforms to [ISO 3166-1 alpha-2]
|
|
69
|
+
*/
|
|
70
|
+
country?: string | null;
|
|
71
|
+
|
|
72
|
+
line1?: string | null;
|
|
73
|
+
|
|
74
|
+
line2?: string | null;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Locality or City.
|
|
78
|
+
*/
|
|
79
|
+
locality?: string | null;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* The postal code of the address.
|
|
83
|
+
*/
|
|
84
|
+
postal_code?: string | null;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Region or State.
|
|
88
|
+
*/
|
|
89
|
+
region?: string | null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface ValidationValidateRoutingNumberParams {
|
|
94
|
+
/**
|
|
95
|
+
* The routing number that is being validated.
|
|
96
|
+
*/
|
|
97
|
+
routing_number: string;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* One of `aba`, `au_bsb`, `br_codigo`, `ca_cpa`, `cnaps`, `gb_sort_code`,
|
|
101
|
+
* `in_ifsc`, `my_branch_code`, or `swift`. In sandbox mode we currently only
|
|
102
|
+
* support `aba` and `swift` with routing numbers '123456789' and 'GRINUST0XXX'
|
|
103
|
+
* respectively.
|
|
104
|
+
*/
|
|
105
|
+
routing_number_type:
|
|
106
|
+
| 'aba'
|
|
107
|
+
| 'au_bsb'
|
|
108
|
+
| 'br_codigo'
|
|
109
|
+
| 'ca_cpa'
|
|
110
|
+
| 'cnaps'
|
|
111
|
+
| 'gb_sort_code'
|
|
112
|
+
| 'in_ifsc'
|
|
113
|
+
| 'my_branch_code'
|
|
114
|
+
| 'swift';
|
|
115
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '~/resource';
|
|
4
|
+
import { createHmac } from 'crypto';
|
|
5
|
+
|
|
6
|
+
import type { HeadersLike } from '~/core';
|
|
7
|
+
import { getHeader } from '~/core';
|
|
8
|
+
|
|
9
|
+
export class Webhooks extends APIResource {
|
|
10
|
+
/**
|
|
11
|
+
* To verify that a webhook was actually sent by Modern Treasury, every payload is
|
|
12
|
+
* signed with a signature that is passed through the `X-Signature` HTTP header.
|
|
13
|
+
*
|
|
14
|
+
* This method will generate a signature based off of your webhook key which can be
|
|
15
|
+
* found in the Developer Settings,
|
|
16
|
+
* https://app.moderntreasury.com/developers/webhooks, and the webhook payload.
|
|
17
|
+
*
|
|
18
|
+
* You can then compare the generated signature with the signature sent with the
|
|
19
|
+
* request, if they match then the webhook was sent by Modern Treasury.
|
|
20
|
+
*/
|
|
21
|
+
getSignature(payload: string, opts?: { key?: string | null | undefined }): string {
|
|
22
|
+
const key = opts?.key || this.client.webhookKey;
|
|
23
|
+
if (key == null) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"The webhook key must either be set using the env var, MODERN_TREASURY_WEBHOOK_KEY, on the client class, new ModernTreasury({ webhookKey: '123' }) or passed to this function",
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
if (!key) {
|
|
29
|
+
throw new Error('The webhook key is set but appears to be empty.');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return createHmac('sha256', key).update(payload, 'utf8').digest('hex');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Returns whether or not the webhook payload was sent by Modern Treasury.
|
|
37
|
+
*/
|
|
38
|
+
validateSignature(
|
|
39
|
+
payload: string,
|
|
40
|
+
headers: string | HeadersLike,
|
|
41
|
+
opts?: { key?: string | null | undefined },
|
|
42
|
+
): boolean {
|
|
43
|
+
const signature = this.getSignature(payload, opts);
|
|
44
|
+
const expectedSignature = typeof headers === 'string' ? headers : getHeader(headers, 'X-Signature');
|
|
45
|
+
if (!expectedSignature) throw new Error('Could not find an X-Signature header');
|
|
46
|
+
return signature === expectedSignature;
|
|
47
|
+
}
|
|
48
|
+
}
|