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.
Files changed (169) hide show
  1. package/.eslintrc.js +10 -0
  2. package/.prettierrc +6 -0
  3. package/LICENSE +7 -0
  4. package/README.md +198 -0
  5. package/build +10 -0
  6. package/core.ts +746 -0
  7. package/dist/cjs/core.d.ts +215 -0
  8. package/dist/cjs/core.js +815 -0
  9. package/dist/cjs/core.js.map +1 -0
  10. package/dist/cjs/index.d.ts +118 -0
  11. package/dist/cjs/index.js +128 -0
  12. package/dist/cjs/index.js.map +1 -0
  13. package/dist/cjs/pagination.d.ts +14 -0
  14. package/dist/cjs/pagination.js +22 -0
  15. package/dist/cjs/pagination.js.map +1 -0
  16. package/dist/cjs/resource.d.ts +11 -0
  17. package/dist/cjs/resource.js +16 -0
  18. package/dist/cjs/resource.js.map +1 -0
  19. package/dist/cjs/resources/counterparties.d.ts +500 -0
  20. package/dist/cjs/resources/counterparties.js +57 -0
  21. package/dist/cjs/resources/counterparties.js.map +1 -0
  22. package/dist/cjs/resources/documents.d.ts +66 -0
  23. package/dist/cjs/resources/documents.js +23 -0
  24. package/dist/cjs/resources/documents.js.map +1 -0
  25. package/dist/cjs/resources/events.d.ts +53 -0
  26. package/dist/cjs/resources/events.js +22 -0
  27. package/dist/cjs/resources/events.js.map +1 -0
  28. package/dist/cjs/resources/expected-payments.d.ts +928 -0
  29. package/dist/cjs/resources/expected-payments.js +31 -0
  30. package/dist/cjs/resources/expected-payments.js.map +1 -0
  31. package/dist/cjs/resources/external-accounts.d.ts +597 -0
  32. package/dist/cjs/resources/external-accounts.js +51 -0
  33. package/dist/cjs/resources/external-accounts.js.map +1 -0
  34. package/dist/cjs/resources/incoming-payment-details.d.ts +487 -0
  35. package/dist/cjs/resources/incoming-payment-details.js +35 -0
  36. package/dist/cjs/resources/incoming-payment-details.js.map +1 -0
  37. package/dist/cjs/resources/index.d.ts +15 -0
  38. package/dist/cjs/resources/index.js +46 -0
  39. package/dist/cjs/resources/index.js.map +1 -0
  40. package/dist/cjs/resources/internal-accounts.d.ts +666 -0
  41. package/dist/cjs/resources/internal-accounts.js +31 -0
  42. package/dist/cjs/resources/internal-accounts.js.map +1 -0
  43. package/dist/cjs/resources/line-items.d.ts +90 -0
  44. package/dist/cjs/resources/line-items.js +38 -0
  45. package/dist/cjs/resources/line-items.js.map +1 -0
  46. package/dist/cjs/resources/paper-items.d.ts +279 -0
  47. package/dist/cjs/resources/paper-items.js +25 -0
  48. package/dist/cjs/resources/paper-items.js.map +1 -0
  49. package/dist/cjs/resources/payment-orders/index.d.ts +2 -0
  50. package/dist/cjs/resources/payment-orders/index.js +33 -0
  51. package/dist/cjs/resources/payment-orders/index.js.map +1 -0
  52. package/dist/cjs/resources/payment-orders/payment-orders.d.ts +2180 -0
  53. package/dist/cjs/resources/payment-orders/payment-orders.js +56 -0
  54. package/dist/cjs/resources/payment-orders/payment-orders.js.map +1 -0
  55. package/dist/cjs/resources/payment-orders/reversals.d.ts +46 -0
  56. package/dist/cjs/resources/payment-orders/reversals.js +23 -0
  57. package/dist/cjs/resources/payment-orders/reversals.js.map +1 -0
  58. package/dist/cjs/resources/returns.d.ts +487 -0
  59. package/dist/cjs/resources/returns.js +31 -0
  60. package/dist/cjs/resources/returns.js.map +1 -0
  61. package/dist/cjs/resources/top-level.d.ts +3 -0
  62. package/dist/cjs/resources/top-level.js +4 -0
  63. package/dist/cjs/resources/top-level.js.map +1 -0
  64. package/dist/cjs/resources/transactions.d.ts +377 -0
  65. package/dist/cjs/resources/transactions.js +31 -0
  66. package/dist/cjs/resources/transactions.js.map +1 -0
  67. package/dist/cjs/resources/validations.d.ts +97 -0
  68. package/dist/cjs/resources/validations.js +16 -0
  69. package/dist/cjs/resources/validations.js.map +1 -0
  70. package/dist/cjs/resources/webhooks.d.ts +31 -0
  71. package/dist/cjs/resources/webhooks.js +44 -0
  72. package/dist/cjs/resources/webhooks.js.map +1 -0
  73. package/dist/cjs/tests/api-resources/counterparties.test.d.ts +1 -0
  74. package/dist/cjs/tests/api-resources/counterparties.test.js +275 -0
  75. package/dist/cjs/tests/api-resources/counterparties.test.js.map +1 -0
  76. package/dist/cjs/tests/api-resources/documents.test.d.ts +1 -0
  77. package/dist/cjs/tests/api-resources/documents.test.js +78 -0
  78. package/dist/cjs/tests/api-resources/documents.test.js.map +1 -0
  79. package/dist/cjs/tests/api-resources/events.test.d.ts +1 -0
  80. package/dist/cjs/tests/api-resources/events.test.js +100 -0
  81. package/dist/cjs/tests/api-resources/events.test.js.map +1 -0
  82. package/dist/cjs/tests/api-resources/expected-payments.test.d.ts +1 -0
  83. package/dist/cjs/tests/api-resources/expected-payments.test.js +176 -0
  84. package/dist/cjs/tests/api-resources/expected-payments.test.js.map +1 -0
  85. package/dist/cjs/tests/api-resources/external-accounts.test.d.ts +1 -0
  86. package/dist/cjs/tests/api-resources/external-accounts.test.js +248 -0
  87. package/dist/cjs/tests/api-resources/external-accounts.test.js.map +1 -0
  88. package/dist/cjs/tests/api-resources/incoming-payment-details.test.d.ts +1 -0
  89. package/dist/cjs/tests/api-resources/incoming-payment-details.test.js +130 -0
  90. package/dist/cjs/tests/api-resources/incoming-payment-details.test.js.map +1 -0
  91. package/dist/cjs/tests/api-resources/internal-accounts.test.d.ts +1 -0
  92. package/dist/cjs/tests/api-resources/internal-accounts.test.js +144 -0
  93. package/dist/cjs/tests/api-resources/internal-accounts.test.js.map +1 -0
  94. package/dist/cjs/tests/api-resources/line-items.test.d.ts +1 -0
  95. package/dist/cjs/tests/api-resources/line-items.test.js +123 -0
  96. package/dist/cjs/tests/api-resources/line-items.test.js.map +1 -0
  97. package/dist/cjs/tests/api-resources/paper-items.test.d.ts +1 -0
  98. package/dist/cjs/tests/api-resources/paper-items.test.js +96 -0
  99. package/dist/cjs/tests/api-resources/paper-items.test.js.map +1 -0
  100. package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.d.ts +1 -0
  101. package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.js +77 -0
  102. package/dist/cjs/tests/api-resources/payment-orders/payment-orders.test.js.map +1 -0
  103. package/dist/cjs/tests/api-resources/returns.test.d.ts +1 -0
  104. package/dist/cjs/tests/api-resources/returns.test.js +116 -0
  105. package/dist/cjs/tests/api-resources/returns.test.js.map +1 -0
  106. package/dist/cjs/tests/api-resources/top-level.test.d.ts +1 -0
  107. package/dist/cjs/tests/api-resources/top-level.test.js +59 -0
  108. package/dist/cjs/tests/api-resources/top-level.test.js.map +1 -0
  109. package/dist/cjs/tests/api-resources/transactions.test.d.ts +1 -0
  110. package/dist/cjs/tests/api-resources/transactions.test.js +134 -0
  111. package/dist/cjs/tests/api-resources/transactions.test.js.map +1 -0
  112. package/dist/cjs/tests/api-resources/validations.test.d.ts +1 -0
  113. package/dist/cjs/tests/api-resources/validations.test.js +62 -0
  114. package/dist/cjs/tests/api-resources/validations.test.js.map +1 -0
  115. package/dist/cjs/tests/api-resources/webhooks.test.d.ts +1 -0
  116. package/dist/cjs/tests/api-resources/webhooks.test.js +100 -0
  117. package/dist/cjs/tests/api-resources/webhooks.test.js.map +1 -0
  118. package/dist/cjs/tests/form.test.d.ts +1 -0
  119. package/dist/cjs/tests/form.test.js +61 -0
  120. package/dist/cjs/tests/form.test.js.map +1 -0
  121. package/dist/cjs/tests/index.test.d.ts +1 -0
  122. package/dist/cjs/tests/index.test.js +57 -0
  123. package/dist/cjs/tests/index.test.js.map +1 -0
  124. package/dist/cjs/tests/responses.test.d.ts +1 -0
  125. package/dist/cjs/tests/responses.test.js +60 -0
  126. package/dist/cjs/tests/responses.test.js.map +1 -0
  127. package/index.ts +175 -0
  128. package/jest.config.js +8 -0
  129. package/package.json +47 -0
  130. package/pagination.ts +36 -0
  131. package/resource.ts +22 -0
  132. package/resources/counterparties.ts +666 -0
  133. package/resources/documents.ts +97 -0
  134. package/resources/events.ts +86 -0
  135. package/resources/expected-payments.ts +1016 -0
  136. package/resources/external-accounts.ts +762 -0
  137. package/resources/incoming-payment-details.ts +592 -0
  138. package/resources/index.ts +16 -0
  139. package/resources/internal-accounts.ts +774 -0
  140. package/resources/line-items.ts +138 -0
  141. package/resources/paper-items.ts +317 -0
  142. package/resources/payment-orders/index.ts +3 -0
  143. package/resources/payment-orders/payment-orders.ts +2486 -0
  144. package/resources/payment-orders/reversals.ts +72 -0
  145. package/resources/returns.ts +545 -0
  146. package/resources/top-level.ts +5 -0
  147. package/resources/transactions.ts +441 -0
  148. package/resources/validations.ts +115 -0
  149. package/resources/webhooks.ts +48 -0
  150. package/tests/api-resources/counterparties.test.ts +237 -0
  151. package/tests/api-resources/documents.test.ts +40 -0
  152. package/tests/api-resources/events.test.ts +62 -0
  153. package/tests/api-resources/expected-payments.test.ts +138 -0
  154. package/tests/api-resources/external-accounts.test.ts +210 -0
  155. package/tests/api-resources/incoming-payment-details.test.ts +92 -0
  156. package/tests/api-resources/internal-accounts.test.ts +103 -0
  157. package/tests/api-resources/line-items.test.ts +85 -0
  158. package/tests/api-resources/paper-items.test.ts +58 -0
  159. package/tests/api-resources/payment-orders/payment-orders.test.ts +39 -0
  160. package/tests/api-resources/returns.test.ts +78 -0
  161. package/tests/api-resources/top-level.test.ts +21 -0
  162. package/tests/api-resources/transactions.test.ts +96 -0
  163. package/tests/api-resources/validations.test.ts +24 -0
  164. package/tests/api-resources/webhooks.test.ts +102 -0
  165. package/tests/form.test.ts +27 -0
  166. package/tests/index.test.ts +62 -0
  167. package/tests/responses.test.ts +25 -0
  168. package/tsconfig.cjs.json +8 -0
  169. package/tsconfig.json +36 -0
package/resource.ts ADDED
@@ -0,0 +1,22 @@
1
+ import type { ModernTreasury } from './index';
2
+
3
+ export class APIResource {
4
+ protected client: ModernTreasury;
5
+ constructor(client: ModernTreasury) {
6
+ this.client = client;
7
+
8
+ this.get = client.get.bind(client);
9
+ this.post = client.post.bind(client);
10
+ this.patch = client.patch.bind(client);
11
+ this.put = client.put.bind(client);
12
+ this.delete = client.delete.bind(client);
13
+ this.getAPIList = client.getAPIList.bind(client);
14
+ }
15
+
16
+ protected get: ModernTreasury['get'];
17
+ protected post: ModernTreasury['post'];
18
+ protected patch: ModernTreasury['patch'];
19
+ protected put: ModernTreasury['put'];
20
+ protected delete: ModernTreasury['delete'];
21
+ protected getAPIList: ModernTreasury['getAPIList'];
22
+ }
@@ -0,0 +1,666 @@
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 Counterparties extends APIResource {
9
+ /**
10
+ * Create a new counterparty.
11
+ */
12
+ create(
13
+ body: CounterpartyCreateParams,
14
+ options?: Core.RequestOptions,
15
+ ): Promise<Core.APIResponse<Counterparty>> {
16
+ return this.post('/api/counterparties', { body, ...options });
17
+ }
18
+
19
+ /**
20
+ * Get details on a single counterparty.
21
+ */
22
+ retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<Counterparty>> {
23
+ return this.get(`/api/counterparties/${id}`, options);
24
+ }
25
+
26
+ /**
27
+ * Updates a given counterparty with new information.
28
+ */
29
+ update(
30
+ id: string,
31
+ body?: CounterpartyUpdateParams,
32
+ options?: Core.RequestOptions,
33
+ ): Promise<Core.APIResponse<Counterparty>>;
34
+ update(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<Counterparty>>;
35
+ update(
36
+ id: string,
37
+ body: CounterpartyUpdateParams | Core.RequestOptions = {},
38
+ options?: Core.RequestOptions,
39
+ ): Promise<Core.APIResponse<Counterparty>> {
40
+ if (isRequestOptions(body)) {
41
+ return this.update(id, {}, body);
42
+ }
43
+
44
+ return this.patch(`/api/counterparties/${id}`, { body, ...options });
45
+ }
46
+
47
+ /**
48
+ * Get a paginated list of all counterparties.
49
+ */
50
+ list(query?: CounterpartyListParams, options?: Core.RequestOptions): Core.PagePromise<CounterpartiesPage>;
51
+ list(options?: Core.RequestOptions): Core.PagePromise<CounterpartiesPage>;
52
+ list(
53
+ query: CounterpartyListParams | Core.RequestOptions = {},
54
+ options?: Core.RequestOptions,
55
+ ): Core.PagePromise<CounterpartiesPage> {
56
+ if (isRequestOptions(query)) {
57
+ return this.list({}, query);
58
+ }
59
+
60
+ return this.getAPIList('/api/counterparties', CounterpartiesPage, { query, ...options });
61
+ }
62
+
63
+ /**
64
+ * Deletes a given counterparty.
65
+ */
66
+ del(id: string, options?: Core.RequestOptions): Promise<void> {
67
+ return this.delete(`/api/counterparties/${id}`, {
68
+ ...options,
69
+ headers: { Accept: '', ...options?.headers },
70
+ });
71
+ }
72
+
73
+ /**
74
+ * Send an email requesting account details.
75
+ */
76
+ collectAccount(
77
+ id: string,
78
+ body: CounterpartyCollectAccountParams,
79
+ options?: Core.RequestOptions,
80
+ ): Promise<Core.APIResponse<CounterpartyCollectAccountResponse>> {
81
+ return this.post(`/api/counterparties/${id}/collect_account`, { body, ...options });
82
+ }
83
+ }
84
+
85
+ export class CounterpartiesPage extends Page<Counterparty> {}
86
+
87
+ export interface Counterparty {
88
+ /**
89
+ * The accounts for this counterparty.
90
+ */
91
+ accounts?: Array<Counterparty.Accounts>;
92
+
93
+ created_at?: string;
94
+
95
+ discarded_at?: string | null;
96
+
97
+ /**
98
+ * The counterparty's email.
99
+ */
100
+ email?: string | null;
101
+
102
+ id?: string;
103
+
104
+ /**
105
+ * This field will be true if this object exists in the live environment or false
106
+ * if it exists in the test environment.
107
+ */
108
+ live_mode?: boolean;
109
+
110
+ /**
111
+ * Additional data represented as key-value pairs. Both the key and value must be
112
+ * strings.
113
+ */
114
+ metadata?: Record<string, string>;
115
+
116
+ /**
117
+ * A human friendly name for this counterparty.
118
+ */
119
+ name?: string;
120
+
121
+ object?: string;
122
+
123
+ /**
124
+ * Send an email to the counterparty whenever an associated payment order is sent
125
+ * to the bank.
126
+ */
127
+ send_remittance_advice?: boolean;
128
+
129
+ updated_at?: string;
130
+ }
131
+
132
+ export namespace Counterparty {
133
+ export interface Accounts {
134
+ account_details?: Array<Accounts.AccountDetails>;
135
+
136
+ /**
137
+ * Can be `checking`, `savings` or `other`.
138
+ */
139
+ account_type?: 'checking' | 'other' | 'savings';
140
+
141
+ contact_details?: Array<Accounts.ContactDetails>;
142
+
143
+ created_at?: string;
144
+
145
+ discarded_at?: string | null;
146
+
147
+ id?: string;
148
+
149
+ /**
150
+ * This field will be true if this object exists in the live environment or false
151
+ * if it exists in the test environment.
152
+ */
153
+ live_mode?: boolean;
154
+
155
+ /**
156
+ * Additional data represented as key-value pairs. Both the key and value must be
157
+ * strings.
158
+ */
159
+ metadata?: Record<string, string>;
160
+
161
+ /**
162
+ * A nickname for the external account. This is only for internal usage and won't
163
+ * affect any payments
164
+ */
165
+ name?: string | null;
166
+
167
+ object?: string;
168
+
169
+ /**
170
+ * The address associated with the owner or `null`.
171
+ */
172
+ party_address?: Accounts.PartyAddress | null;
173
+
174
+ /**
175
+ * The legal name of the entity which owns the account.
176
+ */
177
+ party_name?: string;
178
+
179
+ /**
180
+ * Either `individual` or `business`.
181
+ */
182
+ party_type?: 'business' | 'individual' | null;
183
+
184
+ routing_details?: Array<Accounts.RoutingDetails>;
185
+
186
+ updated_at?: string;
187
+
188
+ verification_status?: 'pending_verification' | 'unverified' | 'verified';
189
+ }
190
+
191
+ export namespace Accounts {
192
+ export interface PartyAddress {
193
+ /**
194
+ * Country code conforms to [ISO 3166-1 alpha-2]
195
+ */
196
+ country?: string | null;
197
+
198
+ created_at?: string;
199
+
200
+ id?: string;
201
+
202
+ line1?: string | null;
203
+
204
+ line2?: string | null;
205
+
206
+ /**
207
+ * This field will be true if this object exists in the live environment or false
208
+ * if it exists in the test environment.
209
+ */
210
+ live_mode?: boolean;
211
+
212
+ /**
213
+ * Locality or City.
214
+ */
215
+ locality?: string | null;
216
+
217
+ object?: string;
218
+
219
+ /**
220
+ * The postal code of the address.
221
+ */
222
+ postal_code?: string | null;
223
+
224
+ /**
225
+ * Region or State.
226
+ */
227
+ region?: string | null;
228
+
229
+ updated_at?: string;
230
+ }
231
+
232
+ export interface AccountDetails {
233
+ account_number?: string;
234
+
235
+ /**
236
+ * Supports iban and clabe, otherwise other if the bank account number is in a
237
+ * generic format.
238
+ */
239
+ account_number_type?: 'iban' | 'clabe' | 'wallet_address' | 'pan' | 'other';
240
+
241
+ created_at?: string;
242
+
243
+ discarded_at?: string | null;
244
+
245
+ id?: string;
246
+
247
+ /**
248
+ * This field will be true if this object exists in the live environment or false
249
+ * if it exists in the test environment.
250
+ */
251
+ live_mode?: boolean;
252
+
253
+ object?: string;
254
+
255
+ updated_at?: string;
256
+ }
257
+
258
+ export interface RoutingDetails {
259
+ bank_address?: RoutingDetails.BankAddress | null;
260
+
261
+ bank_name?: string;
262
+
263
+ created_at?: string;
264
+
265
+ discarded_at?: string | null;
266
+
267
+ id?: string;
268
+
269
+ /**
270
+ * This field will be true if this object exists in the live environment or false
271
+ * if it exists in the test environment.
272
+ */
273
+ live_mode?: boolean;
274
+
275
+ object?: string;
276
+
277
+ /**
278
+ * If the routing detail is to be used for a specific payment type this field will
279
+ * be populated, otherwise null.
280
+ */
281
+ payment_type?:
282
+ | 'ach'
283
+ | 'au_becs'
284
+ | 'bacs'
285
+ | 'book'
286
+ | 'card'
287
+ | 'check'
288
+ | 'eft'
289
+ | 'interac'
290
+ | 'provxchange'
291
+ | 'rtp'
292
+ | 'sen'
293
+ | 'sepa'
294
+ | 'signet'
295
+ | 'wire'
296
+ | null;
297
+
298
+ /**
299
+ * The routing number of the bank.
300
+ */
301
+ routing_number?: string;
302
+
303
+ routing_number_type?:
304
+ | 'aba'
305
+ | 'swift'
306
+ | 'au_bsb'
307
+ | 'ca_cpa'
308
+ | 'cnaps'
309
+ | 'gb_sort_code'
310
+ | 'in_ifsc'
311
+ | 'my_branch_code'
312
+ | 'br_codigo';
313
+
314
+ updated_at?: string;
315
+ }
316
+
317
+ export namespace RoutingDetails {
318
+ export interface BankAddress {
319
+ /**
320
+ * Country code conforms to [ISO 3166-1 alpha-2]
321
+ */
322
+ country?: string | null;
323
+
324
+ created_at?: string;
325
+
326
+ id?: string;
327
+
328
+ line1?: string | null;
329
+
330
+ line2?: string | null;
331
+
332
+ /**
333
+ * This field will be true if this object exists in the live environment or false
334
+ * if it exists in the test environment.
335
+ */
336
+ live_mode?: boolean;
337
+
338
+ /**
339
+ * Locality or City.
340
+ */
341
+ locality?: string | null;
342
+
343
+ object?: string;
344
+
345
+ /**
346
+ * The postal code of the address.
347
+ */
348
+ postal_code?: string | null;
349
+
350
+ /**
351
+ * Region or State.
352
+ */
353
+ region?: string | null;
354
+
355
+ updated_at?: string;
356
+ }
357
+ }
358
+
359
+ export interface ContactDetails {
360
+ contact_identifier?: string;
361
+
362
+ contact_identifier_type?: 'email' | 'phone_number';
363
+
364
+ created_at?: string;
365
+
366
+ discarded_at?: string | null;
367
+
368
+ id?: string;
369
+
370
+ /**
371
+ * This field will be true if this object exists in the live environment or false
372
+ * if it exists in the test environment.
373
+ */
374
+ live_mode?: boolean;
375
+
376
+ object?: string;
377
+
378
+ updated_at?: string;
379
+ }
380
+ }
381
+ }
382
+
383
+ export interface CounterpartyCollectAccountResponse {
384
+ /**
385
+ * This is the link to the secure Modern Treasury form. By default, Modern Treasury
386
+ * will send an email to your counterparty that includes a link to this form.
387
+ * However, if `send_email` is passed as `false` in the body then Modern Treasury
388
+ * will not send the email and you can send it to the counterparty directly.
389
+ */
390
+ form_link?: string;
391
+
392
+ /**
393
+ * The id of the existing counterparty.
394
+ */
395
+ id?: string;
396
+
397
+ /**
398
+ * This field will be `true` if an email requesting account details has already
399
+ * been sent to this counterparty.
400
+ */
401
+ is_resend?: boolean;
402
+ }
403
+
404
+ export interface CounterpartyCreateParams {
405
+ /**
406
+ * A human friendly name for this counterparty.
407
+ */
408
+ name: string;
409
+
410
+ /**
411
+ * The accounts for this counterparty.
412
+ */
413
+ accounts?: Array<CounterpartyCreateParams.Accounts>;
414
+
415
+ /**
416
+ * The counterparty's email.
417
+ */
418
+ email?: string | null;
419
+
420
+ /**
421
+ * An optional type to auto-sync the counterparty to your ledger. Either `customer`
422
+ * or `vendor`.
423
+ */
424
+ ledger_type?: 'customer' | 'vendor';
425
+
426
+ /**
427
+ * Additional data represented as key-value pairs. Both the key and value must be
428
+ * strings.
429
+ */
430
+ metadata?: Record<string, string>;
431
+
432
+ /**
433
+ * Send an email to the counterparty whenever an associated payment order is sent
434
+ * to the bank.
435
+ */
436
+ send_remittance_advice?: boolean;
437
+
438
+ /**
439
+ * Either a valid SSN or EIN.
440
+ */
441
+ taxpayer_identifier?: string;
442
+ }
443
+
444
+ export namespace CounterpartyCreateParams {
445
+ export interface Accounts {
446
+ account_details?: Array<Accounts.AccountDetails>;
447
+
448
+ /**
449
+ * Can be `checking`, `savings` or `other`.
450
+ */
451
+ account_type?: 'checking' | 'other' | 'savings';
452
+
453
+ contact_details?: Array<Accounts.ContactDetails>;
454
+
455
+ /**
456
+ * Additional data represented as key-value pairs. Both the key and value must be
457
+ * strings.
458
+ */
459
+ metadata?: Record<string, string>;
460
+
461
+ /**
462
+ * A nickname for the external account. This is only for internal usage and won't
463
+ * affect any payments
464
+ */
465
+ name?: string | null;
466
+
467
+ /**
468
+ * Required if receiving wire payments.
469
+ */
470
+ party_address?: Accounts.PartyAddress;
471
+
472
+ party_identifier?: string;
473
+
474
+ /**
475
+ * If this value isn't provided, it will be inherited from the counterparty's name.
476
+ */
477
+ party_name?: string;
478
+
479
+ /**
480
+ * Either `individual` or `business`.
481
+ */
482
+ party_type?: 'business' | 'individual' | null;
483
+
484
+ /**
485
+ * If you've enabled the Modern Treasury + Plaid integration in your Plaid account,
486
+ * you can pass the processor token in this field.
487
+ */
488
+ plaid_processor_token?: string;
489
+
490
+ routing_details?: Array<Accounts.RoutingDetails>;
491
+ }
492
+
493
+ export namespace Accounts {
494
+ export interface PartyAddress {
495
+ /**
496
+ * Country code conforms to [ISO 3166-1 alpha-2]
497
+ */
498
+ country?: string | null;
499
+
500
+ line1?: string | null;
501
+
502
+ line2?: string | null;
503
+
504
+ /**
505
+ * Locality or City.
506
+ */
507
+ locality?: string | null;
508
+
509
+ /**
510
+ * The postal code of the address.
511
+ */
512
+ postal_code?: string | null;
513
+
514
+ /**
515
+ * Region or State.
516
+ */
517
+ region?: string | null;
518
+ }
519
+
520
+ export interface AccountDetails {
521
+ account_number: string;
522
+
523
+ account_number_type?: 'iban' | 'clabe' | 'wallet_address' | 'pan' | 'other';
524
+ }
525
+
526
+ export interface RoutingDetails {
527
+ routing_number: string;
528
+
529
+ routing_number_type:
530
+ | 'aba'
531
+ | 'swift'
532
+ | 'au_bsb'
533
+ | 'ca_cpa'
534
+ | 'cnaps'
535
+ | 'gb_sort_code'
536
+ | 'in_ifsc'
537
+ | 'my_branch_code'
538
+ | 'br_codigo';
539
+
540
+ payment_type?:
541
+ | 'ach'
542
+ | 'au_becs'
543
+ | 'bacs'
544
+ | 'book'
545
+ | 'card'
546
+ | 'check'
547
+ | 'eft'
548
+ | 'interac'
549
+ | 'provxchange'
550
+ | 'rtp'
551
+ | 'sen'
552
+ | 'sepa'
553
+ | 'signet'
554
+ | 'wire';
555
+ }
556
+
557
+ export interface ContactDetails {
558
+ contact_identifier?: string;
559
+
560
+ contact_identifier_type?: 'email' | 'phone_number';
561
+ }
562
+ }
563
+ }
564
+
565
+ export interface CounterpartyUpdateParams {
566
+ /**
567
+ * A new email for the counterparty.
568
+ */
569
+ email?: string;
570
+
571
+ /**
572
+ * Additional data in the form of key-value pairs. Pairs can be removed by passing
573
+ * an empty string or `null` as the value.
574
+ */
575
+ metadata?: Record<string, string>;
576
+
577
+ /**
578
+ * A new name for the counterparty. Will only update if passed.
579
+ */
580
+ name?: string;
581
+
582
+ /**
583
+ * If this is `true`, Modern Treasury will send an email to the counterparty
584
+ * whenever an associated payment order is sent to the bank.
585
+ */
586
+ send_remittance_advice?: boolean;
587
+
588
+ /**
589
+ * Either a valid SSN or EIN.
590
+ */
591
+ taxpayer_identifier?: string;
592
+ }
593
+
594
+ export interface CounterpartyListParams extends PageParams {
595
+ /**
596
+ * Used to return counterparties created after some datetime.
597
+ */
598
+ created_at_lower_bound?: string;
599
+
600
+ /**
601
+ * Used to return counterparties created before some datetime.
602
+ */
603
+ created_at_upper_bound?: string;
604
+
605
+ /**
606
+ * Performs a partial string match of the email field. This is also case
607
+ * insensitive.
608
+ */
609
+ email?: string;
610
+
611
+ /**
612
+ * For example, if you want to query for records with metadata key `Type` and value
613
+ * `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query
614
+ * parameters.
615
+ */
616
+ metadata?: Record<string, string>;
617
+
618
+ /**
619
+ * Performs a partial string match of the name field. This is also case
620
+ * insensitive.
621
+ */
622
+ name?: string;
623
+ }
624
+
625
+ export interface CounterpartyCollectAccountParams {
626
+ /**
627
+ * One of `credit` or `debit`. Use `credit` when you want to pay a counterparty.
628
+ * Use `debit` when you need to charge a counterparty. This field helps us send a
629
+ * more tailored email to your counterparties."
630
+ */
631
+ direction: 'credit' | 'debit';
632
+
633
+ /**
634
+ * The URL you want your customer to visit upon filling out the form. By default,
635
+ * they will be sent to a Modern Treasury landing page. This must be a valid HTTPS
636
+ * URL if set.
637
+ */
638
+ custom_redirect?: string;
639
+
640
+ /**
641
+ * The list of fields you want on the form. This field is optional and if it is not
642
+ * set, will default to [\"nameOnAccount\", \"accountType\", \"accountNumber\",
643
+ * \"routingNumber\", \"address\"]. The full list of options is [\"name\",
644
+ * \"nameOnAccount\", \"taxpayerIdentifier\", \"accountType\", \"accountNumber\",
645
+ * \"routingNumber\", \"address\", \"ibanNumber\", \"swiftCode\"].
646
+ */
647
+ fields?: Array<
648
+ | 'name'
649
+ | 'nameOnAccount'
650
+ | 'taxpayerIdentifier'
651
+ | 'accountType'
652
+ | 'accountNumber'
653
+ | 'routingNumber'
654
+ | 'address'
655
+ | 'ibanNumber'
656
+ | 'swiftCode'
657
+ >;
658
+
659
+ /**
660
+ * By default, Modern Treasury will send an email to your counterparty that
661
+ * includes a link to the form they must fill out. However, if you would like to
662
+ * send the counterparty the link, you can set this parameter to `false`. The JSON
663
+ * body will include the link to the secure Modern Treasury form.
664
+ */
665
+ send_email?: boolean;
666
+ }