mailerbot 0.1.0
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/LICENSE +21 -0
- package/README.md +290 -0
- package/dist/index.cjs +852 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +737 -0
- package/dist/index.d.ts +737 -0
- package/dist/index.js +842 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,737 @@
|
|
|
1
|
+
interface RequestOptions {
|
|
2
|
+
method?: string;
|
|
3
|
+
path: string;
|
|
4
|
+
body?: unknown;
|
|
5
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
declare class HttpClient {
|
|
9
|
+
private readonly baseUrl;
|
|
10
|
+
private readonly headers;
|
|
11
|
+
private readonly timeout;
|
|
12
|
+
constructor(baseUrl: string, headers: Record<string, string>, timeout: number);
|
|
13
|
+
request<T>(options: RequestOptions): Promise<T>;
|
|
14
|
+
requestRaw(options: RequestOptions & {
|
|
15
|
+
rawBody?: FormData | string;
|
|
16
|
+
rawHeaders?: Record<string, string>;
|
|
17
|
+
}): Promise<Response>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface Page<T> {
|
|
21
|
+
items: T[];
|
|
22
|
+
total: number;
|
|
23
|
+
page: number;
|
|
24
|
+
pageSize: number;
|
|
25
|
+
pages: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Contact {
|
|
29
|
+
id: string;
|
|
30
|
+
firstName: string;
|
|
31
|
+
lastName: string;
|
|
32
|
+
company?: string | null;
|
|
33
|
+
addressLine1: string;
|
|
34
|
+
addressLine2?: string | null;
|
|
35
|
+
city: string;
|
|
36
|
+
state: string;
|
|
37
|
+
zip: string;
|
|
38
|
+
countryCode: string;
|
|
39
|
+
countryName: string;
|
|
40
|
+
email?: string | null;
|
|
41
|
+
phone?: string | null;
|
|
42
|
+
validationStatus?: string | null;
|
|
43
|
+
correctedAddress?: Record<string, unknown> | null;
|
|
44
|
+
}
|
|
45
|
+
interface ContactList {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
contactIds: string[];
|
|
49
|
+
createdAt: string;
|
|
50
|
+
updatedAt: string;
|
|
51
|
+
}
|
|
52
|
+
interface AddressValidation {
|
|
53
|
+
contactId: string;
|
|
54
|
+
name: string;
|
|
55
|
+
status: string;
|
|
56
|
+
original: string;
|
|
57
|
+
corrected?: string | null;
|
|
58
|
+
}
|
|
59
|
+
interface CsvImportResult {
|
|
60
|
+
importedCount: number;
|
|
61
|
+
listId?: string | null;
|
|
62
|
+
}
|
|
63
|
+
interface CreateContactParams {
|
|
64
|
+
firstName: string;
|
|
65
|
+
lastName: string;
|
|
66
|
+
addressLine1: string;
|
|
67
|
+
city: string;
|
|
68
|
+
state: string;
|
|
69
|
+
zip: string;
|
|
70
|
+
countryCode?: string;
|
|
71
|
+
company?: string;
|
|
72
|
+
addressLine2?: string;
|
|
73
|
+
email?: string;
|
|
74
|
+
phone?: string;
|
|
75
|
+
}
|
|
76
|
+
interface UpdateContactParams {
|
|
77
|
+
firstName?: string;
|
|
78
|
+
lastName?: string;
|
|
79
|
+
addressLine1?: string;
|
|
80
|
+
city?: string;
|
|
81
|
+
state?: string;
|
|
82
|
+
zip?: string;
|
|
83
|
+
countryCode?: string;
|
|
84
|
+
company?: string;
|
|
85
|
+
addressLine2?: string;
|
|
86
|
+
email?: string;
|
|
87
|
+
phone?: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Async auto-paginating iterator. Yields individual items across all pages.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* for await (const contact of client.contacts.iterAll()) {
|
|
96
|
+
* console.log(contact.firstName);
|
|
97
|
+
* }
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare class PageIterator<T> implements AsyncIterable<T> {
|
|
101
|
+
private readonly fetch;
|
|
102
|
+
private readonly pageSize;
|
|
103
|
+
constructor(fetch: (page: number, pageSize: number) => Promise<Page<T>>, pageSize?: number);
|
|
104
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
declare class ContactsResource {
|
|
108
|
+
private readonly http;
|
|
109
|
+
constructor(http: HttpClient);
|
|
110
|
+
list(options?: {
|
|
111
|
+
page?: number;
|
|
112
|
+
pageSize?: number;
|
|
113
|
+
search?: string;
|
|
114
|
+
}): Promise<Page<Contact>>;
|
|
115
|
+
iterAll(options?: {
|
|
116
|
+
pageSize?: number;
|
|
117
|
+
search?: string;
|
|
118
|
+
}): PageIterator<Contact>;
|
|
119
|
+
get(contactId: string): Promise<Contact>;
|
|
120
|
+
create(params: CreateContactParams): Promise<Contact>;
|
|
121
|
+
update(contactId: string, params: UpdateContactParams): Promise<Contact>;
|
|
122
|
+
delete(contactId: string): Promise<void>;
|
|
123
|
+
importCsv(contacts: Record<string, unknown>[], options?: {
|
|
124
|
+
listName?: string;
|
|
125
|
+
}): Promise<CsvImportResult>;
|
|
126
|
+
validateAddresses(contactIds: string[]): Promise<AddressValidation[]>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare class ContactListsResource {
|
|
130
|
+
private readonly http;
|
|
131
|
+
constructor(http: HttpClient);
|
|
132
|
+
list(): Promise<ContactList[]>;
|
|
133
|
+
get(listId: string): Promise<ContactList>;
|
|
134
|
+
create(name: string, options?: {
|
|
135
|
+
contactIds?: string[];
|
|
136
|
+
}): Promise<ContactList>;
|
|
137
|
+
update(listId: string, name: string): Promise<ContactList>;
|
|
138
|
+
delete(listId: string): Promise<void>;
|
|
139
|
+
addContacts(listId: string, contactIds: string[]): Promise<void>;
|
|
140
|
+
removeContacts(listId: string, contactIds: string[]): Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
interface Document {
|
|
144
|
+
id: string;
|
|
145
|
+
title: string;
|
|
146
|
+
content?: string | null;
|
|
147
|
+
createdAt: string;
|
|
148
|
+
updatedAt: string;
|
|
149
|
+
type: string;
|
|
150
|
+
pdfUrl?: string | null;
|
|
151
|
+
thumbnailUrl?: string | null;
|
|
152
|
+
pageCount?: number | null;
|
|
153
|
+
fileSize?: number | null;
|
|
154
|
+
}
|
|
155
|
+
interface CreateDocumentParams {
|
|
156
|
+
title?: string;
|
|
157
|
+
content?: string;
|
|
158
|
+
}
|
|
159
|
+
interface UpdateDocumentParams {
|
|
160
|
+
title?: string;
|
|
161
|
+
content?: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
declare class DocumentsResource {
|
|
165
|
+
private readonly http;
|
|
166
|
+
constructor(http: HttpClient);
|
|
167
|
+
list(options?: {
|
|
168
|
+
page?: number;
|
|
169
|
+
pageSize?: number;
|
|
170
|
+
type?: string;
|
|
171
|
+
}): Promise<Page<Document>>;
|
|
172
|
+
iterAll(options?: {
|
|
173
|
+
pageSize?: number;
|
|
174
|
+
}): PageIterator<Document>;
|
|
175
|
+
get(documentId: string): Promise<Document>;
|
|
176
|
+
create(params?: CreateDocumentParams): Promise<Document>;
|
|
177
|
+
update(documentId: string, params: UpdateDocumentParams): Promise<Document>;
|
|
178
|
+
delete(documentId: string): Promise<void>;
|
|
179
|
+
upload(file: Blob | ArrayBuffer | Uint8Array<ArrayBuffer>, filename: string): Promise<Document>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface PostcardSide {
|
|
183
|
+
elements: Record<string, unknown>[];
|
|
184
|
+
backgroundColor: string;
|
|
185
|
+
backgroundImage?: string | null;
|
|
186
|
+
backgroundImageOpacity?: number | null;
|
|
187
|
+
}
|
|
188
|
+
interface Postcard {
|
|
189
|
+
id: string;
|
|
190
|
+
title: string;
|
|
191
|
+
front?: PostcardSide | null;
|
|
192
|
+
back?: PostcardSide | null;
|
|
193
|
+
width: number;
|
|
194
|
+
height: number;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
updatedAt: string;
|
|
197
|
+
templateId?: string | null;
|
|
198
|
+
}
|
|
199
|
+
interface PostcardTemplate {
|
|
200
|
+
id: string;
|
|
201
|
+
name: string;
|
|
202
|
+
description?: string | null;
|
|
203
|
+
category: string;
|
|
204
|
+
thumbnailUrl?: string | null;
|
|
205
|
+
front?: PostcardSide | null;
|
|
206
|
+
back?: PostcardSide | null;
|
|
207
|
+
}
|
|
208
|
+
interface CreatePostcardParams {
|
|
209
|
+
title?: string;
|
|
210
|
+
front?: Record<string, unknown>;
|
|
211
|
+
back?: Record<string, unknown>;
|
|
212
|
+
}
|
|
213
|
+
interface UpdatePostcardParams {
|
|
214
|
+
title?: string;
|
|
215
|
+
front?: Record<string, unknown>;
|
|
216
|
+
back?: Record<string, unknown>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
declare class PostcardsResource {
|
|
220
|
+
private readonly http;
|
|
221
|
+
constructor(http: HttpClient);
|
|
222
|
+
listTemplates(): Promise<PostcardTemplate[]>;
|
|
223
|
+
getTemplate(templateId: string): Promise<PostcardTemplate>;
|
|
224
|
+
list(options?: {
|
|
225
|
+
page?: number;
|
|
226
|
+
pageSize?: number;
|
|
227
|
+
}): Promise<Page<Postcard>>;
|
|
228
|
+
iterAll(options?: {
|
|
229
|
+
pageSize?: number;
|
|
230
|
+
}): PageIterator<Postcard>;
|
|
231
|
+
get(postcardId: string): Promise<Postcard>;
|
|
232
|
+
create(params?: CreatePostcardParams): Promise<Postcard>;
|
|
233
|
+
update(postcardId: string, params: UpdatePostcardParams): Promise<Postcard>;
|
|
234
|
+
delete(postcardId: string): Promise<void>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
interface MailingPostage {
|
|
238
|
+
postageZoneId: string;
|
|
239
|
+
postageZoneName: string;
|
|
240
|
+
postageZoneSlug: string;
|
|
241
|
+
postageRateId: string;
|
|
242
|
+
postageRateLabel: string;
|
|
243
|
+
postageRateSlug: string;
|
|
244
|
+
recipientCount: number;
|
|
245
|
+
costPerPiece: number;
|
|
246
|
+
subtotal: number;
|
|
247
|
+
}
|
|
248
|
+
interface Mailing {
|
|
249
|
+
id: string;
|
|
250
|
+
name: string;
|
|
251
|
+
type: string;
|
|
252
|
+
productTypeId?: string | null;
|
|
253
|
+
documentId?: string | null;
|
|
254
|
+
postcardId?: string | null;
|
|
255
|
+
contactListId: string;
|
|
256
|
+
couponListId?: string | null;
|
|
257
|
+
status: string;
|
|
258
|
+
recipientCount: number;
|
|
259
|
+
createdAt: string;
|
|
260
|
+
scheduledDate?: string | null;
|
|
261
|
+
printColor: boolean;
|
|
262
|
+
productCostPerPiece: number;
|
|
263
|
+
totalCost: number;
|
|
264
|
+
taxAmount: number;
|
|
265
|
+
taxRate: number;
|
|
266
|
+
paymentStatus: string;
|
|
267
|
+
stripePaymentIntentId?: string | null;
|
|
268
|
+
isTest: boolean;
|
|
269
|
+
postage: MailingPostage[];
|
|
270
|
+
itemCount: number;
|
|
271
|
+
itemsMailed: number;
|
|
272
|
+
itemsDelivered: number;
|
|
273
|
+
itemsReturned: number;
|
|
274
|
+
deliveredAt?: string | null;
|
|
275
|
+
}
|
|
276
|
+
type MailingItemTrackingStatus = "in_transit" | "out_for_delivery" | "forwarded" | "delivered" | "returned";
|
|
277
|
+
interface MailingItemTracking {
|
|
278
|
+
id: string;
|
|
279
|
+
mailingId: string;
|
|
280
|
+
contactId?: string | null;
|
|
281
|
+
recipientName?: string | null;
|
|
282
|
+
recipientCompany?: string | null;
|
|
283
|
+
recipientCity?: string | null;
|
|
284
|
+
recipientState?: string | null;
|
|
285
|
+
recipientZip?: string | null;
|
|
286
|
+
status: "pending" | "printed" | "mailed";
|
|
287
|
+
trackingStatus: MailingItemTrackingStatus | null;
|
|
288
|
+
printedAt?: string | null;
|
|
289
|
+
mailedAt?: string | null;
|
|
290
|
+
firstScanAt?: string | null;
|
|
291
|
+
lastScanAt?: string | null;
|
|
292
|
+
lastScanEventCode?: string | null;
|
|
293
|
+
lastScanLabel?: string | null;
|
|
294
|
+
lastScanLocation?: string | null;
|
|
295
|
+
anticipatedDeliveryDate?: string | null;
|
|
296
|
+
expectedDeliveryDate?: string | null;
|
|
297
|
+
deliveredAt?: string | null;
|
|
298
|
+
returnedAt?: string | null;
|
|
299
|
+
/** True when delivered was inferred from the final USPS sort plus the predicted delivery day. */
|
|
300
|
+
deliveryInferred: boolean;
|
|
301
|
+
deliveryDate: string | null;
|
|
302
|
+
}
|
|
303
|
+
interface MailingItemScan {
|
|
304
|
+
id: string;
|
|
305
|
+
scanDatetime: string;
|
|
306
|
+
scanEventCode: string;
|
|
307
|
+
handlingEventType: "A" | "AA" | "L" | "AL";
|
|
308
|
+
label: string;
|
|
309
|
+
facilityName?: string | null;
|
|
310
|
+
facilityCity?: string | null;
|
|
311
|
+
facilityState?: string | null;
|
|
312
|
+
facilityZip?: string | null;
|
|
313
|
+
mailPhase?: string | null;
|
|
314
|
+
imb: string;
|
|
315
|
+
}
|
|
316
|
+
interface ListMailingItemsOptions {
|
|
317
|
+
page?: number;
|
|
318
|
+
pageSize?: number;
|
|
319
|
+
/** Filter by tracking state; "none" selects pieces not yet scanned. */
|
|
320
|
+
trackingStatus?: MailingItemTrackingStatus | "none";
|
|
321
|
+
}
|
|
322
|
+
interface ZoneRecipientCount {
|
|
323
|
+
postageZoneId: string;
|
|
324
|
+
postageZoneName: string;
|
|
325
|
+
postageZoneSlug: string;
|
|
326
|
+
recipientCount: number;
|
|
327
|
+
}
|
|
328
|
+
interface UnavailableRecipients {
|
|
329
|
+
countryName: string;
|
|
330
|
+
recipientCount: number;
|
|
331
|
+
reason: string;
|
|
332
|
+
}
|
|
333
|
+
interface CostCalculation {
|
|
334
|
+
type: string;
|
|
335
|
+
productTypeCode: string;
|
|
336
|
+
recipientCount: number;
|
|
337
|
+
productCostPerPiece: number;
|
|
338
|
+
totalProductCost: number;
|
|
339
|
+
zoneCounts: ZoneRecipientCount[];
|
|
340
|
+
unavailable: UnavailableRecipients[];
|
|
341
|
+
totalCost?: number | null;
|
|
342
|
+
pageCount?: number | null;
|
|
343
|
+
printColor: boolean;
|
|
344
|
+
basePrice?: number | null;
|
|
345
|
+
perPagePrice?: number | null;
|
|
346
|
+
colorSurchargePerPage?: number | null;
|
|
347
|
+
}
|
|
348
|
+
interface PostageSelection {
|
|
349
|
+
postageZoneSlug: string;
|
|
350
|
+
postageRateSlug: string;
|
|
351
|
+
}
|
|
352
|
+
interface CreateMailingParams {
|
|
353
|
+
name: string;
|
|
354
|
+
type: string;
|
|
355
|
+
contactListId: string;
|
|
356
|
+
documentId?: string;
|
|
357
|
+
postcardId?: string;
|
|
358
|
+
couponListId?: string;
|
|
359
|
+
scheduledDate?: string | Date;
|
|
360
|
+
printColor?: boolean;
|
|
361
|
+
postageSelections?: PostageSelection[];
|
|
362
|
+
}
|
|
363
|
+
interface UpdateMailingParams {
|
|
364
|
+
name?: string;
|
|
365
|
+
scheduledDate?: string | Date;
|
|
366
|
+
}
|
|
367
|
+
interface EstimateCostParams {
|
|
368
|
+
type: string;
|
|
369
|
+
contactListId?: string;
|
|
370
|
+
contactIds?: string[];
|
|
371
|
+
documentId?: string;
|
|
372
|
+
printColor?: boolean;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
declare class MailingsResource {
|
|
376
|
+
private readonly http;
|
|
377
|
+
constructor(http: HttpClient);
|
|
378
|
+
list(options?: {
|
|
379
|
+
page?: number;
|
|
380
|
+
pageSize?: number;
|
|
381
|
+
}): Promise<Page<Mailing>>;
|
|
382
|
+
iterAll(options?: {
|
|
383
|
+
pageSize?: number;
|
|
384
|
+
}): PageIterator<Mailing>;
|
|
385
|
+
get(mailingId: string): Promise<Mailing>;
|
|
386
|
+
create(params: CreateMailingParams): Promise<Mailing>;
|
|
387
|
+
update(mailingId: string, params: UpdateMailingParams): Promise<Mailing>;
|
|
388
|
+
delete(mailingId: string): Promise<void>;
|
|
389
|
+
validateAddresses(mailingId: string): Promise<Record<string, unknown>[]>;
|
|
390
|
+
estimateCost(params: EstimateCostParams): Promise<CostCalculation>;
|
|
391
|
+
calculateCost(mailingId: string): Promise<CostCalculation>;
|
|
392
|
+
send(mailingId: string): Promise<Mailing>;
|
|
393
|
+
listItems(mailingId: string, options?: ListMailingItemsOptions): Promise<Page<MailingItemTracking>>;
|
|
394
|
+
iterItems(mailingId: string, options?: Omit<ListMailingItemsOptions, "page">): PageIterator<MailingItemTracking>;
|
|
395
|
+
listItemScans(mailingId: string, itemId: string): Promise<MailingItemScan[]>;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
interface Campaign {
|
|
399
|
+
id: string;
|
|
400
|
+
name: string;
|
|
401
|
+
mailingIds: string[];
|
|
402
|
+
status: string;
|
|
403
|
+
createdAt: string;
|
|
404
|
+
updatedAt: string;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
declare class CampaignsResource {
|
|
408
|
+
private readonly http;
|
|
409
|
+
constructor(http: HttpClient);
|
|
410
|
+
list(options?: {
|
|
411
|
+
page?: number;
|
|
412
|
+
pageSize?: number;
|
|
413
|
+
}): Promise<Page<Campaign>>;
|
|
414
|
+
iterAll(options?: {
|
|
415
|
+
pageSize?: number;
|
|
416
|
+
}): PageIterator<Campaign>;
|
|
417
|
+
get(campaignId: string): Promise<Campaign>;
|
|
418
|
+
create(name: string, options?: {
|
|
419
|
+
mailingIds?: string[];
|
|
420
|
+
}): Promise<Campaign>;
|
|
421
|
+
update(campaignId: string, params: {
|
|
422
|
+
name?: string;
|
|
423
|
+
status?: string;
|
|
424
|
+
}): Promise<Campaign>;
|
|
425
|
+
delete(campaignId: string): Promise<void>;
|
|
426
|
+
addMailing(campaignId: string, mailingId: string): Promise<Campaign>;
|
|
427
|
+
removeMailing(campaignId: string, mailingId: string): Promise<Campaign>;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
interface DashboardStats {
|
|
431
|
+
totalDocuments: number;
|
|
432
|
+
totalMailings: number;
|
|
433
|
+
lettersSent: number;
|
|
434
|
+
postcardsSent: number;
|
|
435
|
+
totalContacts: number;
|
|
436
|
+
totalSpent: number;
|
|
437
|
+
totalQrScans: number;
|
|
438
|
+
}
|
|
439
|
+
interface StateCount {
|
|
440
|
+
state: string;
|
|
441
|
+
count: number;
|
|
442
|
+
}
|
|
443
|
+
interface ReportingData {
|
|
444
|
+
totalPieces: number;
|
|
445
|
+
totalSpent: number;
|
|
446
|
+
lettersCount: number;
|
|
447
|
+
postcardsCount: number;
|
|
448
|
+
destinationsByState: StateCount[];
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
declare class DashboardResource {
|
|
452
|
+
private readonly http;
|
|
453
|
+
constructor(http: HttpClient);
|
|
454
|
+
stats(): Promise<DashboardStats>;
|
|
455
|
+
reporting(options?: {
|
|
456
|
+
startDate?: string;
|
|
457
|
+
endDate?: string;
|
|
458
|
+
}): Promise<ReportingData>;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
interface PaymentIntent {
|
|
462
|
+
clientSecret: string;
|
|
463
|
+
paymentIntentId: string;
|
|
464
|
+
amount: number;
|
|
465
|
+
subtotal: number;
|
|
466
|
+
taxAmount: number;
|
|
467
|
+
taxRate: number;
|
|
468
|
+
currency: string;
|
|
469
|
+
}
|
|
470
|
+
interface SavedCard {
|
|
471
|
+
id: string;
|
|
472
|
+
brand: string;
|
|
473
|
+
last4: string;
|
|
474
|
+
expMonth: number;
|
|
475
|
+
expYear: number;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
declare class PaymentsResource {
|
|
479
|
+
private readonly http;
|
|
480
|
+
constructor(http: HttpClient);
|
|
481
|
+
createPaymentIntent(mailingId: string, options?: {
|
|
482
|
+
paymentMethodId?: string;
|
|
483
|
+
}): Promise<PaymentIntent>;
|
|
484
|
+
getStripeKey(): Promise<string>;
|
|
485
|
+
listCards(): Promise<SavedCard[]>;
|
|
486
|
+
deleteCard(paymentMethodId: string): Promise<void>;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
interface QrLink {
|
|
490
|
+
id: string;
|
|
491
|
+
slug: string;
|
|
492
|
+
destinationUrl: string;
|
|
493
|
+
postcardId?: string | null;
|
|
494
|
+
mailingId?: string | null;
|
|
495
|
+
recipientId?: string | null;
|
|
496
|
+
qrElementId?: string | null;
|
|
497
|
+
scanCount: number;
|
|
498
|
+
createdAt: string;
|
|
499
|
+
updatedAt: string;
|
|
500
|
+
shortUrl: string;
|
|
501
|
+
}
|
|
502
|
+
interface ScansByDay {
|
|
503
|
+
date: string;
|
|
504
|
+
count: number;
|
|
505
|
+
}
|
|
506
|
+
interface TopLink {
|
|
507
|
+
slug: string;
|
|
508
|
+
destinationUrl: string;
|
|
509
|
+
scanCount: number;
|
|
510
|
+
shortUrl: string;
|
|
511
|
+
}
|
|
512
|
+
interface QrAnalytics {
|
|
513
|
+
totalScans: number;
|
|
514
|
+
uniqueLinks: number;
|
|
515
|
+
scansByDay: ScansByDay[];
|
|
516
|
+
topLinks: TopLink[];
|
|
517
|
+
recentScans: Record<string, unknown>[];
|
|
518
|
+
}
|
|
519
|
+
interface CreateQrLinkParams {
|
|
520
|
+
destinationUrl: string;
|
|
521
|
+
postcardId?: string;
|
|
522
|
+
mailingId?: string;
|
|
523
|
+
recipientId?: string;
|
|
524
|
+
qrElementId?: string;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
declare class QrResource {
|
|
528
|
+
private readonly http;
|
|
529
|
+
constructor(http: HttpClient);
|
|
530
|
+
list(options?: {
|
|
531
|
+
page?: number;
|
|
532
|
+
pageSize?: number;
|
|
533
|
+
}): Promise<Page<QrLink>>;
|
|
534
|
+
iterAll(options?: {
|
|
535
|
+
pageSize?: number;
|
|
536
|
+
}): PageIterator<QrLink>;
|
|
537
|
+
create(params: CreateQrLinkParams): Promise<QrLink>;
|
|
538
|
+
delete(linkId: string): Promise<void>;
|
|
539
|
+
analytics(options?: {
|
|
540
|
+
days?: number;
|
|
541
|
+
}): Promise<QrAnalytics>;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
interface MergeTag {
|
|
545
|
+
key: string;
|
|
546
|
+
label: string;
|
|
547
|
+
category: string;
|
|
548
|
+
sampleValue: string;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
declare class MergeTagsResource {
|
|
552
|
+
private readonly http;
|
|
553
|
+
constructor(http: HttpClient);
|
|
554
|
+
list(): Promise<MergeTag[]>;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
declare class PricingResource {
|
|
558
|
+
private readonly http;
|
|
559
|
+
constructor(http: HttpClient);
|
|
560
|
+
catalog(): Promise<Record<string, unknown>[]>;
|
|
561
|
+
countries(): Promise<Record<string, unknown>[]>;
|
|
562
|
+
postageZones(): Promise<Record<string, unknown>[]>;
|
|
563
|
+
postageRates(options?: {
|
|
564
|
+
productType?: string;
|
|
565
|
+
zone?: string;
|
|
566
|
+
}): Promise<Record<string, unknown>[]>;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
interface CouponList {
|
|
570
|
+
id: string;
|
|
571
|
+
name: string;
|
|
572
|
+
description?: string | null;
|
|
573
|
+
totalCodes: number;
|
|
574
|
+
usedCodes: number;
|
|
575
|
+
availableCodes: number;
|
|
576
|
+
createdAt: string;
|
|
577
|
+
updatedAt: string;
|
|
578
|
+
}
|
|
579
|
+
interface CouponCode {
|
|
580
|
+
id: string;
|
|
581
|
+
code: string;
|
|
582
|
+
used: boolean;
|
|
583
|
+
usedAt?: string | null;
|
|
584
|
+
assignedToContactId?: string | null;
|
|
585
|
+
mailingId?: string | null;
|
|
586
|
+
createdAt: string;
|
|
587
|
+
}
|
|
588
|
+
interface CouponImportResult {
|
|
589
|
+
importedCount: number;
|
|
590
|
+
duplicateCount: number;
|
|
591
|
+
}
|
|
592
|
+
interface CouponAvailability {
|
|
593
|
+
couponListId: string;
|
|
594
|
+
totalCodes: number;
|
|
595
|
+
usedCodes: number;
|
|
596
|
+
availableCodes: number;
|
|
597
|
+
sufficient: boolean;
|
|
598
|
+
requestedCount: number;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
declare class CouponsResource {
|
|
602
|
+
private readonly http;
|
|
603
|
+
constructor(http: HttpClient);
|
|
604
|
+
list(): Promise<CouponList[]>;
|
|
605
|
+
get(listId: string): Promise<CouponList>;
|
|
606
|
+
create(name: string, options?: {
|
|
607
|
+
description?: string;
|
|
608
|
+
}): Promise<CouponList>;
|
|
609
|
+
update(listId: string, params: {
|
|
610
|
+
name?: string;
|
|
611
|
+
description?: string;
|
|
612
|
+
}): Promise<CouponList>;
|
|
613
|
+
delete(listId: string): Promise<void>;
|
|
614
|
+
listCodes(listId: string, options?: {
|
|
615
|
+
page?: number;
|
|
616
|
+
pageSize?: number;
|
|
617
|
+
used?: boolean;
|
|
618
|
+
}): Promise<Page<CouponCode>>;
|
|
619
|
+
importCodes(listId: string, codes: string[]): Promise<CouponImportResult>;
|
|
620
|
+
deleteCode(listId: string, codeId: string): Promise<void>;
|
|
621
|
+
checkAvailability(listId: string, count: number): Promise<CouponAvailability>;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
interface Asset {
|
|
625
|
+
id: string;
|
|
626
|
+
filename: string;
|
|
627
|
+
originalFilename: string;
|
|
628
|
+
url: string;
|
|
629
|
+
mimeType: string;
|
|
630
|
+
fileSize: number;
|
|
631
|
+
createdAt: string;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
declare class AssetsResource {
|
|
635
|
+
private readonly http;
|
|
636
|
+
constructor(http: HttpClient);
|
|
637
|
+
list(options?: {
|
|
638
|
+
page?: number;
|
|
639
|
+
pageSize?: number;
|
|
640
|
+
}): Promise<Page<Asset>>;
|
|
641
|
+
iterAll(options?: {
|
|
642
|
+
pageSize?: number;
|
|
643
|
+
}): PageIterator<Asset>;
|
|
644
|
+
upload(file: Blob | ArrayBuffer | Uint8Array<ArrayBuffer>, filename: string, mimeType?: string): Promise<Asset>;
|
|
645
|
+
delete(assetId: string): Promise<void>;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
interface MailerBotOptions {
|
|
649
|
+
/** Base URL for the API. Defaults to `https://api.mailerbot.com/api/v1`. */
|
|
650
|
+
baseUrl?: string;
|
|
651
|
+
/** Request timeout in milliseconds. Defaults to 30000. */
|
|
652
|
+
timeout?: number;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* MailerBot API client.
|
|
656
|
+
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```ts
|
|
659
|
+
* import { MailerBot } from "mailerbot";
|
|
660
|
+
*
|
|
661
|
+
* const client = new MailerBot("mb_live_...");
|
|
662
|
+
* const page = await client.contacts.list();
|
|
663
|
+
* console.log(page.total, "contacts");
|
|
664
|
+
* ```
|
|
665
|
+
*/
|
|
666
|
+
declare class MailerBot {
|
|
667
|
+
readonly contacts: ContactsResource;
|
|
668
|
+
readonly contactLists: ContactListsResource;
|
|
669
|
+
readonly documents: DocumentsResource;
|
|
670
|
+
readonly postcards: PostcardsResource;
|
|
671
|
+
readonly mailings: MailingsResource;
|
|
672
|
+
readonly campaigns: CampaignsResource;
|
|
673
|
+
readonly dashboard: DashboardResource;
|
|
674
|
+
readonly payments: PaymentsResource;
|
|
675
|
+
readonly qr: QrResource;
|
|
676
|
+
readonly mergeTags: MergeTagsResource;
|
|
677
|
+
readonly pricing: PricingResource;
|
|
678
|
+
readonly coupons: CouponsResource;
|
|
679
|
+
readonly assets: AssetsResource;
|
|
680
|
+
constructor(apiKey: string, options?: MailerBotOptions);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Base error class for all MailerBot SDK errors.
|
|
685
|
+
*/
|
|
686
|
+
declare class MailerBotError extends Error {
|
|
687
|
+
readonly statusCode: number | undefined;
|
|
688
|
+
readonly response: Record<string, unknown> | undefined;
|
|
689
|
+
constructor(message: string, options?: {
|
|
690
|
+
statusCode?: number;
|
|
691
|
+
response?: Record<string, unknown>;
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
/** Raised when the API key is missing or invalid (401). */
|
|
695
|
+
declare class AuthenticationError extends MailerBotError {
|
|
696
|
+
constructor(message: string, options?: {
|
|
697
|
+
statusCode?: number;
|
|
698
|
+
response?: Record<string, unknown>;
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
/** Raised when the API key lacks permission for the requested resource (403). */
|
|
702
|
+
declare class PermissionError extends MailerBotError {
|
|
703
|
+
constructor(message: string, options?: {
|
|
704
|
+
statusCode?: number;
|
|
705
|
+
response?: Record<string, unknown>;
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
/** Raised when the requested resource does not exist (404). */
|
|
709
|
+
declare class NotFoundError extends MailerBotError {
|
|
710
|
+
constructor(message: string, options?: {
|
|
711
|
+
statusCode?: number;
|
|
712
|
+
response?: Record<string, unknown>;
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
/** Raised when the request body fails validation (422). */
|
|
716
|
+
declare class ValidationError extends MailerBotError {
|
|
717
|
+
constructor(message: string, options?: {
|
|
718
|
+
statusCode?: number;
|
|
719
|
+
response?: Record<string, unknown>;
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
/** Raised when the rate limit is exceeded (429). */
|
|
723
|
+
declare class RateLimitError extends MailerBotError {
|
|
724
|
+
constructor(message: string, options?: {
|
|
725
|
+
statusCode?: number;
|
|
726
|
+
response?: Record<string, unknown>;
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
/** Raised for unexpected server-side errors (5xx). */
|
|
730
|
+
declare class ServerError extends MailerBotError {
|
|
731
|
+
constructor(message: string, options?: {
|
|
732
|
+
statusCode?: number;
|
|
733
|
+
response?: Record<string, unknown>;
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
export { type AddressValidation, type Asset, AuthenticationError, type Campaign, type Contact, type ContactList, type CostCalculation, type CouponAvailability, type CouponCode, type CouponImportResult, type CouponList, type CreateContactParams, type CreateDocumentParams, type CreateMailingParams, type CreatePostcardParams, type CreateQrLinkParams, type CsvImportResult, type DashboardStats, type Document, type ListMailingItemsOptions, MailerBot, MailerBotError, type MailerBotOptions, type Mailing, type MailingItemScan, type MailingItemTracking, type MailingItemTrackingStatus, type MergeTag, NotFoundError, type Page, PageIterator, type PaymentIntent, PermissionError, type Postcard, type PostcardSide, type PostcardTemplate, type QrAnalytics, type QrLink, RateLimitError, type ReportingData, type SavedCard, type ScansByDay, ServerError, type StateCount, type TopLink, type UpdateContactParams, type UpdateDocumentParams, type UpdateMailingParams, type UpdatePostcardParams, ValidationError };
|