carlyemail 0.2.0 → 0.3.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.
Files changed (5) hide show
  1. package/README.md +49 -5
  2. package/carlyemail.js +107 -11
  3. package/package.json +9 -3
  4. package/sdk.d.ts +777 -0
  5. package/sdk.js +791 -0
package/sdk.js ADDED
@@ -0,0 +1,791 @@
1
+ // Generated by scripts/build_sdk.py from the OpenAPI spec. Do not edit.
2
+ //
3
+ // The client is one fetch call per method with no dependencies, so it runs in
4
+ // Node, in the browser, in a worker and on the edge without a build step.
5
+
6
+ export class CarlyEmailError extends Error {
7
+ constructor(status, body) {
8
+ super(body?.message || `HTTP ${status}`);
9
+ this.name = "CarlyEmailError";
10
+ this.status = status;
11
+ // The API answers errors with a message, the thing that clears it, and a
12
+ // documentation link. Dropping the last two would leave callers with only
13
+ // the sentence.
14
+ this.code = body?.code;
15
+ this.fix = body?.fix;
16
+ this.docs = body?.docs;
17
+ this.body = body;
18
+ }
19
+ }
20
+
21
+ const DEFAULT_BASE_URL = "https://api.carlyemail.com";
22
+
23
+ class Transport {
24
+ constructor(options = {}) {
25
+ const key =
26
+ options.apiKey ??
27
+ (typeof process !== "undefined" ? process.env?.CARLYEMAIL_API_KEY : undefined);
28
+ if (!key) {
29
+ throw new Error("No API key. Pass { apiKey } or set CARLYEMAIL_API_KEY.");
30
+ }
31
+ this.apiKey = key;
32
+ this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
33
+ this.fetch = options.fetch ?? globalThis.fetch;
34
+ }
35
+
36
+ async request(method, path, { query, body } = {}) {
37
+ const url = new URL(this.baseUrl + path);
38
+ for (const [name, value] of Object.entries(query ?? {})) {
39
+ if (value === undefined || value === null) continue;
40
+ // Repeated key, not a comma-joined string: that is what the API reads
41
+ // for list-valued query parameters such as `labels`.
42
+ for (const one of Array.isArray(value) ? value : [value]) {
43
+ url.searchParams.append(name, String(one));
44
+ }
45
+ }
46
+
47
+ const response = await this.fetch(url, {
48
+ method,
49
+ headers: {
50
+ authorization: `Bearer ${this.apiKey}`,
51
+ ...(body === undefined ? {} : { "content-type": "application/json" }),
52
+ },
53
+ body: body === undefined ? undefined : JSON.stringify(body),
54
+ });
55
+
56
+ if (response.status === 204) return undefined;
57
+
58
+ const text = await response.text();
59
+ const parsed = text ? JSON.parse(text) : undefined;
60
+ if (!response.ok) throw new CarlyEmailError(response.status, parsed);
61
+ return parsed;
62
+ }
63
+ }
64
+
65
+ function encode(value) {
66
+ return encodeURIComponent(String(value));
67
+ }
68
+
69
+
70
+ class Agent {
71
+ constructor(transport) {
72
+ this.$ = transport;
73
+ }
74
+
75
+ /** Sign Up */
76
+ signUp(body) {
77
+ return this.$.request("POST", `/v0/agent/sign-up`, { body });
78
+ }
79
+
80
+ /** Verify */
81
+ verify(body) {
82
+ return this.$.request("POST", `/v0/agent/verify`, { body });
83
+ }
84
+ }
85
+
86
+ class Auth {
87
+ constructor(transport) {
88
+ this.$ = transport;
89
+ }
90
+
91
+ /** Whoami */
92
+ whoami() {
93
+ return this.$.request("GET", `/v0/auth/me`);
94
+ }
95
+ }
96
+
97
+ class Billing {
98
+ constructor(transport) {
99
+ this.$ = transport;
100
+ }
101
+
102
+ /** Create Checkout */
103
+ createCheckout(body) {
104
+ return this.$.request("POST", `/v0/billing/checkout`, { body });
105
+ }
106
+
107
+ /** Create Portal */
108
+ createPortal() {
109
+ return this.$.request("POST", `/v0/billing/portal`);
110
+ }
111
+
112
+ /** Current Billing */
113
+ current() {
114
+ return this.$.request("GET", `/v0/billing`);
115
+ }
116
+ }
117
+
118
+ class Inboxes {
119
+ constructor(transport) {
120
+ this.$ = transport;
121
+ }
122
+
123
+ /** List Inboxes */
124
+ list(query = {}) {
125
+ return this.$.request("GET", `/v0/inboxes`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
126
+ }
127
+
128
+ /** Create Inbox */
129
+ create(body) {
130
+ return this.$.request("POST", `/v0/inboxes`, { body });
131
+ }
132
+
133
+ /** Get Inbox */
134
+ get(inboxId) {
135
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}`);
136
+ }
137
+
138
+ /** Update Inbox */
139
+ update(inboxId, body) {
140
+ return this.$.request("PATCH", `/v0/inboxes/${encode(inboxId)}`, { body });
141
+ }
142
+
143
+ /** Delete Inbox */
144
+ delete(inboxId) {
145
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}`);
146
+ }
147
+ }
148
+
149
+ class Messages {
150
+ constructor(transport) {
151
+ this.$ = transport;
152
+ }
153
+
154
+ /** List Messages */
155
+ list(inboxId, query = {}) {
156
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/messages`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending, "include_spam": query.includeSpam, "include_blocked": query.includeBlocked, "include_unauthenticated": query.includeUnauthenticated, "include_trash": query.includeTrash, "from": query.from, "to": query.to, "subject": query.subject } });
157
+ }
158
+
159
+ /** Search Messages */
160
+ search(inboxId, query = {}) {
161
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/messages/search`, { query: { "q": query.q, "limit": query.limit, "page_token": query.pageToken, "before": query.before, "after": query.after } });
162
+ }
163
+
164
+ /** Send */
165
+ send(inboxId, body) {
166
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/messages/send`, { body });
167
+ }
168
+
169
+ /** Reply */
170
+ reply(inboxId, messageId, body) {
171
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}/reply`, { body });
172
+ }
173
+
174
+ /** Batch Get */
175
+ batchGet(inboxId, body) {
176
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/messages/batch-get`, { body });
177
+ }
178
+
179
+ /** Batch Update */
180
+ batchUpdate(inboxId, body) {
181
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/messages/batch-update`, { body });
182
+ }
183
+
184
+ /** Reply All */
185
+ replyAll(inboxId, messageId, body) {
186
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}/reply-all`, { body });
187
+ }
188
+
189
+ /** Forward */
190
+ forward(inboxId, messageId, body) {
191
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}/forward`, { body });
192
+ }
193
+
194
+ /** Get Message */
195
+ get(inboxId, messageId) {
196
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}`);
197
+ }
198
+
199
+ /** Update Message */
200
+ update(inboxId, messageId, body) {
201
+ return this.$.request("PATCH", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}`, { body });
202
+ }
203
+
204
+ /** Delete Message */
205
+ delete(inboxId, messageId) {
206
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}`);
207
+ }
208
+
209
+ /** Get Raw */
210
+ getRaw(inboxId, messageId) {
211
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}/raw`);
212
+ }
213
+
214
+ /** Get Attachment */
215
+ getAttachment(inboxId, messageId, attachmentId) {
216
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/messages/${encode(messageId)}/attachments/${encode(attachmentId)}`);
217
+ }
218
+ }
219
+
220
+ class Threads {
221
+ constructor(transport) {
222
+ this.$ = transport;
223
+ }
224
+
225
+ /** List Threads */
226
+ list(inboxId, query = {}) {
227
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/threads`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending, "senders": query.senders, "recipients": query.recipients, "subject": query.subject } });
228
+ }
229
+
230
+ /** Search Threads */
231
+ search(inboxId, query = {}) {
232
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/threads/search`, { query: { "q": query.q, "limit": query.limit, "page_token": query.pageToken, "before": query.before, "after": query.after } });
233
+ }
234
+
235
+ /** Get Thread Attachment */
236
+ getAttachment(inboxId, threadId, attachmentId) {
237
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/threads/${encode(threadId)}/attachments/${encode(attachmentId)}`);
238
+ }
239
+
240
+ /** Get Thread */
241
+ get(inboxId, threadId) {
242
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/threads/${encode(threadId)}`);
243
+ }
244
+
245
+ /** Update Thread */
246
+ update(inboxId, threadId, body) {
247
+ return this.$.request("PATCH", `/v0/inboxes/${encode(inboxId)}/threads/${encode(threadId)}`, { body });
248
+ }
249
+
250
+ /** Delete Thread */
251
+ delete(inboxId, threadId) {
252
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}/threads/${encode(threadId)}`);
253
+ }
254
+
255
+ /** List Threads */
256
+ listOrg(query = {}) {
257
+ return this.$.request("GET", `/v0/threads`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending, "include_spam": query.includeSpam, "include_blocked": query.includeBlocked, "include_unauthenticated": query.includeUnauthenticated, "include_trash": query.includeTrash, "senders": query.senders, "recipients": query.recipients, "subject": query.subject } });
258
+ }
259
+
260
+ /** Search Threads */
261
+ searchOrg(query = {}) {
262
+ return this.$.request("GET", `/v0/threads/search`, { query: { "q": query.q, "limit": query.limit, "page_token": query.pageToken, "before": query.before, "after": query.after } });
263
+ }
264
+
265
+ /** Get Thread */
266
+ getOrg(threadId) {
267
+ return this.$.request("GET", `/v0/threads/${encode(threadId)}`);
268
+ }
269
+
270
+ /** Update Thread */
271
+ updateOrg(threadId, body) {
272
+ return this.$.request("PATCH", `/v0/threads/${encode(threadId)}`, { body });
273
+ }
274
+
275
+ /** Delete Thread */
276
+ deleteOrg(threadId) {
277
+ return this.$.request("DELETE", `/v0/threads/${encode(threadId)}`);
278
+ }
279
+
280
+ /** Get Attachment */
281
+ getOrgAttachment(threadId, attachmentId) {
282
+ return this.$.request("GET", `/v0/threads/${encode(threadId)}/attachments/${encode(attachmentId)}`);
283
+ }
284
+ }
285
+
286
+ class Drafts {
287
+ constructor(transport) {
288
+ this.$ = transport;
289
+ }
290
+
291
+ /** List Drafts */
292
+ list(inboxId, query = {}) {
293
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/drafts`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending } });
294
+ }
295
+
296
+ /** Create Draft */
297
+ create(inboxId, body) {
298
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/drafts`, { body });
299
+ }
300
+
301
+ /** Get Draft */
302
+ get(inboxId, draftId) {
303
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/drafts/${encode(draftId)}`);
304
+ }
305
+
306
+ /** Update Draft */
307
+ update(inboxId, draftId, body) {
308
+ return this.$.request("PATCH", `/v0/inboxes/${encode(inboxId)}/drafts/${encode(draftId)}`, { body });
309
+ }
310
+
311
+ /** Delete Draft */
312
+ delete(inboxId, draftId) {
313
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}/drafts/${encode(draftId)}`);
314
+ }
315
+
316
+ /** Send Draft */
317
+ send(inboxId, draftId, body) {
318
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/drafts/${encode(draftId)}/send`, { body });
319
+ }
320
+
321
+ /** Get Draft Attachment */
322
+ getAttachment(inboxId, draftId, attachmentId) {
323
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/drafts/${encode(draftId)}/attachments/${encode(attachmentId)}`);
324
+ }
325
+
326
+ /** List All Drafts */
327
+ listOrg(query = {}) {
328
+ return this.$.request("GET", `/v0/drafts`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending } });
329
+ }
330
+
331
+ /** Get Any Draft */
332
+ getOrg(draftId) {
333
+ return this.$.request("GET", `/v0/drafts/${encode(draftId)}`);
334
+ }
335
+
336
+ /** Get Any Draft Attachment */
337
+ getOrgAttachment(draftId, attachmentId) {
338
+ return this.$.request("GET", `/v0/drafts/${encode(draftId)}/attachments/${encode(attachmentId)}`);
339
+ }
340
+ }
341
+
342
+ class Lists {
343
+ constructor(transport) {
344
+ this.$ = transport;
345
+ }
346
+
347
+ /** List Inbox Entries */
348
+ listInboxEntries(inboxId, direction, type, query = {}) {
349
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/lists/${encode(direction)}/${encode(type)}`, { query: { "limit": query.limit, "page_token": query.pageToken } });
350
+ }
351
+
352
+ /** Create Inbox Entry */
353
+ createInboxEntry(inboxId, direction, type, body) {
354
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/lists/${encode(direction)}/${encode(type)}`, { body });
355
+ }
356
+
357
+ /** Get Inbox Entry */
358
+ getInboxEntry(inboxId, entry, direction, type) {
359
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/lists/${encode(direction)}/${encode(type)}/${encode(entry)}`);
360
+ }
361
+
362
+ /** Delete Inbox Entry */
363
+ deleteInboxEntry(inboxId, entry, direction, type) {
364
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}/lists/${encode(direction)}/${encode(type)}/${encode(entry)}`);
365
+ }
366
+
367
+ /** List Org Entries */
368
+ listOrgEntries(direction, type, query = {}) {
369
+ return this.$.request("GET", `/v0/lists/${encode(direction)}/${encode(type)}`, { query: { "limit": query.limit, "page_token": query.pageToken } });
370
+ }
371
+
372
+ /** Create Org Entry */
373
+ createOrgEntry(direction, type, body) {
374
+ return this.$.request("POST", `/v0/lists/${encode(direction)}/${encode(type)}`, { body });
375
+ }
376
+
377
+ /** Get Org Entry */
378
+ getOrgEntry(entry, direction, type) {
379
+ return this.$.request("GET", `/v0/lists/${encode(direction)}/${encode(type)}/${encode(entry)}`);
380
+ }
381
+
382
+ /** Delete Org Entry */
383
+ deleteOrgEntry(entry, direction, type) {
384
+ return this.$.request("DELETE", `/v0/lists/${encode(direction)}/${encode(type)}/${encode(entry)}`);
385
+ }
386
+ }
387
+
388
+ class Domains {
389
+ constructor(transport) {
390
+ this.$ = transport;
391
+ }
392
+
393
+ /** List Domains */
394
+ list(query = {}) {
395
+ return this.$.request("GET", `/v0/domains`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
396
+ }
397
+
398
+ /** Create Domain */
399
+ create(body) {
400
+ return this.$.request("POST", `/v0/domains`, { body });
401
+ }
402
+
403
+ /** Get Domain */
404
+ get(domainId) {
405
+ return this.$.request("GET", `/v0/domains/${encode(domainId)}`);
406
+ }
407
+
408
+ /** Update Domain */
409
+ update(domainId, body) {
410
+ return this.$.request("PATCH", `/v0/domains/${encode(domainId)}`, { body });
411
+ }
412
+
413
+ /** Delete Domain */
414
+ delete(domainId) {
415
+ return this.$.request("DELETE", `/v0/domains/${encode(domainId)}`);
416
+ }
417
+
418
+ /** Verify Domain */
419
+ verify(domainId) {
420
+ return this.$.request("POST", `/v0/domains/${encode(domainId)}/verify`);
421
+ }
422
+
423
+ /** Get Zone File */
424
+ getZoneFile(domainId) {
425
+ return this.$.request("GET", `/v0/domains/${encode(domainId)}/zone-file`);
426
+ }
427
+ }
428
+
429
+ class ApiKeys {
430
+ constructor(transport) {
431
+ this.$ = transport;
432
+ }
433
+
434
+ /** List Api Keys */
435
+ list(query = {}) {
436
+ return this.$.request("GET", `/v0/api-keys`, { query: { "limit": query.limit, "page_token": query.pageToken } });
437
+ }
438
+
439
+ /** Create Api Key */
440
+ create(body) {
441
+ return this.$.request("POST", `/v0/api-keys`, { body });
442
+ }
443
+
444
+ /** Delete Api Key */
445
+ delete(apiKeyId) {
446
+ return this.$.request("DELETE", `/v0/api-keys/${encode(apiKeyId)}`);
447
+ }
448
+
449
+ /** List Inbox Api Keys */
450
+ listInbox(inboxId, query = {}) {
451
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/api-keys`, { query: { "limit": query.limit, "page_token": query.pageToken } });
452
+ }
453
+
454
+ /** Create Inbox Api Key */
455
+ createInbox(inboxId, body) {
456
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/api-keys`, { body });
457
+ }
458
+
459
+ /** Delete Inbox Api Key */
460
+ deleteInbox(inboxId, apiKeyId) {
461
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}/api-keys/${encode(apiKeyId)}`);
462
+ }
463
+ }
464
+
465
+ class Metrics {
466
+ constructor(transport) {
467
+ this.$ = transport;
468
+ }
469
+
470
+ /** Org Events */
471
+ orgEvents(query = {}) {
472
+ return this.$.request("GET", `/v0/metrics/events`, { query: { "event_types": query.eventTypes, "start": query.start, "end": query.end, "period": query.period, "limit": query.limit, "descending": query.descending } });
473
+ }
474
+
475
+ /** Org Usage */
476
+ orgUsage(query = {}) {
477
+ return this.$.request("GET", `/v0/metrics/usage`, { query: { "usage_types": query.usageTypes, "start": query.start, "end": query.end, "period": query.period, "limit": query.limit, "descending": query.descending } });
478
+ }
479
+
480
+ /** Inbox Events */
481
+ inboxEvents(inboxId, query = {}) {
482
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/metrics/events`, { query: { "event_types": query.eventTypes, "start": query.start, "end": query.end, "period": query.period, "limit": query.limit, "descending": query.descending } });
483
+ }
484
+
485
+ /** Inbox Usage */
486
+ inboxUsage(inboxId, query = {}) {
487
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/metrics/usage`, { query: { "usage_types": query.usageTypes, "start": query.start, "end": query.end, "period": query.period, "limit": query.limit, "descending": query.descending } });
488
+ }
489
+ }
490
+
491
+ class Pods {
492
+ constructor(transport) {
493
+ this.$ = transport;
494
+ }
495
+
496
+ /** List Pods */
497
+ list(query = {}) {
498
+ return this.$.request("GET", `/v0/pods`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
499
+ }
500
+
501
+ /** Create Pod */
502
+ create(body) {
503
+ return this.$.request("POST", `/v0/pods`, { body });
504
+ }
505
+
506
+ /** Get Pod */
507
+ get(podId) {
508
+ return this.$.request("GET", `/v0/pods/${encode(podId)}`);
509
+ }
510
+
511
+ /** Delete Pod */
512
+ delete(podId) {
513
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}`);
514
+ }
515
+
516
+ /** List Inboxes */
517
+ listInboxes(podId, query = {}) {
518
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/inboxes`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
519
+ }
520
+
521
+ /** Create Inbox */
522
+ createInbox(podId, body) {
523
+ return this.$.request("POST", `/v0/pods/${encode(podId)}/inboxes`, { body });
524
+ }
525
+
526
+ /** Get Inbox */
527
+ getInbox(inboxId, podId) {
528
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/inboxes/${encode(inboxId)}`);
529
+ }
530
+
531
+ /** Update Inbox */
532
+ updateInbox(inboxId, podId, body) {
533
+ return this.$.request("PATCH", `/v0/pods/${encode(podId)}/inboxes/${encode(inboxId)}`, { body });
534
+ }
535
+
536
+ /** Delete Inbox */
537
+ deleteInbox(inboxId, podId) {
538
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}/inboxes/${encode(inboxId)}`);
539
+ }
540
+
541
+ /** List Threads */
542
+ listThreads(podId, query = {}) {
543
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/threads`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending, "include_spam": query.includeSpam, "include_blocked": query.includeBlocked, "include_unauthenticated": query.includeUnauthenticated, "include_trash": query.includeTrash, "senders": query.senders, "recipients": query.recipients, "subject": query.subject } });
544
+ }
545
+
546
+ /** Search Threads */
547
+ searchThreads(podId, query = {}) {
548
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/threads/search`, { query: { "q": query.q, "limit": query.limit, "page_token": query.pageToken, "before": query.before, "after": query.after } });
549
+ }
550
+
551
+ /** Get Thread */
552
+ getThread(threadId, podId) {
553
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/threads/${encode(threadId)}`);
554
+ }
555
+
556
+ /** Update Thread */
557
+ updateThread(threadId, podId, body) {
558
+ return this.$.request("PATCH", `/v0/pods/${encode(podId)}/threads/${encode(threadId)}`, { body });
559
+ }
560
+
561
+ /** Delete Thread */
562
+ deleteThread(threadId, podId) {
563
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}/threads/${encode(threadId)}`);
564
+ }
565
+
566
+ /** Get Thread Attachment */
567
+ getThreadAttachment(threadId, attachmentId, podId) {
568
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/threads/${encode(threadId)}/attachments/${encode(attachmentId)}`);
569
+ }
570
+
571
+ /** List Drafts */
572
+ listDrafts(podId, query = {}) {
573
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/drafts`, { query: { "limit": query.limit, "page_token": query.pageToken, "labels": query.labels, "before": query.before, "after": query.after, "ascending": query.ascending } });
574
+ }
575
+
576
+ /** Get Draft */
577
+ getDraft(draftId, podId) {
578
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/drafts/${encode(draftId)}`);
579
+ }
580
+
581
+ /** Get Draft Attachment */
582
+ getDraftAttachment(draftId, attachmentId, podId) {
583
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/drafts/${encode(draftId)}/attachments/${encode(attachmentId)}`);
584
+ }
585
+
586
+ /** List Entries */
587
+ listEntries(direction, type, podId, query = {}) {
588
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/lists/${encode(direction)}/${encode(type)}`, { query: { "limit": query.limit, "page_token": query.pageToken } });
589
+ }
590
+
591
+ /** Create Entry */
592
+ createEntry(direction, type, podId, body) {
593
+ return this.$.request("POST", `/v0/pods/${encode(podId)}/lists/${encode(direction)}/${encode(type)}`, { body });
594
+ }
595
+
596
+ /** Get Entry */
597
+ getEntry(entry, direction, type, podId) {
598
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/lists/${encode(direction)}/${encode(type)}/${encode(entry)}`);
599
+ }
600
+
601
+ /** Delete Entry */
602
+ deleteEntry(entry, direction, type, podId) {
603
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}/lists/${encode(direction)}/${encode(type)}/${encode(entry)}`);
604
+ }
605
+
606
+ /** List Domains */
607
+ listDomains(podId, query = {}) {
608
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/domains`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
609
+ }
610
+
611
+ /** Create Domain */
612
+ createDomain(podId, body) {
613
+ return this.$.request("POST", `/v0/pods/${encode(podId)}/domains`, { body });
614
+ }
615
+
616
+ /** Get Domain */
617
+ getDomain(domainId, podId) {
618
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/domains/${encode(domainId)}`);
619
+ }
620
+
621
+ /** Update Domain */
622
+ updateDomain(domainId, podId, body) {
623
+ return this.$.request("PATCH", `/v0/pods/${encode(podId)}/domains/${encode(domainId)}`, { body });
624
+ }
625
+
626
+ /** Delete Domain */
627
+ deleteDomain(domainId, podId) {
628
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}/domains/${encode(domainId)}`);
629
+ }
630
+
631
+ /** Verify Domain */
632
+ verifyDomain(domainId, podId) {
633
+ return this.$.request("POST", `/v0/pods/${encode(podId)}/domains/${encode(domainId)}/verify`);
634
+ }
635
+
636
+ /** Get Zone File */
637
+ getZoneFile(domainId, podId) {
638
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/domains/${encode(domainId)}/zone-file`);
639
+ }
640
+
641
+ /** List Webhooks */
642
+ listWebhooks(podId, query = {}) {
643
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/webhooks`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
644
+ }
645
+
646
+ /** Create Webhook */
647
+ createWebhook(podId, body) {
648
+ return this.$.request("POST", `/v0/pods/${encode(podId)}/webhooks`, { body });
649
+ }
650
+
651
+ /** Get Webhook */
652
+ getWebhook(webhookId, podId) {
653
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/webhooks/${encode(webhookId)}`);
654
+ }
655
+
656
+ /** Update Webhook */
657
+ updateWebhook(webhookId, podId, body) {
658
+ return this.$.request("PATCH", `/v0/pods/${encode(podId)}/webhooks/${encode(webhookId)}`, { body });
659
+ }
660
+
661
+ /** Delete Webhook */
662
+ deleteWebhook(webhookId, podId) {
663
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}/webhooks/${encode(webhookId)}`);
664
+ }
665
+
666
+ /** List Api Keys */
667
+ listApiKeys(podId, query = {}) {
668
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/api-keys`, { query: { "limit": query.limit, "page_token": query.pageToken } });
669
+ }
670
+
671
+ /** Create Api Key */
672
+ createApiKey(podId, body) {
673
+ return this.$.request("POST", `/v0/pods/${encode(podId)}/api-keys`, { body });
674
+ }
675
+
676
+ /** Delete Api Key */
677
+ deleteApiKey(apiKeyId, podId) {
678
+ return this.$.request("DELETE", `/v0/pods/${encode(podId)}/api-keys/${encode(apiKeyId)}`);
679
+ }
680
+
681
+ /** Metric Events */
682
+ metricEvents(podId, query = {}) {
683
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/metrics/events`, { query: { "event_types": query.eventTypes, "start": query.start, "end": query.end, "period": query.period, "limit": query.limit, "descending": query.descending } });
684
+ }
685
+
686
+ /** Metric Usage */
687
+ metricUsage(podId, query = {}) {
688
+ return this.$.request("GET", `/v0/pods/${encode(podId)}/metrics/usage`, { query: { "usage_types": query.usageTypes, "start": query.start, "end": query.end, "period": query.period, "limit": query.limit, "descending": query.descending } });
689
+ }
690
+ }
691
+
692
+ class Organizations {
693
+ constructor(transport) {
694
+ this.$ = transport;
695
+ }
696
+
697
+ /** Get Organization */
698
+ get() {
699
+ return this.$.request("GET", `/v0/organizations`);
700
+ }
701
+ }
702
+
703
+ class InboxEvents {
704
+ constructor(transport) {
705
+ this.$ = transport;
706
+ }
707
+
708
+ /** List Inbox Events */
709
+ list(inboxId, query = {}) {
710
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/events`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
711
+ }
712
+ }
713
+
714
+ class Webhooks {
715
+ constructor(transport) {
716
+ this.$ = transport;
717
+ }
718
+
719
+ /** List Webhooks */
720
+ list(query = {}) {
721
+ return this.$.request("GET", `/v0/webhooks`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
722
+ }
723
+
724
+ /** Create Webhook */
725
+ create(body) {
726
+ return this.$.request("POST", `/v0/webhooks`, { body });
727
+ }
728
+
729
+ /** Get Webhook */
730
+ get(webhookId) {
731
+ return this.$.request("GET", `/v0/webhooks/${encode(webhookId)}`);
732
+ }
733
+
734
+ /** Update Webhook */
735
+ update(webhookId, body) {
736
+ return this.$.request("PATCH", `/v0/webhooks/${encode(webhookId)}`, { body });
737
+ }
738
+
739
+ /** Delete Webhook */
740
+ delete(webhookId) {
741
+ return this.$.request("DELETE", `/v0/webhooks/${encode(webhookId)}`);
742
+ }
743
+
744
+ /** List Inbox Webhooks */
745
+ listInbox(inboxId, query = {}) {
746
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/webhooks`, { query: { "limit": query.limit, "page_token": query.pageToken, "ascending": query.ascending } });
747
+ }
748
+
749
+ /** Create Inbox Webhook */
750
+ createInbox(inboxId, body) {
751
+ return this.$.request("POST", `/v0/inboxes/${encode(inboxId)}/webhooks`, { body });
752
+ }
753
+
754
+ /** Get Inbox Webhook */
755
+ getInbox(inboxId, webhookId) {
756
+ return this.$.request("GET", `/v0/inboxes/${encode(inboxId)}/webhooks/${encode(webhookId)}`);
757
+ }
758
+
759
+ /** Update Inbox Webhook */
760
+ updateInbox(inboxId, webhookId, body) {
761
+ return this.$.request("PATCH", `/v0/inboxes/${encode(inboxId)}/webhooks/${encode(webhookId)}`, { body });
762
+ }
763
+
764
+ /** Delete Inbox Webhook */
765
+ deleteInbox(inboxId, webhookId) {
766
+ return this.$.request("DELETE", `/v0/inboxes/${encode(inboxId)}/webhooks/${encode(webhookId)}`);
767
+ }
768
+ }
769
+
770
+ export class CarlyEmail {
771
+ constructor(options = {}) {
772
+ const transport = new Transport(options);
773
+ this.agent = new Agent(transport);
774
+ this.auth = new Auth(transport);
775
+ this.billing = new Billing(transport);
776
+ this.inboxes = new Inboxes(transport);
777
+ this.messages = new Messages(transport);
778
+ this.threads = new Threads(transport);
779
+ this.drafts = new Drafts(transport);
780
+ this.lists = new Lists(transport);
781
+ this.domains = new Domains(transport);
782
+ this.apiKeys = new ApiKeys(transport);
783
+ this.metrics = new Metrics(transport);
784
+ this.pods = new Pods(transport);
785
+ this.organizations = new Organizations(transport);
786
+ this.inboxEvents = new InboxEvents(transport);
787
+ this.webhooks = new Webhooks(transport);
788
+ }
789
+ }
790
+
791
+ export default CarlyEmail;