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
@@ -0,0 +1,377 @@
1
+ import * as Core from '../core';
2
+ import { APIResource } from '../resource';
3
+ import { Page, PageParams } from '../pagination';
4
+ export declare class Transactions extends APIResource {
5
+ /**
6
+ * Get details on a single transaction.
7
+ */
8
+ retrieve(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<Transaction>>;
9
+ /**
10
+ * Update a single transaction.
11
+ */
12
+ update(
13
+ id: string,
14
+ body?: TransactionUpdateParams,
15
+ options?: Core.RequestOptions,
16
+ ): Promise<Core.APIResponse<Transaction>>;
17
+ update(id: string, options?: Core.RequestOptions): Promise<Core.APIResponse<Transaction>>;
18
+ /**
19
+ * Get a list of all transactions.
20
+ */
21
+ list(query?: TransactionListParams, options?: Core.RequestOptions): Core.PagePromise<TransactionsPage>;
22
+ list(options?: Core.RequestOptions): Core.PagePromise<TransactionsPage>;
23
+ }
24
+ export declare class TransactionsPage extends Page<Transaction> {}
25
+ export interface Transaction {
26
+ /**
27
+ * Value in specified currency's smallest unit. e.g. $10 would be represented
28
+ * as 1000.
29
+ */
30
+ amount?: number;
31
+ /**
32
+ * The date on which the transaction occurred.
33
+ */
34
+ as_of_date?: string | null;
35
+ /**
36
+ * The time on which the transaction occurred. Depending on the granularity of the
37
+ * timestamp information received from the bank, it may be `null`.
38
+ */
39
+ as_of_time?: string | null;
40
+ created_at?: string;
41
+ /**
42
+ * Currency that this transaction is denominated in.
43
+ */
44
+ currency?:
45
+ | 'AED'
46
+ | 'AFN'
47
+ | 'ALL'
48
+ | 'AMD'
49
+ | 'ANG'
50
+ | 'AOA'
51
+ | 'ARS'
52
+ | 'AUD'
53
+ | 'AWG'
54
+ | 'AZN'
55
+ | 'BAM'
56
+ | 'BBD'
57
+ | 'BCH'
58
+ | 'BDT'
59
+ | 'BGN'
60
+ | 'BHD'
61
+ | 'BIF'
62
+ | 'BMD'
63
+ | 'BND'
64
+ | 'BOB'
65
+ | 'BRL'
66
+ | 'BSD'
67
+ | 'BTC'
68
+ | 'BTN'
69
+ | 'BWP'
70
+ | 'BYN'
71
+ | 'BYR'
72
+ | 'BZD'
73
+ | 'CAD'
74
+ | 'CDF'
75
+ | 'CHF'
76
+ | 'CLF'
77
+ | 'CLP'
78
+ | 'CNH'
79
+ | 'CNY'
80
+ | 'COP'
81
+ | 'CRC'
82
+ | 'CUC'
83
+ | 'CUP'
84
+ | 'CVE'
85
+ | 'CZK'
86
+ | 'DJF'
87
+ | 'DKK'
88
+ | 'DOP'
89
+ | 'DZD'
90
+ | 'EEK'
91
+ | 'EGP'
92
+ | 'ERN'
93
+ | 'ETB'
94
+ | 'EUR'
95
+ | 'FJD'
96
+ | 'FKP'
97
+ | 'GBP'
98
+ | 'GBX'
99
+ | 'GEL'
100
+ | 'GGP'
101
+ | 'GHS'
102
+ | 'GIP'
103
+ | 'GMD'
104
+ | 'GNF'
105
+ | 'GTQ'
106
+ | 'GYD'
107
+ | 'HKD'
108
+ | 'HNL'
109
+ | 'HRK'
110
+ | 'HTG'
111
+ | 'HUF'
112
+ | 'IDR'
113
+ | 'ILS'
114
+ | 'IMP'
115
+ | 'INR'
116
+ | 'IQD'
117
+ | 'IRR'
118
+ | 'ISK'
119
+ | 'JEP'
120
+ | 'JMD'
121
+ | 'JOD'
122
+ | 'JPY'
123
+ | 'KES'
124
+ | 'KGS'
125
+ | 'KHR'
126
+ | 'KMF'
127
+ | 'KPW'
128
+ | 'KRW'
129
+ | 'KWD'
130
+ | 'KYD'
131
+ | 'KZT'
132
+ | 'LAK'
133
+ | 'LBP'
134
+ | 'LKR'
135
+ | 'LRD'
136
+ | 'LSL'
137
+ | 'LTL'
138
+ | 'LVL'
139
+ | 'LYD'
140
+ | 'MAD'
141
+ | 'MDL'
142
+ | 'MGA'
143
+ | 'MKD'
144
+ | 'MMK'
145
+ | 'MNT'
146
+ | 'MOP'
147
+ | 'MRO'
148
+ | 'MRU'
149
+ | 'MTL'
150
+ | 'MUR'
151
+ | 'MVR'
152
+ | 'MWK'
153
+ | 'MXN'
154
+ | 'MYR'
155
+ | 'MZN'
156
+ | 'NAD'
157
+ | 'NGN'
158
+ | 'NIO'
159
+ | 'NOK'
160
+ | 'NPR'
161
+ | 'NZD'
162
+ | 'OMR'
163
+ | 'PAB'
164
+ | 'PEN'
165
+ | 'PGK'
166
+ | 'PHP'
167
+ | 'PKR'
168
+ | 'PLN'
169
+ | 'PYG'
170
+ | 'QAR'
171
+ | 'RON'
172
+ | 'RSD'
173
+ | 'RUB'
174
+ | 'RWF'
175
+ | 'SAR'
176
+ | 'SBD'
177
+ | 'SCR'
178
+ | 'SDG'
179
+ | 'SEK'
180
+ | 'SGD'
181
+ | 'SHP'
182
+ | 'SKK'
183
+ | 'SLL'
184
+ | 'SOS'
185
+ | 'SRD'
186
+ | 'SSP'
187
+ | 'STD'
188
+ | 'SVC'
189
+ | 'SYP'
190
+ | 'SZL'
191
+ | 'THB'
192
+ | 'TJS'
193
+ | 'TMM'
194
+ | 'TMT'
195
+ | 'TND'
196
+ | 'TOP'
197
+ | 'TRY'
198
+ | 'TTD'
199
+ | 'TWD'
200
+ | 'TZS'
201
+ | 'UAH'
202
+ | 'UGX'
203
+ | 'USD'
204
+ | 'UYU'
205
+ | 'UZS'
206
+ | 'VEF'
207
+ | 'VES'
208
+ | 'VND'
209
+ | 'VUV'
210
+ | 'WST'
211
+ | 'XAF'
212
+ | 'XAG'
213
+ | 'XAU'
214
+ | 'XBA'
215
+ | 'XBB'
216
+ | 'XBC'
217
+ | 'XBD'
218
+ | 'XCD'
219
+ | 'XDR'
220
+ | 'XFU'
221
+ | 'XOF'
222
+ | 'XPD'
223
+ | 'XPF'
224
+ | 'XPT'
225
+ | 'XTS'
226
+ | 'YER'
227
+ | 'ZAR'
228
+ | 'ZMK'
229
+ | 'ZMW'
230
+ | 'ZWD'
231
+ | 'ZWL'
232
+ | 'ZWN'
233
+ | 'ZWR';
234
+ /**
235
+ * This field contains additional information that the bank provided about the
236
+ * transaction. This is structured data. Some of the data in here might overlap
237
+ * with what is in the `vendor_description`. For example, the OBI could be a part
238
+ * of the vendor description, and it would also be included in here. The attributes
239
+ * that are passed through the details field will vary based on your banking
240
+ * partner. Currently, the following keys may be in the details object:
241
+ * `originator_name`, `originator_to_beneficiary_information`.
242
+ */
243
+ details?: Record<string, string>;
244
+ /**
245
+ * Either `credit` or `debit`.
246
+ */
247
+ direction?: string;
248
+ discarded_at?: string | null;
249
+ id?: string;
250
+ /**
251
+ * The ID of the relevant Internal Account.
252
+ */
253
+ internal_account_id?: string;
254
+ /**
255
+ * This field will be true if this object exists in the live environment or false
256
+ * if it exists in the test environment.
257
+ */
258
+ live_mode?: boolean;
259
+ /**
260
+ * Additional data represented as key-value pairs. Both the key and value must be
261
+ * strings.
262
+ */
263
+ metadata?: Record<string, string>;
264
+ object?: string;
265
+ /**
266
+ * This field will be `true` if the transaction has posted to the account.
267
+ */
268
+ posted?: boolean;
269
+ /**
270
+ * This field will be `true` if a transaction is reconciled by the Modern Treasury
271
+ * system. This means that it has transaction line items that sum up to the
272
+ * transaction's amount.
273
+ */
274
+ reconciled?: boolean;
275
+ /**
276
+ * The type of the transaction. Can be one of `ach`, `wire`, `check`, `rtp`,
277
+ * `book`, or `sen`.
278
+ */
279
+ type?:
280
+ | 'ach'
281
+ | 'au_becs'
282
+ | 'bacs'
283
+ | 'book'
284
+ | 'card'
285
+ | 'check'
286
+ | 'eft'
287
+ | 'interac'
288
+ | 'provxchange'
289
+ | 'rtp'
290
+ | 'sen'
291
+ | 'sepa'
292
+ | 'signet'
293
+ | 'wire';
294
+ updated_at?: string;
295
+ /**
296
+ * When applicable, the bank-given code that determines the transaction's category.
297
+ * For most banks this is the BAI2/BTRS transaction code.
298
+ */
299
+ vendor_code?: string | null;
300
+ /**
301
+ * The type of vendor_code being reported. Can be one of `bai2`, `swift`,
302
+ * `cleartouch`, or `silvergate`.
303
+ */
304
+ vendor_code_type?:
305
+ | 'bai2'
306
+ | 'bankprov'
307
+ | 'bnk_dev'
308
+ | 'cleartouch'
309
+ | 'cross_river'
310
+ | 'currencycloud'
311
+ | 'dc_bank'
312
+ | 'dwolla'
313
+ | 'goldman_sachs'
314
+ | 'iso20022'
315
+ | 'jpmc'
316
+ | 'mx'
317
+ | 'signet'
318
+ | 'silvergate'
319
+ | 'swift'
320
+ | null;
321
+ /**
322
+ * An identifier given to this transaction by the bank, often `null`.
323
+ */
324
+ vendor_customer_id?: string | null;
325
+ /**
326
+ * The transaction detail text that often appears in on your bank statement and in
327
+ * your banking portal.
328
+ */
329
+ vendor_description?: string | null;
330
+ /**
331
+ * An identifier given to this transaction by the bank.
332
+ */
333
+ vendor_id?: string | null;
334
+ }
335
+ export interface TransactionUpdateParams {
336
+ /**
337
+ * Additional data in the form of key-value pairs. Pairs can be removed by passing
338
+ * an empty string or `null` as the value.
339
+ */
340
+ metadata?: Record<string, string>;
341
+ }
342
+ export interface TransactionListParams extends PageParams {
343
+ /**
344
+ * Filters transactions with an `as_of_date` starting on or before the specified
345
+ * date (YYYY-MM-DD).
346
+ */
347
+ as_of_date_end?: string;
348
+ /**
349
+ * Filters transactions with an `as_of_date` starting on or after the specified
350
+ * date (YYYY-MM-DD).
351
+ */
352
+ as_of_date_start?: string;
353
+ counterparty_id?: string;
354
+ /**
355
+ * Filters for transactions including the queried string in the description.
356
+ */
357
+ description?: string;
358
+ direction?: string;
359
+ /**
360
+ * Specify `internal_account_id` if you wish to see transactions to/from a specific
361
+ * account.
362
+ */
363
+ internal_account_id?: string;
364
+ /**
365
+ * For example, if you want to query for records with metadata key `Type` and value
366
+ * `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query
367
+ * parameters.
368
+ */
369
+ metadata?: Record<string, string>;
370
+ payment_type?: string;
371
+ /**
372
+ * Either `true` or `false`.
373
+ */
374
+ posted?: boolean;
375
+ transactable_type?: string;
376
+ virtual_account_id?: string;
377
+ }
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ exports.TransactionsPage = exports.Transactions = void 0;
5
+ const resource_1 = require('../resource');
6
+ const core_1 = require('../core');
7
+ const pagination_1 = require('../pagination');
8
+ class Transactions extends resource_1.APIResource {
9
+ /**
10
+ * Get details on a single transaction.
11
+ */
12
+ retrieve(id, options) {
13
+ return this.get(`/api/transactions/${id}`, options);
14
+ }
15
+ update(id, body = {}, options) {
16
+ if ((0, core_1.isRequestOptions)(body)) {
17
+ return this.update(id, {}, body);
18
+ }
19
+ return this.patch(`/api/transactions/${id}`, Object.assign({ body }, options));
20
+ }
21
+ list(query = {}, options) {
22
+ if ((0, core_1.isRequestOptions)(query)) {
23
+ return this.list({}, query);
24
+ }
25
+ return this.getAPIList('/api/transactions', TransactionsPage, Object.assign({ query }, options));
26
+ }
27
+ }
28
+ exports.Transactions = Transactions;
29
+ class TransactionsPage extends pagination_1.Page {}
30
+ exports.TransactionsPage = TransactionsPage;
31
+ //# sourceMappingURL=transactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../resources/transactions.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,yCAAyC;AACzC,iCAA0C;AAC1C,6CAAgD;AAEhD,MAAa,YAAa,SAAQ,sBAAW;IAC3C;;OAEG;IACH,QAAQ,CAAC,EAAU,EAAE,OAA6B;QAChD,OAAO,IAAI,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAWD,MAAM,CACJ,EAAU,EACV,OAAsD,EAAE,EACxD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,IAAI,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;SAClC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,kBAAI,IAAI,IAAK,OAAO,EAAG,CAAC;IACrE,CAAC;IAOD,IAAI,CACF,QAAqD,EAAE,EACvD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SAC7B;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,mBAAmB,EAAE,gBAAgB,kBAAI,KAAK,IAAK,OAAO,EAAG,CAAC;IACvF,CAAC;CACF;AA5CD,oCA4CC;AAED,MAAa,gBAAiB,SAAQ,iBAAiB;CAAG;AAA1D,4CAA0D"}
@@ -0,0 +1,97 @@
1
+ import * as Core from '../core';
2
+ import { APIResource } from '../resource';
3
+ export declare class Validations extends APIResource {
4
+ /**
5
+ * Validates the routing number information supplied without creating a routing
6
+ * detail
7
+ */
8
+ validateRoutingNumber(
9
+ query: ValidationValidateRoutingNumberParams,
10
+ options?: Core.RequestOptions,
11
+ ): Promise<Core.APIResponse<RoutingNumberLookupRequest>>;
12
+ }
13
+ export interface RoutingNumberLookupRequest {
14
+ /**
15
+ * The address of the bank.
16
+ */
17
+ bank_address?: RoutingNumberLookupRequest.BankAddress;
18
+ /**
19
+ * The name of the bank.
20
+ */
21
+ bank_name?: string;
22
+ /**
23
+ * The routing number of the bank.
24
+ */
25
+ routing_number?: string;
26
+ /**
27
+ * One of `aba`, `au_bsb`, `br_codigo`, `ca_cpa`, `cnaps`, `gb_sort_code`,
28
+ * `in_ifsc`, `my_branch_code`, or `swift`. In sandbox mode we currently only
29
+ * support `aba` and `swift` with routing numbers '123456789' and 'GRINUST0XXX'
30
+ * respectively.
31
+ */
32
+ routing_number_type?: 'aba' | 'au_bsb' | 'ca_cpa' | 'gb_sort_code' | 'swift';
33
+ /**
34
+ * An array of payment types that are supported for this routing number. This can
35
+ * include `ach`, `wire`, `rtp`, `sepa`, `bacs`, `au_becs` currently.
36
+ */
37
+ supported_payment_types?: Array<
38
+ | 'ach'
39
+ | 'au_becs'
40
+ | 'bacs'
41
+ | 'book'
42
+ | 'card'
43
+ | 'check'
44
+ | 'eft'
45
+ | 'interac'
46
+ | 'provxchange'
47
+ | 'rtp'
48
+ | 'sen'
49
+ | 'sepa'
50
+ | 'signet'
51
+ | 'wire'
52
+ >;
53
+ }
54
+ export declare namespace RoutingNumberLookupRequest {
55
+ interface BankAddress {
56
+ /**
57
+ * Country code conforms to [ISO 3166-1 alpha-2]
58
+ */
59
+ country?: string | null;
60
+ line1?: string | null;
61
+ line2?: string | null;
62
+ /**
63
+ * Locality or City.
64
+ */
65
+ locality?: string | null;
66
+ /**
67
+ * The postal code of the address.
68
+ */
69
+ postal_code?: string | null;
70
+ /**
71
+ * Region or State.
72
+ */
73
+ region?: string | null;
74
+ }
75
+ }
76
+ export interface ValidationValidateRoutingNumberParams {
77
+ /**
78
+ * The routing number that is being validated.
79
+ */
80
+ routing_number: string;
81
+ /**
82
+ * One of `aba`, `au_bsb`, `br_codigo`, `ca_cpa`, `cnaps`, `gb_sort_code`,
83
+ * `in_ifsc`, `my_branch_code`, or `swift`. In sandbox mode we currently only
84
+ * support `aba` and `swift` with routing numbers '123456789' and 'GRINUST0XXX'
85
+ * respectively.
86
+ */
87
+ routing_number_type:
88
+ | 'aba'
89
+ | 'au_bsb'
90
+ | 'br_codigo'
91
+ | 'ca_cpa'
92
+ | 'cnaps'
93
+ | 'gb_sort_code'
94
+ | 'in_ifsc'
95
+ | 'my_branch_code'
96
+ | 'swift';
97
+ }
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ exports.Validations = void 0;
5
+ const resource_1 = require('../resource');
6
+ class Validations extends resource_1.APIResource {
7
+ /**
8
+ * Validates the routing number information supplied without creating a routing
9
+ * detail
10
+ */
11
+ validateRoutingNumber(query, options) {
12
+ return this.get('/api/validations/routing_numbers', Object.assign({ query }, options));
13
+ }
14
+ }
15
+ exports.Validations = Validations;
16
+ //# sourceMappingURL=validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","sourceRoot":"","sources":["../../../resources/validations.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAGrD,yCAAyC;AAEzC,MAAa,WAAY,SAAQ,sBAAW;IAC1C;;;OAGG;IACH,qBAAqB,CACnB,KAA4C,EAC5C,OAA6B;QAE7B,OAAO,IAAI,CAAC,GAAG,CAAC,kCAAkC,kBAAI,KAAK,IAAK,OAAO,EAAG,CAAC;IAC7E,CAAC;CACF;AAXD,kCAWC"}
@@ -0,0 +1,31 @@
1
+ import { APIResource } from '../resource';
2
+ import type { HeadersLike } from '../core';
3
+ export declare class Webhooks extends APIResource {
4
+ /**
5
+ * To verify that a webhook was actually sent by Modern Treasury, every payload is
6
+ * signed with a signature that is passed through the `X-Signature` HTTP header.
7
+ *
8
+ * This method will generate a signature based off of your webhook key which can be
9
+ * found in the Developer Settings,
10
+ * https://app.moderntreasury.com/developers/webhooks, and the webhook payload.
11
+ *
12
+ * You can then compare the generated signature with the signature sent with the
13
+ * request, if they match then the webhook was sent by Modern Treasury.
14
+ */
15
+ getSignature(
16
+ payload: string,
17
+ opts?: {
18
+ key?: string | null | undefined;
19
+ },
20
+ ): string;
21
+ /**
22
+ * Returns whether or not the webhook payload was sent by Modern Treasury.
23
+ */
24
+ validateSignature(
25
+ payload: string,
26
+ headers: string | HeadersLike,
27
+ opts?: {
28
+ key?: string | null | undefined;
29
+ },
30
+ ): boolean;
31
+ }
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+ // File generated from our OpenAPI spec by Stainless.
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+ exports.Webhooks = void 0;
5
+ const resource_1 = require('../resource');
6
+ const crypto_1 = require('crypto');
7
+ const core_1 = require('../core');
8
+ class Webhooks extends resource_1.APIResource {
9
+ /**
10
+ * To verify that a webhook was actually sent by Modern Treasury, every payload is
11
+ * signed with a signature that is passed through the `X-Signature` HTTP header.
12
+ *
13
+ * This method will generate a signature based off of your webhook key which can be
14
+ * found in the Developer Settings,
15
+ * https://app.moderntreasury.com/developers/webhooks, and the webhook payload.
16
+ *
17
+ * You can then compare the generated signature with the signature sent with the
18
+ * request, if they match then the webhook was sent by Modern Treasury.
19
+ */
20
+ getSignature(payload, opts) {
21
+ const key = (opts === null || opts === void 0 ? void 0 : opts.key) || this.client.webhookKey;
22
+ if (key == null) {
23
+ throw new Error(
24
+ "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",
25
+ );
26
+ }
27
+ if (!key) {
28
+ throw new Error('The webhook key is set but appears to be empty.');
29
+ }
30
+ return (0, crypto_1.createHmac)('sha256', key).update(payload, 'utf8').digest('hex');
31
+ }
32
+ /**
33
+ * Returns whether or not the webhook payload was sent by Modern Treasury.
34
+ */
35
+ validateSignature(payload, headers, opts) {
36
+ const signature = this.getSignature(payload, opts);
37
+ const expectedSignature =
38
+ typeof headers === 'string' ? headers : (0, core_1.getHeader)(headers, 'X-Signature');
39
+ if (!expectedSignature) throw new Error('Could not find an X-Signature header');
40
+ return signature === expectedSignature;
41
+ }
42
+ }
43
+ exports.Webhooks = Webhooks;
44
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../../resources/webhooks.ts"],"names":[],"mappings":";AAAA,qDAAqD;;;AAErD,yCAAyC;AACzC,mCAAoC;AAGpC,iCAAmC;AAEnC,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;OAUG;IACH,YAAY,CAAC,OAAe,EAAE,IAA0C;QACtE,MAAM,GAAG,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,GAAG,KAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QAChD,IAAI,GAAG,IAAI,IAAI,EAAE;YACf,MAAM,IAAI,KAAK,CACb,8KAA8K,CAC/K,CAAC;SACH;QACD,IAAI,CAAC,GAAG,EAAE;YACR,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;SACpE;QAED,OAAO,IAAA,mBAAU,EAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACzE,CAAC;IAED;;OAEG;IACH,iBAAiB,CACf,OAAe,EACf,OAA6B,EAC7B,IAA0C;QAE1C,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACnD,MAAM,iBAAiB,GAAG,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,gBAAS,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;QACpG,IAAI,CAAC,iBAAiB;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAChF,OAAO,SAAS,KAAK,iBAAiB,CAAC;IACzC,CAAC;CACF;AAvCD,4BAuCC"}