forked from Modern-Treasury/modern-treasury-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreturns.ts
More file actions
452 lines (406 loc) · 10.4 KB
/
Copy pathreturns.ts
File metadata and controls
452 lines (406 loc) · 10.4 KB
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
447
448
449
450
451
452
// 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 ReturnsAPI from './returns';
import * as Shared from './shared';
import { Page, type PageParams } from '../pagination';
export class Returns extends APIResource {
/**
* Create a return.
*/
create(params: ReturnCreateParams, options?: Core.RequestOptions): Core.APIPromise<ReturnObject> {
// @ts-expect-error idempotency key header isn't defined anymore but is included here for back-compat
const { 'Idempotency-Key': idempotencyKey, ...body } = params;
if (idempotencyKey) {
console.warn(
"The Idempotency-Key request param is deprecated, the 'idempotencyToken' option should be set instead",
);
}
return this._client.post('/api/returns', {
body,
...options,
headers: { 'Idempotency-Key': idempotencyKey, ...options?.headers },
});
}
/**
* Get a single return.
*/
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<ReturnObject> {
return this._client.get(`/api/returns/${id}`, options);
}
/**
* Get a list of returns.
*/
list(
query?: ReturnListParams,
options?: Core.RequestOptions,
): Core.PagePromise<ReturnObjectsPage, ReturnObject>;
list(options?: Core.RequestOptions): Core.PagePromise<ReturnObjectsPage, ReturnObject>;
list(
query: ReturnListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.PagePromise<ReturnObjectsPage, ReturnObject> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
return this._client.getAPIList('/api/returns', ReturnObjectsPage, { query, ...options });
}
}
export class ReturnObjectsPage extends Page<ReturnObject> {}
export interface ReturnObject {
id: string;
/**
* Value in specified currency's smallest unit. e.g. $10 would be represented
* as 1000.
*/
amount: number;
/**
* The return code. For ACH returns, this is the required ACH return code.
*/
code:
| '901'
| '902'
| '903'
| '904'
| '905'
| '907'
| '908'
| '909'
| '910'
| '911'
| '912'
| '914'
| 'C01'
| 'C02'
| 'C03'
| 'C05'
| 'C06'
| 'C07'
| 'C08'
| 'C09'
| 'C13'
| 'C14'
| 'R01'
| 'R02'
| 'R03'
| 'R04'
| 'R05'
| 'R06'
| 'R07'
| 'R08'
| 'R09'
| 'R10'
| 'R11'
| 'R12'
| 'R14'
| 'R15'
| 'R16'
| 'R17'
| 'R20'
| 'R21'
| 'R22'
| 'R23'
| 'R24'
| 'R29'
| 'R31'
| 'R33'
| 'R37'
| 'R38'
| 'R39'
| 'R51'
| 'R52'
| 'R53'
| 'currencycloud'
| null;
created_at: string;
/**
* Currency that this transaction is denominated in.
*/
currency: Shared.Currency;
/**
* If the return's status is `returned`, this will include the return object's data
* that is returning this return.
*/
current_return: ReturnObject | null;
/**
* If the return code is `R14` or `R15` this is the date the deceased counterparty
* passed away.
*/
date_of_death: string | null;
/**
* If an originating return failed to be processed by the bank, a description of
* the failure reason will be available.
*/
failure_reason: string | null;
/**
* The ID of the relevant Internal Account.
*/
internal_account_id: string | null;
/**
* The ID of the ledger transaction linked to the return.
*/
ledger_transaction_id: string | null;
/**
* This field will be true if this object exists in the live environment or false
* if it exists in the test environment.
*/
live_mode: boolean;
object: string;
/**
* Often the bank will provide an explanation for the return, which is a short
* human readable string.
*/
reason: string | null;
/**
* An array of Payment Reference objects.
*/
reference_numbers: Array<ReturnObject.ReferenceNumber>;
/**
* The ID of the object being returned or `null`.
*/
returnable_id: string | null;
/**
* The type of object being returned or `null`.
*/
returnable_type: 'incoming_payment_detail' | 'paper_item' | 'payment_order' | 'return' | 'reversal' | null;
/**
* The role of the return, can be `originating` or `receiving`.
*/
role: 'originating' | 'receiving';
/**
* The current status of the return.
*/
status: 'completed' | 'failed' | 'pending' | 'processing' | 'returned' | 'sent';
/**
* The ID of the relevant Transaction or `null`.
*/
transaction_id: string | null;
/**
* The ID of the relevant Transaction Line Item or `null`.
*/
transaction_line_item_id: string | null;
/**
* The type of return. Can be one of: `ach`, `ach_noc`, `au_becs`, `bacs`, `eft`,
* `interac`, `manual`, `paper_item`, `wire`.
*/
type:
| 'ach'
| 'ach_noc'
| 'au_becs'
| 'bacs'
| 'book'
| 'check'
| 'cross_border'
| 'eft'
| 'interac'
| 'manual'
| 'paper_item'
| 'sepa'
| 'wire';
updated_at: string;
/**
* Some returns may include additional information from the bank. In these cases,
* this string will be present.
*/
additional_information?: string | null;
}
export namespace ReturnObject {
export interface ReferenceNumber {
id: string;
created_at: string;
/**
* This field will be true if this object exists in the live environment or false
* if it exists in the test environment.
*/
live_mode: boolean;
object: string;
/**
* The vendor reference number.
*/
reference_number: string;
/**
* The type of the reference number. Referring to the vendor payment id.
*/
reference_number_type:
| 'ach_original_trace_number'
| 'ach_trace_number'
| 'bankprov_payment_activity_date'
| 'bankprov_payment_id'
| 'bnk_dev_prenotification_id'
| 'bnk_dev_transfer_id'
| 'bofa_end_to_end_id'
| 'bofa_transaction_id'
| 'check_number'
| 'citibank_reference_number'
| 'citibank_worldlink_clearing_system_reference_number'
| 'column_fx_quote_id'
| 'column_reversal_pair_transfer_id'
| 'column_transfer_id'
| 'cross_river_payment_id'
| 'cross_river_service_message'
| 'cross_river_transaction_id'
| 'currencycloud_conversion_id'
| 'currencycloud_payment_id'
| 'dc_bank_transaction_id'
| 'dwolla_transaction_id'
| 'eft_trace_number'
| 'evolve_transaction_id'
| 'fedwire_imad'
| 'fedwire_omad'
| 'first_republic_internal_id'
| 'goldman_sachs_collection_request_id'
| 'goldman_sachs_end_to_end_id'
| 'goldman_sachs_payment_request_id'
| 'goldman_sachs_request_id'
| 'goldman_sachs_unique_payment_id'
| 'interac_message_id'
| 'jpmc_ccn'
| 'jpmc_clearing_system_reference'
| 'jpmc_customer_reference_id'
| 'jpmc_end_to_end_id'
| 'jpmc_firm_root_id'
| 'jpmc_fx_trn_id'
| 'jpmc_p3_id'
| 'jpmc_payment_batch_id'
| 'jpmc_payment_information_id'
| 'jpmc_payment_returned_datetime'
| 'lob_check_id'
| 'other'
| 'partial_swift_mir'
| 'pnc_clearing_reference'
| 'pnc_instruction_id'
| 'pnc_multipayment_id'
| 'pnc_payment_trace_id'
| 'rspec_vendor_payment_id'
| 'rtp_instruction_id'
| 'signet_api_reference_id'
| 'signet_confirmation_id'
| 'signet_request_id'
| 'silvergate_payment_id'
| 'svb_end_to_end_id'
| 'svb_payment_id'
| 'svb_transaction_cleared_for_sanctions_review'
| 'svb_transaction_held_for_sanctions_review'
| 'swift_mir'
| 'swift_uetr'
| 'umb_product_partner_account_number'
| 'usbank_payment_id'
| 'wells_fargo_end_to_end_id'
| 'wells_fargo_payment_id'
| 'wells_fargo_trace_number'
| 'wells_fargo_uetr';
updated_at: string;
}
}
export interface ReturnCreateParams {
/**
* The ID of the object being returned or `null`.
*/
returnable_id: string | null;
/**
* The type of object being returned. Currently, this may only be
* incoming_payment_detail.
*/
returnable_type: 'incoming_payment_detail';
/**
* Some returns may include additional information from the bank. In these cases,
* this string will be present.
*/
additional_information?: string | null;
/**
* The return code. For ACH returns, this is the required ACH return code.
*/
code?:
| '901'
| '902'
| '903'
| '904'
| '905'
| '907'
| '908'
| '909'
| '910'
| '911'
| '912'
| '914'
| 'C01'
| 'C02'
| 'C03'
| 'C05'
| 'C06'
| 'C07'
| 'C08'
| 'C09'
| 'C13'
| 'C14'
| 'R01'
| 'R02'
| 'R03'
| 'R04'
| 'R05'
| 'R06'
| 'R07'
| 'R08'
| 'R09'
| 'R10'
| 'R11'
| 'R12'
| 'R14'
| 'R15'
| 'R16'
| 'R17'
| 'R20'
| 'R21'
| 'R22'
| 'R23'
| 'R24'
| 'R29'
| 'R31'
| 'R33'
| 'R37'
| 'R38'
| 'R39'
| 'R51'
| 'R52'
| 'R53'
| 'currencycloud'
| null;
/**
* If the return code is `R14` or `R15` this is the date the deceased counterparty
* passed away.
*/
date_of_death?: string | null;
/**
* An optional description of the reason for the return. This is for internal usage
* and will not be transmitted to the bank.”
*/
reason?: string | null;
}
export interface ReturnListParams extends PageParams {
/**
* Specify `counterparty_id` if you wish to see returns that occurred with a
* specific counterparty.
*/
counterparty_id?: string;
/**
* Specify `internal_account_id` if you wish to see returns to/from a specific
* account.
*/
internal_account_id?: string;
/**
* The ID of a valid returnable. Must be accompanied by `returnable_type`.
*/
returnable_id?: string;
/**
* One of `payment_order`, `paper_item`, `reversal`, or `incoming_payment_detail`.
* Must be accompanied by `returnable_id`.
*/
returnable_type?: 'incoming_payment_detail' | 'paper_item' | 'payment_order' | 'return' | 'reversal';
}
export namespace Returns {
export import ReturnObject = ReturnsAPI.ReturnObject;
export import ReturnObjectsPage = ReturnsAPI.ReturnObjectsPage;
export import ReturnCreateParams = ReturnsAPI.ReturnCreateParams;
export import ReturnListParams = ReturnsAPI.ReturnListParams;
}