-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinbound-mail-items.ts
More file actions
255 lines (223 loc) · 6.65 KB
/
inbound-mail-items.ts
File metadata and controls
255 lines (223 loc) · 6.65 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
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { Page, type PageParams, PagePromise } from '../core/pagination';
import { RequestOptions } from '../internal/request-options';
import { path } from '../internal/utils/path';
export class InboundMailItems extends APIResource {
/**
* Retrieve an Inbound Mail Item
*
* @example
* ```ts
* const inboundMailItem =
* await client.inboundMailItems.retrieve(
* 'inbound_mail_item_q6rrg7mmqpplx80zceev',
* );
* ```
*/
retrieve(inboundMailItemID: string, options?: RequestOptions): APIPromise<InboundMailItem> {
return this._client.get(path`/inbound_mail_items/${inboundMailItemID}`, options);
}
/**
* List Inbound Mail Items
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const inboundMailItem of client.inboundMailItems.list()) {
* // ...
* }
* ```
*/
list(
query: InboundMailItemListParams | null | undefined = {},
options?: RequestOptions,
): PagePromise<InboundMailItemsPage, InboundMailItem> {
return this._client.getAPIList('/inbound_mail_items', Page<InboundMailItem>, { query, ...options });
}
/**
* Action an Inbound Mail Item
*
* @example
* ```ts
* const inboundMailItem =
* await client.inboundMailItems.action(
* 'inbound_mail_item_q6rrg7mmqpplx80zceev',
* {
* checks: [{ action: 'deposit' }, { action: 'ignore' }],
* },
* );
* ```
*/
action(
inboundMailItemID: string,
body: InboundMailItemActionParams,
options?: RequestOptions,
): APIPromise<InboundMailItem> {
return this._client.post(path`/inbound_mail_items/${inboundMailItemID}/action`, { body, ...options });
}
}
export type InboundMailItemsPage = Page<InboundMailItem>;
/**
* Inbound Mail Items represent pieces of physical mail delivered to a Lockbox
* Address.
*/
export interface InboundMailItem {
/**
* The Inbound Mail Item identifier.
*/
id: string;
/**
* The checks in the mail item.
*/
checks: Array<InboundMailItem.Check>;
/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) time at which the Inbound
* Mail Item was created.
*/
created_at: string;
/**
* The identifier for the File containing the scanned contents of the mail item.
*/
file_id: string;
/**
* The identifier for the Lockbox Address that received this mail item.
*/
lockbox_address_id: string;
/**
* The identifier for the Lockbox Recipient that received this mail item. For mail
* items that could not be routed to a Lockbox Recipient, this will be null.
*/
lockbox_recipient_id: string | null;
/**
* The recipient name as written on the mail item.
*/
recipient_name: string | null;
/**
* If the mail item has been rejected, why it was rejected.
*
* - `no_matching_lockbox` - The mail item does not match any lockbox.
* - `no_check` - The mail item does not contain a check.
* - `lockbox_not_active` - The Lockbox or its associated Account is not active.
* - `lockbox_address_not_active` - The Lockbox Address is not active.
* - `lockbox_recipient_not_active` - The Lockbox Recipient or its associated
* Account is not active.
*/
rejection_reason:
| 'no_matching_lockbox'
| 'no_check'
| 'lockbox_not_active'
| 'lockbox_address_not_active'
| 'lockbox_recipient_not_active'
| null;
/**
* If the mail item has been processed.
*
* - `pending` - The mail item is pending processing.
* - `processed` - The mail item has been processed.
* - `rejected` - The mail item has been rejected.
*/
status: 'pending' | 'processed' | 'rejected';
/**
* A constant representing the object's type. For this resource it will always be
* `inbound_mail_item`.
*/
type: 'inbound_mail_item';
[k: string]: unknown;
}
export namespace InboundMailItem {
/**
* Inbound Mail Item Checks represent the checks in an Inbound Mail Item.
*/
export interface Check {
/**
* The amount of the check.
*/
amount: number;
/**
* The identifier for the File containing the back of the check.
*/
back_file_id: string | null;
/**
* The identifier of the Check Deposit if this check was deposited.
*/
check_deposit_id: string | null;
/**
* The identifier for the File containing the front of the check.
*/
front_file_id: string | null;
/**
* The status of the Inbound Mail Item Check.
*
* - `pending` - The check is pending processing.
* - `deposited` - The check has been deposited.
* - `ignored` - The check has been ignored.
*/
status: 'pending' | 'deposited' | 'ignored' | null;
}
}
export interface InboundMailItemListParams extends PageParams {
created_at?: InboundMailItemListParams.CreatedAt;
/**
* Filter Inbound Mail Items to ones sent to the provided Lockbox Address.
*/
lockbox_address_id?: string;
/**
* Filter Inbound Mail Items to ones sent to the provided Lockbox Recipient.
*/
lockbox_recipient_id?: string;
}
export namespace InboundMailItemListParams {
export interface CreatedAt {
/**
* Return results after this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
* timestamp.
*/
after?: string;
/**
* Return results before this [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)
* timestamp.
*/
before?: string;
/**
* Return results on or after this
* [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp.
*/
on_or_after?: string;
/**
* Return results on or before this
* [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) timestamp.
*/
on_or_before?: string;
}
}
export interface InboundMailItemActionParams {
/**
* The actions to perform on the Inbound Mail Item.
*/
checks: Array<InboundMailItemActionParams.Check>;
}
export namespace InboundMailItemActionParams {
export interface Check {
/**
* The action to perform on the Inbound Mail Item.
*
* - `deposit` - The check will be deposited.
* - `ignore` - The check will be ignored.
*/
action: 'deposit' | 'ignore';
/**
* The identifier of the Account to deposit the check into.
*/
account_id?: string;
}
}
export declare namespace InboundMailItems {
export {
type InboundMailItem as InboundMailItem,
type InboundMailItemsPage as InboundMailItemsPage,
type InboundMailItemListParams as InboundMailItemListParams,
type InboundMailItemActionParams as InboundMailItemActionParams,
};
}