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/dist/index.cjs ADDED
@@ -0,0 +1,852 @@
1
+ 'use strict';
2
+
3
+ // src/errors.ts
4
+ var MailerBotError = class extends Error {
5
+ statusCode;
6
+ response;
7
+ constructor(message, options) {
8
+ super(message);
9
+ this.name = "MailerBotError";
10
+ this.statusCode = options?.statusCode;
11
+ this.response = options?.response;
12
+ }
13
+ };
14
+ var AuthenticationError = class extends MailerBotError {
15
+ constructor(message, options) {
16
+ super(message, options);
17
+ this.name = "AuthenticationError";
18
+ }
19
+ };
20
+ var PermissionError = class extends MailerBotError {
21
+ constructor(message, options) {
22
+ super(message, options);
23
+ this.name = "PermissionError";
24
+ }
25
+ };
26
+ var NotFoundError = class extends MailerBotError {
27
+ constructor(message, options) {
28
+ super(message, options);
29
+ this.name = "NotFoundError";
30
+ }
31
+ };
32
+ var ValidationError = class extends MailerBotError {
33
+ constructor(message, options) {
34
+ super(message, options);
35
+ this.name = "ValidationError";
36
+ }
37
+ };
38
+ var RateLimitError = class extends MailerBotError {
39
+ constructor(message, options) {
40
+ super(message, options);
41
+ this.name = "RateLimitError";
42
+ }
43
+ };
44
+ var ServerError = class extends MailerBotError {
45
+ constructor(message, options) {
46
+ super(message, options);
47
+ this.name = "ServerError";
48
+ }
49
+ };
50
+
51
+ // src/http.ts
52
+ var DEFAULT_BASE_URL = "https://api.mailerbot.com/api/v1";
53
+ var DEFAULT_TIMEOUT = 3e4;
54
+ function buildHeaders(apiKey) {
55
+ return {
56
+ "X-API-Key": apiKey,
57
+ "Content-Type": "application/json",
58
+ Accept: "application/json"
59
+ };
60
+ }
61
+ async function raiseForStatus(response) {
62
+ if (response.ok) return;
63
+ let body;
64
+ try {
65
+ body = await response.json();
66
+ } catch {
67
+ body = { detail: await response.text().catch(() => "Unknown error") };
68
+ }
69
+ const detail = typeof body.detail === "string" ? body.detail : JSON.stringify(body);
70
+ const status = response.status;
71
+ const opts = { statusCode: status, response: body };
72
+ if (status === 401) throw new AuthenticationError(detail, opts);
73
+ if (status === 403) throw new PermissionError(detail, opts);
74
+ if (status === 404) throw new NotFoundError(detail, opts);
75
+ if (status === 422) throw new ValidationError(detail, opts);
76
+ if (status === 429) throw new RateLimitError(detail, opts);
77
+ if (status >= 500) throw new ServerError(detail, opts);
78
+ throw new MailerBotError(detail, opts);
79
+ }
80
+ var HttpClient = class {
81
+ baseUrl;
82
+ headers;
83
+ timeout;
84
+ constructor(baseUrl, headers, timeout) {
85
+ this.baseUrl = baseUrl;
86
+ this.headers = headers;
87
+ this.timeout = timeout;
88
+ }
89
+ async request(options) {
90
+ const fullUrl = `${this.baseUrl}${options.path.startsWith("/") ? "" : "/"}${options.path}`;
91
+ const urlObj = new URL(fullUrl);
92
+ if (options.params) {
93
+ for (const [key, value] of Object.entries(options.params)) {
94
+ if (value !== void 0) {
95
+ urlObj.searchParams.set(key, String(value));
96
+ }
97
+ }
98
+ }
99
+ const mergedHeaders = { ...this.headers, ...options.headers };
100
+ const controller = new AbortController();
101
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
102
+ try {
103
+ const response = await fetch(urlObj.toString(), {
104
+ method: options.method ?? "GET",
105
+ headers: mergedHeaders,
106
+ body: options.body !== void 0 ? JSON.stringify(options.body) : void 0,
107
+ signal: controller.signal
108
+ });
109
+ await raiseForStatus(response);
110
+ const text = await response.text();
111
+ if (!text) return void 0;
112
+ return JSON.parse(text);
113
+ } finally {
114
+ clearTimeout(timeoutId);
115
+ }
116
+ }
117
+ async requestRaw(options) {
118
+ const fullUrl = `${this.baseUrl}${options.path.startsWith("/") ? "" : "/"}${options.path}`;
119
+ const urlObj = new URL(fullUrl);
120
+ if (options.params) {
121
+ for (const [key, value] of Object.entries(options.params)) {
122
+ if (value !== void 0) {
123
+ urlObj.searchParams.set(key, String(value));
124
+ }
125
+ }
126
+ }
127
+ const controller = new AbortController();
128
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
129
+ try {
130
+ const response = await fetch(urlObj.toString(), {
131
+ method: options.method ?? "POST",
132
+ headers: options.rawHeaders ?? this.headers,
133
+ body: options.rawBody,
134
+ signal: controller.signal
135
+ });
136
+ await raiseForStatus(response);
137
+ return response;
138
+ } finally {
139
+ clearTimeout(timeoutId);
140
+ }
141
+ }
142
+ };
143
+
144
+ // src/pagination.ts
145
+ var PageIterator = class {
146
+ fetch;
147
+ pageSize;
148
+ constructor(fetch2, pageSize = 100) {
149
+ this.fetch = fetch2;
150
+ this.pageSize = pageSize;
151
+ }
152
+ async *[Symbol.asyncIterator]() {
153
+ let page = 1;
154
+ while (true) {
155
+ const result = await this.fetch(page, this.pageSize);
156
+ for (const item of result.items) {
157
+ yield item;
158
+ }
159
+ if (page >= result.pages) break;
160
+ page++;
161
+ }
162
+ }
163
+ };
164
+
165
+ // src/resources/contacts.ts
166
+ var ContactsResource = class {
167
+ constructor(http) {
168
+ this.http = http;
169
+ }
170
+ async list(options) {
171
+ return this.http.request({
172
+ path: "/contacts",
173
+ params: {
174
+ page: options?.page ?? 1,
175
+ page_size: options?.pageSize ?? 50,
176
+ search: options?.search
177
+ }
178
+ });
179
+ }
180
+ iterAll(options) {
181
+ return new PageIterator(
182
+ (page, pageSize) => this.list({ page, pageSize, search: options?.search }),
183
+ options?.pageSize ?? 100
184
+ );
185
+ }
186
+ async get(contactId) {
187
+ return this.http.request({ path: `/contacts/${contactId}` });
188
+ }
189
+ async create(params) {
190
+ return this.http.request({
191
+ method: "POST",
192
+ path: "/contacts",
193
+ body: params
194
+ });
195
+ }
196
+ async update(contactId, params) {
197
+ return this.http.request({
198
+ method: "PUT",
199
+ path: `/contacts/${contactId}`,
200
+ body: params
201
+ });
202
+ }
203
+ async delete(contactId) {
204
+ await this.http.request({
205
+ method: "DELETE",
206
+ path: `/contacts/${contactId}`
207
+ });
208
+ }
209
+ async importCsv(contacts, options) {
210
+ return this.http.request({
211
+ method: "POST",
212
+ path: "/contacts/import",
213
+ body: { contacts, listName: options?.listName }
214
+ });
215
+ }
216
+ async validateAddresses(contactIds) {
217
+ return this.http.request({
218
+ method: "POST",
219
+ path: "/contacts/validate",
220
+ body: { contactIds }
221
+ });
222
+ }
223
+ };
224
+
225
+ // src/resources/contact-lists.ts
226
+ var ContactListsResource = class {
227
+ constructor(http) {
228
+ this.http = http;
229
+ }
230
+ async list() {
231
+ return this.http.request({ path: "/contact-lists" });
232
+ }
233
+ async get(listId) {
234
+ return this.http.request({
235
+ path: `/contact-lists/${listId}`
236
+ });
237
+ }
238
+ async create(name, options) {
239
+ return this.http.request({
240
+ method: "POST",
241
+ path: "/contact-lists",
242
+ body: { name, contactIds: options?.contactIds ?? [] }
243
+ });
244
+ }
245
+ async update(listId, name) {
246
+ return this.http.request({
247
+ method: "PUT",
248
+ path: `/contact-lists/${listId}`,
249
+ body: { name }
250
+ });
251
+ }
252
+ async delete(listId) {
253
+ await this.http.request({
254
+ method: "DELETE",
255
+ path: `/contact-lists/${listId}`
256
+ });
257
+ }
258
+ async addContacts(listId, contactIds) {
259
+ await this.http.request({
260
+ method: "POST",
261
+ path: `/contact-lists/${listId}/contacts`,
262
+ body: { contactIds }
263
+ });
264
+ }
265
+ async removeContacts(listId, contactIds) {
266
+ await this.http.request({
267
+ method: "DELETE",
268
+ path: `/contact-lists/${listId}/contacts`,
269
+ body: { contactIds }
270
+ });
271
+ }
272
+ };
273
+
274
+ // src/resources/documents.ts
275
+ var DocumentsResource = class {
276
+ constructor(http) {
277
+ this.http = http;
278
+ }
279
+ async list(options) {
280
+ return this.http.request({
281
+ path: "/documents",
282
+ params: {
283
+ page: options?.page ?? 1,
284
+ page_size: options?.pageSize ?? 50,
285
+ type: options?.type
286
+ }
287
+ });
288
+ }
289
+ iterAll(options) {
290
+ return new PageIterator(
291
+ (page, pageSize) => this.list({ page, pageSize }),
292
+ options?.pageSize ?? 100
293
+ );
294
+ }
295
+ async get(documentId) {
296
+ return this.http.request({ path: `/documents/${documentId}` });
297
+ }
298
+ async create(params) {
299
+ return this.http.request({
300
+ method: "POST",
301
+ path: "/documents",
302
+ body: {
303
+ title: params?.title ?? "Untitled Document",
304
+ content: params?.content ?? ""
305
+ }
306
+ });
307
+ }
308
+ async update(documentId, params) {
309
+ return this.http.request({
310
+ method: "PUT",
311
+ path: `/documents/${documentId}`,
312
+ body: params
313
+ });
314
+ }
315
+ async delete(documentId) {
316
+ await this.http.request({
317
+ method: "DELETE",
318
+ path: `/documents/${documentId}`
319
+ });
320
+ }
321
+ async upload(file, filename) {
322
+ const formData = new FormData();
323
+ const blob = file instanceof Blob ? file : new Blob([file], { type: "application/pdf" });
324
+ formData.append("file", blob, filename);
325
+ const response = await this.http.requestRaw({
326
+ method: "POST",
327
+ path: "/documents/upload",
328
+ rawBody: formData,
329
+ rawHeaders: {}
330
+ // let fetch set Content-Type with boundary
331
+ });
332
+ return await response.json();
333
+ }
334
+ };
335
+
336
+ // src/resources/postcards.ts
337
+ var PostcardsResource = class {
338
+ constructor(http) {
339
+ this.http = http;
340
+ }
341
+ async listTemplates() {
342
+ return this.http.request({
343
+ path: "/postcards/templates"
344
+ });
345
+ }
346
+ async getTemplate(templateId) {
347
+ return this.http.request({
348
+ path: `/postcards/templates/${templateId}`
349
+ });
350
+ }
351
+ async list(options) {
352
+ return this.http.request({
353
+ path: "/postcards",
354
+ params: {
355
+ page: options?.page ?? 1,
356
+ page_size: options?.pageSize ?? 50
357
+ }
358
+ });
359
+ }
360
+ iterAll(options) {
361
+ return new PageIterator(
362
+ (page, pageSize) => this.list({ page, pageSize }),
363
+ options?.pageSize ?? 100
364
+ );
365
+ }
366
+ async get(postcardId) {
367
+ return this.http.request({ path: `/postcards/${postcardId}` });
368
+ }
369
+ async create(params) {
370
+ return this.http.request({
371
+ method: "POST",
372
+ path: "/postcards",
373
+ body: {
374
+ title: params?.title ?? "Untitled Postcard",
375
+ front: params?.front,
376
+ back: params?.back
377
+ }
378
+ });
379
+ }
380
+ async update(postcardId, params) {
381
+ return this.http.request({
382
+ method: "PUT",
383
+ path: `/postcards/${postcardId}`,
384
+ body: params
385
+ });
386
+ }
387
+ async delete(postcardId) {
388
+ await this.http.request({
389
+ method: "DELETE",
390
+ path: `/postcards/${postcardId}`
391
+ });
392
+ }
393
+ };
394
+
395
+ // src/resources/mailings.ts
396
+ function toISOString(date) {
397
+ if (date === void 0) return void 0;
398
+ return date instanceof Date ? date.toISOString() : date;
399
+ }
400
+ var MailingsResource = class {
401
+ constructor(http) {
402
+ this.http = http;
403
+ }
404
+ async list(options) {
405
+ return this.http.request({
406
+ path: "/mailings",
407
+ params: {
408
+ page: options?.page ?? 1,
409
+ page_size: options?.pageSize ?? 50
410
+ }
411
+ });
412
+ }
413
+ iterAll(options) {
414
+ return new PageIterator(
415
+ (page, pageSize) => this.list({ page, pageSize }),
416
+ options?.pageSize ?? 100
417
+ );
418
+ }
419
+ async get(mailingId) {
420
+ return this.http.request({ path: `/mailings/${mailingId}` });
421
+ }
422
+ async create(params) {
423
+ return this.http.request({
424
+ method: "POST",
425
+ path: "/mailings",
426
+ body: {
427
+ name: params.name,
428
+ type: params.type,
429
+ contactListId: params.contactListId,
430
+ documentId: params.documentId,
431
+ postcardId: params.postcardId,
432
+ couponListId: params.couponListId,
433
+ scheduledDate: toISOString(params.scheduledDate),
434
+ printColor: params.printColor ?? false,
435
+ postageSelections: params.postageSelections
436
+ }
437
+ });
438
+ }
439
+ async update(mailingId, params) {
440
+ return this.http.request({
441
+ method: "PUT",
442
+ path: `/mailings/${mailingId}`,
443
+ body: {
444
+ name: params.name,
445
+ scheduledDate: toISOString(params.scheduledDate)
446
+ }
447
+ });
448
+ }
449
+ async delete(mailingId) {
450
+ await this.http.request({
451
+ method: "DELETE",
452
+ path: `/mailings/${mailingId}`
453
+ });
454
+ }
455
+ async validateAddresses(mailingId) {
456
+ return this.http.request({
457
+ method: "POST",
458
+ path: `/mailings/${mailingId}/validate-addresses`
459
+ });
460
+ }
461
+ async estimateCost(params) {
462
+ return this.http.request({
463
+ method: "POST",
464
+ path: "/mailings/estimate-cost",
465
+ body: {
466
+ type: params.type,
467
+ contactListId: params.contactListId,
468
+ contactIds: params.contactIds,
469
+ documentId: params.documentId,
470
+ printColor: params.printColor ?? false
471
+ }
472
+ });
473
+ }
474
+ async calculateCost(mailingId) {
475
+ return this.http.request({
476
+ method: "POST",
477
+ path: `/mailings/${mailingId}/calculate-cost`
478
+ });
479
+ }
480
+ async send(mailingId) {
481
+ return this.http.request({
482
+ method: "POST",
483
+ path: `/mailings/${mailingId}/send`
484
+ });
485
+ }
486
+ async listItems(mailingId, options) {
487
+ return this.http.request({
488
+ path: `/mailings/${mailingId}/items`,
489
+ params: {
490
+ page: options?.page ?? 1,
491
+ page_size: options?.pageSize ?? 50,
492
+ trackingStatus: options?.trackingStatus
493
+ }
494
+ });
495
+ }
496
+ iterItems(mailingId, options) {
497
+ return new PageIterator(
498
+ (page, pageSize) => this.listItems(mailingId, {
499
+ page,
500
+ pageSize,
501
+ trackingStatus: options?.trackingStatus
502
+ }),
503
+ options?.pageSize ?? 100
504
+ );
505
+ }
506
+ async listItemScans(mailingId, itemId) {
507
+ return this.http.request({
508
+ path: `/mailings/${mailingId}/items/${itemId}/scans`
509
+ });
510
+ }
511
+ };
512
+
513
+ // src/resources/campaigns.ts
514
+ var CampaignsResource = class {
515
+ constructor(http) {
516
+ this.http = http;
517
+ }
518
+ async list(options) {
519
+ return this.http.request({
520
+ path: "/campaigns",
521
+ params: {
522
+ page: options?.page ?? 1,
523
+ page_size: options?.pageSize ?? 50
524
+ }
525
+ });
526
+ }
527
+ iterAll(options) {
528
+ return new PageIterator(
529
+ (page, pageSize) => this.list({ page, pageSize }),
530
+ options?.pageSize ?? 100
531
+ );
532
+ }
533
+ async get(campaignId) {
534
+ return this.http.request({ path: `/campaigns/${campaignId}` });
535
+ }
536
+ async create(name, options) {
537
+ return this.http.request({
538
+ method: "POST",
539
+ path: "/campaigns",
540
+ body: { name, mailingIds: options?.mailingIds ?? [] }
541
+ });
542
+ }
543
+ async update(campaignId, params) {
544
+ return this.http.request({
545
+ method: "PUT",
546
+ path: `/campaigns/${campaignId}`,
547
+ body: params
548
+ });
549
+ }
550
+ async delete(campaignId) {
551
+ await this.http.request({
552
+ method: "DELETE",
553
+ path: `/campaigns/${campaignId}`
554
+ });
555
+ }
556
+ async addMailing(campaignId, mailingId) {
557
+ return this.http.request({
558
+ method: "POST",
559
+ path: `/campaigns/${campaignId}/mailings`,
560
+ body: { mailing_id: mailingId }
561
+ });
562
+ }
563
+ async removeMailing(campaignId, mailingId) {
564
+ return this.http.request({
565
+ method: "DELETE",
566
+ path: `/campaigns/${campaignId}/mailings/${mailingId}`
567
+ });
568
+ }
569
+ };
570
+
571
+ // src/resources/dashboard.ts
572
+ var DashboardResource = class {
573
+ constructor(http) {
574
+ this.http = http;
575
+ }
576
+ async stats() {
577
+ return this.http.request({ path: "/dashboard/stats" });
578
+ }
579
+ async reporting(options) {
580
+ return this.http.request({
581
+ path: "/dashboard/reporting",
582
+ params: {
583
+ start_date: options?.startDate,
584
+ end_date: options?.endDate
585
+ }
586
+ });
587
+ }
588
+ };
589
+
590
+ // src/resources/payments.ts
591
+ var PaymentsResource = class {
592
+ constructor(http) {
593
+ this.http = http;
594
+ }
595
+ async createPaymentIntent(mailingId, options) {
596
+ const body = { mailingId };
597
+ if (options?.paymentMethodId) {
598
+ body.paymentMethodId = options.paymentMethodId;
599
+ }
600
+ return this.http.request({
601
+ method: "POST",
602
+ path: "/payments/create-payment-intent",
603
+ body
604
+ });
605
+ }
606
+ async getStripeKey() {
607
+ const data = await this.http.request({
608
+ path: "/payments/config"
609
+ });
610
+ return data.publishable_key;
611
+ }
612
+ async listCards() {
613
+ return this.http.request({ path: "/payments/cards" });
614
+ }
615
+ async deleteCard(paymentMethodId) {
616
+ await this.http.request({
617
+ method: "DELETE",
618
+ path: `/payments/cards/${paymentMethodId}`
619
+ });
620
+ }
621
+ };
622
+
623
+ // src/resources/qr.ts
624
+ var QrResource = class {
625
+ constructor(http) {
626
+ this.http = http;
627
+ }
628
+ async list(options) {
629
+ return this.http.request({
630
+ path: "/qr/links",
631
+ params: {
632
+ page: options?.page ?? 1,
633
+ page_size: options?.pageSize ?? 50
634
+ }
635
+ });
636
+ }
637
+ iterAll(options) {
638
+ return new PageIterator(
639
+ (page, pageSize) => this.list({ page, pageSize }),
640
+ options?.pageSize ?? 100
641
+ );
642
+ }
643
+ async create(params) {
644
+ return this.http.request({
645
+ method: "POST",
646
+ path: "/qr/links",
647
+ body: params
648
+ });
649
+ }
650
+ async delete(linkId) {
651
+ await this.http.request({
652
+ method: "DELETE",
653
+ path: `/qr/links/${linkId}`
654
+ });
655
+ }
656
+ async analytics(options) {
657
+ return this.http.request({
658
+ path: "/qr/analytics",
659
+ params: { days: options?.days ?? 30 }
660
+ });
661
+ }
662
+ };
663
+
664
+ // src/resources/merge-tags.ts
665
+ var MergeTagsResource = class {
666
+ constructor(http) {
667
+ this.http = http;
668
+ }
669
+ async list() {
670
+ return this.http.request({ path: "/merge-tags" });
671
+ }
672
+ };
673
+
674
+ // src/resources/pricing.ts
675
+ var PricingResource = class {
676
+ constructor(http) {
677
+ this.http = http;
678
+ }
679
+ async catalog() {
680
+ return this.http.request({ path: "/pricing" });
681
+ }
682
+ async countries() {
683
+ return this.http.request({
684
+ path: "/pricing/countries"
685
+ });
686
+ }
687
+ async postageZones() {
688
+ return this.http.request({
689
+ path: "/pricing/postage-zones"
690
+ });
691
+ }
692
+ async postageRates(options) {
693
+ return this.http.request({
694
+ path: "/pricing/postage-rates",
695
+ params: {
696
+ product_type: options?.productType,
697
+ zone: options?.zone
698
+ }
699
+ });
700
+ }
701
+ };
702
+
703
+ // src/resources/coupons.ts
704
+ var CouponsResource = class {
705
+ constructor(http) {
706
+ this.http = http;
707
+ }
708
+ async list() {
709
+ return this.http.request({ path: "/coupons" });
710
+ }
711
+ async get(listId) {
712
+ return this.http.request({ path: `/coupons/${listId}` });
713
+ }
714
+ async create(name, options) {
715
+ return this.http.request({
716
+ method: "POST",
717
+ path: "/coupons",
718
+ body: { name, description: options?.description }
719
+ });
720
+ }
721
+ async update(listId, params) {
722
+ return this.http.request({
723
+ method: "PUT",
724
+ path: `/coupons/${listId}`,
725
+ body: params
726
+ });
727
+ }
728
+ async delete(listId) {
729
+ await this.http.request({
730
+ method: "DELETE",
731
+ path: `/coupons/${listId}`
732
+ });
733
+ }
734
+ async listCodes(listId, options) {
735
+ return this.http.request({
736
+ path: `/coupons/${listId}/codes`,
737
+ params: {
738
+ page: options?.page ?? 1,
739
+ page_size: options?.pageSize ?? 50,
740
+ used: options?.used
741
+ }
742
+ });
743
+ }
744
+ async importCodes(listId, codes) {
745
+ return this.http.request({
746
+ method: "POST",
747
+ path: `/coupons/${listId}/codes/import`,
748
+ body: { codes }
749
+ });
750
+ }
751
+ async deleteCode(listId, codeId) {
752
+ await this.http.request({
753
+ method: "DELETE",
754
+ path: `/coupons/${listId}/codes/${codeId}`
755
+ });
756
+ }
757
+ async checkAvailability(listId, count) {
758
+ return this.http.request({
759
+ path: `/coupons/${listId}/availability`,
760
+ params: { count }
761
+ });
762
+ }
763
+ };
764
+
765
+ // src/resources/assets.ts
766
+ var AssetsResource = class {
767
+ constructor(http) {
768
+ this.http = http;
769
+ }
770
+ async list(options) {
771
+ return this.http.request({
772
+ path: "/assets",
773
+ params: {
774
+ page: options?.page ?? 1,
775
+ page_size: options?.pageSize ?? 50
776
+ }
777
+ });
778
+ }
779
+ iterAll(options) {
780
+ return new PageIterator(
781
+ (page, pageSize) => this.list({ page, pageSize }),
782
+ options?.pageSize ?? 100
783
+ );
784
+ }
785
+ async upload(file, filename, mimeType) {
786
+ const formData = new FormData();
787
+ const blob = file instanceof Blob ? file : new Blob([file], { type: mimeType ?? "application/octet-stream" });
788
+ formData.append("file", blob, filename);
789
+ const response = await this.http.requestRaw({
790
+ method: "POST",
791
+ path: "/assets",
792
+ rawBody: formData,
793
+ rawHeaders: {}
794
+ // let fetch set Content-Type with boundary
795
+ });
796
+ return await response.json();
797
+ }
798
+ async delete(assetId) {
799
+ await this.http.request({
800
+ method: "DELETE",
801
+ path: `/assets/${assetId}`
802
+ });
803
+ }
804
+ };
805
+
806
+ // src/client.ts
807
+ var MailerBot = class {
808
+ contacts;
809
+ contactLists;
810
+ documents;
811
+ postcards;
812
+ mailings;
813
+ campaigns;
814
+ dashboard;
815
+ payments;
816
+ qr;
817
+ mergeTags;
818
+ pricing;
819
+ coupons;
820
+ assets;
821
+ constructor(apiKey, options) {
822
+ const baseUrl = (options?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
823
+ const timeout = options?.timeout ?? DEFAULT_TIMEOUT;
824
+ const headers = buildHeaders(apiKey);
825
+ const http = new HttpClient(baseUrl, headers, timeout);
826
+ this.contacts = new ContactsResource(http);
827
+ this.contactLists = new ContactListsResource(http);
828
+ this.documents = new DocumentsResource(http);
829
+ this.postcards = new PostcardsResource(http);
830
+ this.mailings = new MailingsResource(http);
831
+ this.campaigns = new CampaignsResource(http);
832
+ this.dashboard = new DashboardResource(http);
833
+ this.payments = new PaymentsResource(http);
834
+ this.qr = new QrResource(http);
835
+ this.mergeTags = new MergeTagsResource(http);
836
+ this.pricing = new PricingResource(http);
837
+ this.coupons = new CouponsResource(http);
838
+ this.assets = new AssetsResource(http);
839
+ }
840
+ };
841
+
842
+ exports.AuthenticationError = AuthenticationError;
843
+ exports.MailerBot = MailerBot;
844
+ exports.MailerBotError = MailerBotError;
845
+ exports.NotFoundError = NotFoundError;
846
+ exports.PageIterator = PageIterator;
847
+ exports.PermissionError = PermissionError;
848
+ exports.RateLimitError = RateLimitError;
849
+ exports.ServerError = ServerError;
850
+ exports.ValidationError = ValidationError;
851
+ //# sourceMappingURL=index.cjs.map
852
+ //# sourceMappingURL=index.cjs.map