-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailsac-client.js
More file actions
641 lines (641 loc) · 39 KB
/
mailsac-client.js
File metadata and controls
641 lines (641 loc) · 39 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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
"use strict";
/* eslint-disable */
/* tslint:disable */
/*
* ---------------------------------------------------------------
* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
* ## ##
* ## AUTHOR: acacode ##
* ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
* ---------------------------------------------------------------
*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mailsac = exports.HttpClient = exports.ContentType = exports.ByteEncoding = exports.MessageFolder = void 0;
/** Folders for a email messages */
var MessageFolder;
(function (MessageFolder) {
MessageFolder["Inbox"] = "inbox";
MessageFolder["All"] = "all";
MessageFolder["Spam"] = "spam";
MessageFolder["Trash"] = "trash";
})(MessageFolder || (exports.MessageFolder = MessageFolder = {}));
var ByteEncoding;
(function (ByteEncoding) {
ByteEncoding["Byte"] = "byte";
ByteEncoding["Base64"] = "base64";
})(ByteEncoding || (exports.ByteEncoding = ByteEncoding = {}));
const axios_1 = require("axios");
var ContentType;
(function (ContentType) {
ContentType["Json"] = "application/json";
ContentType["FormData"] = "multipart/form-data";
ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
ContentType["Text"] = "text/plain";
})(ContentType || (exports.ContentType = ContentType = {}));
class HttpClient {
constructor(_a = {}) {
var { securityWorker, secure, format } = _a, axiosConfig = __rest(_a, ["securityWorker", "secure", "format"]);
this.securityData = null;
this.setSecurityData = (data) => {
this.securityData = data;
};
this.request = (_a) => __awaiter(this, void 0, void 0, function* () {
var { secure, path, type, query, format, body } = _a, params = __rest(_a, ["secure", "path", "type", "query", "format", "body"]);
const secureParams = ((typeof secure === "boolean" ? secure : this.secure) &&
this.securityWorker &&
(yield this.securityWorker(this.securityData))) ||
{};
const requestParams = this.mergeRequestParams(params, secureParams);
const responseFormat = format || this.format || undefined;
if (type === ContentType.FormData && body && body !== null && typeof body === "object") {
body = this.createFormData(body);
}
if (type === ContentType.Text && body && body !== null && typeof body !== "string") {
body = JSON.stringify(body);
}
return this.instance.request(Object.assign(Object.assign({}, requestParams), { headers: Object.assign(Object.assign({}, (requestParams.headers || {})), (type && type !== ContentType.FormData ? { "Content-Type": type } : {})), params: query, responseType: responseFormat, data: body, url: path }));
});
this.instance = axios_1.default.create(Object.assign(Object.assign({}, axiosConfig), { baseURL: axiosConfig.baseURL || "https://mailsac.com/api" }));
this.secure = secure;
this.format = format;
this.securityWorker = securityWorker;
}
mergeRequestParams(params1, params2) {
const method = params1.method || (params2 && params2.method);
return Object.assign(Object.assign(Object.assign(Object.assign({}, this.instance.defaults), params1), (params2 || {})), { headers: Object.assign(Object.assign(Object.assign({}, ((method && this.instance.defaults.headers[method.toLowerCase()]) || {})), (params1.headers || {})), ((params2 && params2.headers) || {})) });
}
stringifyFormItem(formItem) {
if (typeof formItem === "object" && formItem !== null) {
return JSON.stringify(formItem);
}
else {
return `${formItem}`;
}
}
createFormData(input) {
return Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
const propertyContent = property instanceof Array ? property : [property];
for (const formItem of propertyContent) {
const isFileType = formItem instanceof Blob || formItem instanceof File;
formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
}
return formData;
}, new FormData());
}
}
exports.HttpClient = HttpClient;
/**
* @title mailsac API Specification
* @version 1.0.8
* @baseUrl https://mailsac.com/api
*
* ## About the API
*
* The Mailsac API allows for interacting with Mailsac services, including checking email,
* email validations, setting up forwarding addresses, receiving web socket email messages,
* and sending outbound mail.
*
* [**Get a free API key**](https://mailsac.com/api-keys)
*
* Test the Mailsac API online:
*
* * [**Swagger UI Explorer** →](https://mailsac.com/docs/swagger)
*
* **Base API Endpoint**:
*
* * `https://mailsac.com/api/`
* * _All API documentation is relative to this endpoint._
*
* **OpenAPI Spec**:
*
* * [Download JSON](https://mailsac.com/openapi.json)
* * [Download YAML](https://mailsac.com/openapi.yml)
*
*
* ### Support and Resources
*
* * [npm Node.js and Browser library - @mailsac/api](https://www.npmjs.com/package/@mailsac/api)
* * [Full Documentation and Guides](https://docs.mailsac.com)
* * [Community Support and Discussion Forums](https://forum.mailsac.com/forums/)
* * [Web socket example in Node.js - ruffrey](https://github.com/ruffrey/mailsac-node-websocket-example)
*
* Paid Email Support, Pre-Sales
* > support@team.mailsac.com
*
* [Terms of Service](https://docs.mailsac.com/en/latest/about/terms_of_service.html)
*
* [Privacy Policy](https://docs.mailsac.com/en/latest/about/privacy_policy.html)
*/
class Mailsac extends HttpClient {
constructor() {
super(...arguments);
this.addresses = {
/**
* @description Get an array of enhanced private inbox address objects for the account. These addresses must be setup ("reserved") using `POST /api/addresses/:email`, or [on the Add Email Address page](https://mailsac.com/private-address).
*
* @tags Addresses
* @name ListAddresses
* @summary List all enhanced email addresses
* @request GET:/addresses
* @secure
*/
listAddresses: (params = {}) => this.request(Object.assign({ path: `/addresses`, method: "GET", secure: true, format: "json" }, params)),
/**
* No description
*
* @tags Addresses
* @name GetAddress
* @summary Fetch an address or check if it is reserved
* @request GET:/addresses/{email}
* @secure
*/
getAddress: (email, params = {}) => this.request(Object.assign({ path: `/addresses/${email}`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Sets the email address private and "owned" by the account. All messages which already exist, and any future messages which are received, will be private to this account only. An email address must be reserved to be able to forward messages to another email address, Slack, web sockets, or webhooks. Public email addresses, and private email addresses under a custom domain, are not routeable.
*
* @tags Addresses
* @name CreateAddress
* @summary Reserve (create/own) a private email address
* @request POST:/addresses/{email}
* @secure
*/
createAddress: (email, data, params = {}) => this.request(Object.assign({ path: `/addresses/${email}`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params)),
/**
* @description For a private email address, set it to forward to another place. It can be forwarded to another email (with `via mailsac` indicator), to a websocket, to a webhook, or to a Slack channel.
*
* @tags Addresses
* @name UpdateAddress
* @summary Update private email address forwarding and metadata
* @request PUT:/addresses/{email}
* @secure
*/
updateAddress: (email, data, params = {}) => this.request(Object.assign({ path: `/addresses/${email}`, method: "PUT", body: data, secure: true, type: ContentType.Json }, params)),
/**
* @description Removes this enhanced private address from ownership by the account. Any email received to the address's inbox will be public in the future, unless the address was under a custom domain which is set private.
*
* @tags Addresses
* @name DeleteAddress
* @summary Release an enhanced email address
* @request DELETE:/addresses/{email}
* @secure
*/
deleteAddress: (email, query, params = {}) => this.request(Object.assign({ path: `/addresses/${email}`, method: "DELETE", query: query, secure: true }, params)),
/**
* No description
*
* @tags Addresses
* @name CheckAvailability
* @summary Check address ownership
* @request GET:/addresses/{email}/availability
* @secure
*/
checkAvailability: (email, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/availability`, method: "GET", secure: true }, params)),
/**
* @description Reserves multiple enhanced private addresses. The max addresses per request is 100. It is not necessary to create enhanced addresses before receiving email. Enhanced addresses are only necessary to forward messages to another email address, Slack, web sockets, webhooks, or fetch messages over POP3.
*
* @tags Addresses
* @name CreateAddresses
* @summary Reserve multiple enhanced addresses
* @request POST:/private-addresses-bulk
* @secure
*/
createAddresses: (data, params = {}) => this.request(Object.assign({ path: `/private-addresses-bulk`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params)),
};
this.emailValidation = {
/**
* @description Determine whether an email address is a valid format, whether it is a disposable address, and the domains or IP addresses it is associated with.
*
* @tags emailValidation
* @name ValidateAddress
* @summary Validate an email address and if it is disposable
* @request GET:/validations/addresses/{email}
* @secure
*/
validateAddress: (email, params = {}) => this.request(Object.assign({ path: `/validations/addresses/${email}`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Determine whether an email address is a valid format, whether it is a disposable address, and the domains or IP addresses it is associated with.
*
* @tags emailValidation
* @name ValidateAddressesBulk
* @summary Validate up to 50 email addresses
* @request POST:/validations/addresses
* @secure
*/
validateAddressesBulk: (data, params = {}) => this.request(Object.assign({ path: `/validations/addresses`, method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params)),
};
this.messages = {
/**
* @description Get the number of messages for an email inbox address. **It is NOT necessary to reserve the address** before using this route. Whether it is an address on a custom domain, or a public domain, or mailsac.com, the mail can be counted as long as nobody else owns it.
*
* @tags Messages
* @name CountMessages
* @summary Count messages for an email inbox
* @request GET:/addresses/{email}/message-count
* @secure
*/
countMessages: (email, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/message-count`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Get a list of messages for the email address. Messages are always **sorted in decending order by when they were received**, with the newest message always in the first position of the array. The email message objects are abbreviated to provide basic meta data. To get more information about a specific message, use `GET /api/addresses/{email}/messages/{messageId}`. **It is NOT necessary to reserve the address** before checking mail! Whether it is an address on a custom domain, or a public domain, or mailsac.com, the mail can be checked with this route.
*
* @tags Messages
* @name ListMessages
* @summary List messages for an email inbox
* @request GET:/addresses/{email}/messages
* @secure
*/
listMessages: (email, query, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* @description This deletes all messages for a specific email address. The address must be an owned address or an address in a owned domain. Starred messages will not be deleted. Use `DELETE /addresses/{email}/messages/{messageId}` to remove starred messages or unstar the messages before calling this route.
*
* @tags Messages
* @name DeleteAllMessages
* @summary Delete all messages for an email inbox
* @request DELETE:/addresses/{email}/messages
* @secure
*/
deleteAllMessages: (email, query, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages`, method: "DELETE", query: query, secure: true }, params)),
/**
* @description Get a list of messages that have been saved and made private for the entire account using the "star message" feature. Messages recieved via the Capture Service will also show up as starred IF the `capturePrivate` flag on the account is enabled.
*
* @tags Messages
* @name ListStarredMessages
* @summary List starred (saved) messages on the account
* @request GET:/addresses/starred/messages
* @secure
*/
listStarredMessages: (params = {}) => this.request(Object.assign({ path: `/addresses/starred/messages`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Retrieves metadata about a single email message. This route includes additional metadata not available when listing messages, such as parsed links from the text or HTML body, and attachment md5sums. To get even more information about message attachments, like filenames, see the Attachments API. To get the entire original SMTP message, see the "raw" message route.
*
* @tags Messages
* @name GetMessageMetadata
* @summary Get email message metadata
* @request GET:/addresses/{email}/messages/{messageId}
* @secure
*/
getMessageMetadata: (email, messageId, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Deletes an individual email message. There is no trash or undo.
*
* @tags Messages
* @name DeleteMessage
* @summary Delete an email message
* @request DELETE:/addresses/{email}/messages/{messageId}
* @secure
*/
deleteMessage: (email, messageId, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}`, method: "DELETE", secure: true, format: "json" }, params)),
/**
* @description Gets the entire original SMTP message transport - everything that was sent over the network to Mailsac's inbound servers, plus any Mailsac-generated `Received` headers, and special `x-mailsac-*` headers.
*
* @tags Messages
* @name GetFullRawMessage
* @summary Get original SMTP message
* @request GET:/raw/{email}/{messageId}
* @secure
*/
getFullRawMessage: (email, messageId, query, params = {}) => this.request(Object.assign({ path: `/raw/${email}/${messageId}`, method: "GET", query: query, secure: true }, params)),
/**
* @description Returns pre-parsed message headers in one of 3 formats - `json`, `json-ordered`, or `plain`. If no querystring parameter is provided, the default format will be `json`. Every email is different; fields in the below examples are not guaranteed to exist.
*
* @tags Messages
* @name GetHeaders
* @summary Get parsed message headers
* @request GET:/addresses/{email}/messages/{messageId}/headers
* @secure
*/
getHeaders: (email, messageId, query, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/headers`, method: "GET", query: query, secure: true }, params)),
/**
* @description Get a message's HTML content. Attached images are inlined and nothing has been stripped. When no HTML body was sent in the original message, a simple HTML body will be created. Use the querystring param ?download=1 to trigger file download in browser.
*
* @tags Messages
* @name GetBodyDirty
* @summary Get message HTML body (dirty)
* @request GET:/dirty/{email}/{messageId}
* @secure
*/
getBodyDirty: (email, messageId, query, params = {}) => this.request(Object.assign({ path: `/dirty/${email}/${messageId}`, method: "GET", query: query, secure: true }, params)),
/**
* @description Get safe HTML from an email message. Scripts, images and links are stripped out. This HTML is safer to render than the potentially "dirty" original HTML. When no HTML body was sent in the original message, a simple HTML body will be created. Use the querystring param ?download=1 to trigger file download in browser.
*
* @tags Messages
* @name GetBodySanitized
* @summary Get the message HTML body (sanitized)
* @request GET:/body/{email}/{messageId}
* @secure
*/
getBodySanitized: (email, messageId, query, params = {}) => this.request(Object.assign({ path: `/body/${email}/${messageId}`, method: "GET", query: query, secure: true }, params)),
/**
* @description Get a message's text content. If the original message only contained HTML, a simple plain text body will be generated. HTTP links in the plain text email will be available when fetching the message's metadata at the `message.links[]` property. Use the querystring param ?download=1 to trigger file download in browser.
*
* @tags Messages
* @name GetBodyPlainText
* @summary Get message plaintext
* @request GET:/text/{email}/{messageId}
* @secure
*/
getBodyPlainText: (email, messageId, query, params = {}) => this.request(Object.assign({ path: `/text/${email}/${messageId}`, method: "GET", query: query, secure: true }, params)),
/**
* @description Toggle a message's *starred* status so it will not be automatically recycled when the account's message storage limit is reached. There is no PUT body. It returns only the message metadata.
*
* @tags Messages
* @name ToggleMessageStar
* @summary Star (save) a message
* @request PUT:/addresses/{email}/messages/{messageId}/star
* @secure
*/
toggleMessageStar: (email, messageId, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/star`, method: "PUT", secure: true, format: "json" }, params)),
/**
* @description To help organize messages and group messages together, add a label to a message. Labels are used in the Inbox UI to group messages. When successful, returns 200 with a subset of the message object. When the label already exists on the message, the message is not modified and the API endpoint returns 200. No PUT body is needed.
*
* @tags Messages
* @name AddMessageLabel
* @summary Add a label to a message
* @request PUT:/addresses/{email}/messages/{messageId}/labels/{label}
* @secure
*/
addMessageLabel: (email, messageId, label, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/labels/${label}`, method: "PUT", secure: true, format: "json" }, params)),
/**
* @description Removes a label from a message. Returns 200 with a subset of the message object when successful. When the label did not exists on the message, the message is not modified and the API endpoint returns 200.
*
* @tags Messages
* @name DeleteMessageLabel
* @summary Remove a label from a message
* @request DELETE:/addresses/{email}/messages/{messageId}/labels/{label}
* @secure
*/
deleteMessageLabel: (email, messageId, label, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/labels/${label}`, method: "DELETE", secure: true, format: "json" }, params)),
/**
* @description Move the message to a different mail folder. No new folders can be added. To organize mail, use labels. No PUT body is needed.
*
* @tags Messages
* @name SetMessageFolder
* @summary Move a message into a folder
* @request PUT:/addresses/{email}/messages/{messageId}/folder/{folder}
* @secure
*/
setMessageFolder: (email, messageId, folder, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/folder/${folder}`, method: "PUT", secure: true, format: "json" }, params)),
/**
* @description Change the read state of a message. Pass `readBoolean` as `true` to mark the message as read, and `false` to mark it as unread. The default for any new message `false` (unread). No PUT body is needed.
*
* @tags Messages
* @name SetMessageReadStatus
* @summary Set message read/unread status
* @request PUT:/addresses/{email}/messages/{messageId}/read/{readBoolean}
* @secure
*/
setMessageReadStatus: (email, messageId, readBoolean, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/read/${readBoolean}`, method: "PUT", secure: true, format: "json" }, params)),
/**
* @description Used by the Inbox UI to display all messages for the account, across all domains and private addresses. Returns email message short metadata, paginated, with the global account unread message count.
*
* @tags Messages
* @name ListInboxMessages
* @summary Get all account messages paginated
* @request GET:/inbox
* @secure
*/
listInboxMessages: (query, params = {}) => this.request(Object.assign({ path: `/inbox`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* @description Filter account messages within the the `to` and `from` `.address` fields, and the `subject` line. This differs from `/api/inbox-search` by using logical AND, rather than OR in `/api/inbox-search`. At least one query condition is required, otherwise a 400 will be returned. A maximum of 100 results will ever be returned. Refine the query or reduce the number of messages in the account to find specific items.
*
* @tags Messages
* @name FilterInboxMessages
* @summary Filter messages in account by to, from, and/or subject
* @request GET:/inbox-filter
* @secure
*/
filterInboxMessages: (query, params = {}) => this.request(Object.assign({ path: `/inbox-filter`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* @description Search all account messages within the the `to` and `from` `.address` fields, and the `subject` line. This differs from `/api/inbox-filter` by using logical OR, rather than AND in `/api/inbox-filter`. A maximum of 100 results will ever be returned. Refine the query or reduce the number of messages in the account to find specific items.
*
* @tags Messages
* @name SearchInboxMessages
* @summary Search messages by to, from, and subject
* @request GET:/inbox-search
* @secure
*/
searchInboxMessages: (query, params = {}) => this.request(Object.assign({ path: `/inbox-search`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* @description Get a list of messages across any inboxes of a domain. Messages are always **sorted in decending order by when they were received**, with the newest message always in the first position of the array. The email message objects are abbreviated to provide basic meta data. To get more information about a specific message, use `GET /api/addresses/{email}/messages/{messageId}`. The domain must be owned by the account making the request, and have DNS validated. Paginate with `until?=<Date>` and `limit=<uint>`.
*
* @tags Messages
* @name ListDomainMessages
* @summary List messages for an domain
* @request GET:/domains/{domain}/messages
* @secure
*/
listDomainMessages: (domain, query, params = {}) => this.request(Object.assign({ path: `/domains/${domain}/messages`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* @description Delete all messages for a specifc domain. Starred messages will be deleted. The domain must be owned domain.
*
* @tags Messages
* @name DeleteAllDomainMessages
* @summary Delete all messages in a domain
* @request POST:/domains/{domain}/delete-all-domain-mail
* @secure
*/
deleteAllDomainMessages: (domain, params = {}) => this.request(Object.assign({ path: `/domains/${domain}/delete-all-domain-mail`, method: "POST", secure: true }, params)),
};
this.domains = {
/**
* @description List custom domains for the account.
*
* @tags Domains
* @name ListDomains
* @summary List domains
* @request GET:/domains
* @secure
*/
listDomains: (params = {}) => this.request(Object.assign({ path: `/domains`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Get information about a configured domain, including the number of messages.
*
* @tags Domains
* @name GetDomain
* @summary Get domain information
* @request GET:/domains/{domain}
* @secure
*/
getDomain: (domain, params = {}) => this.request(Object.assign({ path: `/domains/${domain}`, method: "GET", secure: true, format: "json" }, params)),
};
this.account = {
/**
* @description Get information about the account for this API key.
*
* @tags Account
* @name User
* @summary Get current account
* @request GET:/me
* @secure
*/
user: (params = {}) => this.request(Object.assign({ path: `/me`, method: "GET", secure: true }, params)),
/**
* @description Get summary information about email addresses, domains, and usage.
*
* @tags Account
* @name AccountStats
* @summary Get account stats
* @request GET:/me/stats
* @secure
*/
accountStats: (query, params = {}) => this.request(Object.assign({ path: `/me/stats`, method: "GET", query: query, secure: true }, params)),
};
this.attachments = {
/**
* @description Get attachment metadata on email message.
*
* @tags Attachments
* @name ListMessageAttachments
* @summary List attachments for an email message
* @request GET:/addresses/{email}/messages/{messageId}/attachments
* @secure
*/
listMessageAttachments: (email, messageId, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/attachments`, method: "GET", secure: true }, params)),
/**
* @description Download an email message attachment as a file.
*
* @tags Attachments
* @name DownloadAttachment
* @summary Download email attachment
* @request GET:/addresses/{email}/messages/{messageId}/attachments/{attachmentIdentifier}
* @secure
*/
downloadAttachment: (email, messageId, attachmentIdentifier, params = {}) => this.request(Object.assign({ path: `/addresses/${email}/messages/${messageId}/attachments/${attachmentIdentifier}`, method: "GET", secure: true }, params)),
/**
* @description Search for attachments that were received during the requested time period. Limited to public inboxes and messages not starred by a user. Responds with 'Failed to fetch' in swagger editor. Works in curl with generated example.
*
* @tags Attachments
* @name ListPublicAttachments
* @summary Search for attachments
* @request GET:/mailstats/common-attachments
* @secure
*/
listPublicAttachments: (query, params = {}) => this.request(Object.assign({ path: `/mailstats/common-attachments`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* @description Provides count of attachments by md5 sum Responds with 'Failed to fetch' in swagger editor, works in curl with generated example
*
* @tags Attachments
* @name CountPublicAttachments
* @summary Count public attachments
* @request GET:/mailstats/common-attachments/{md5sum}/count
* @secure
*/
countPublicAttachments: (md5Sum, params = {}) => this.request(Object.assign({ path: `/mailstats/common-attachments/${md5Sum}/count`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description List the email messages that have attachments with the requested MD5 sum. Limited to non-private inboxes.
*
* @tags Attachments
* @name ListMessagesForAttachment
* @summary List public messages with an attachment
* @request GET:/mailstats/common-attachments/{md5sum}
* @secure
*/
listMessagesForAttachment: (md5Sum, params = {}) => this.request(Object.assign({ path: `/mailstats/common-attachments/${md5Sum}`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Download an attachment with the MD5 sum requested.
*
* @tags Attachments
* @name DownloadPublicAttachment
* @summary Download public attachment
* @request GET:/mailstats/common-attachments/{md5sum}/download
* @secure
*/
downloadPublicAttachment: (md5Sum, params = {}) => this.request(Object.assign({ path: `/mailstats/common-attachments/${md5Sum}/download`, method: "GET", secure: true }, params)),
};
this.messageStats = {
/**
* No description
*
* @tags messageStats
* @name ListTopPublicAddresses
* @summary List top public disposable email addresses receiving messages
* @request GET:/mailstats/top-addresses
* @secure
*/
listTopPublicAddresses: (query, params = {}) => this.request(Object.assign({ path: `/mailstats/top-addresses`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* No description
*
* @tags messageStats
* @name ListTopPublicSenders
* @summary List top sender email addresses for disposable public messages
* @request GET:/mailstats/top-senders
* @secure
*/
listTopPublicSenders: (query, params = {}) => this.request(Object.assign({ path: `/mailstats/top-senders`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* No description
*
* @tags messageStats
* @name ListTopPublicDomains
* @summary List top public domains receiving disposable messages
* @request GET:/mailstats/top-domains
* @secure
*/
listTopPublicDomains: (query, params = {}) => this.request(Object.assign({ path: `/mailstats/top-domains`, method: "GET", query: query, secure: true, format: "json" }, params)),
/**
* No description
*
* @tags messageStats
* @name Denylist
* @summary List the current deny-list
* @request GET:/mailstats/blacklist
* @secure
*/
denylist: (params = {}) => this.request(Object.assign({ path: `/mailstats/blacklist`, method: "GET", secure: true, format: "json" }, params)),
/**
* @description Check whether an IP or domain is currently on the deny-list.
*
* @tags messageStats
* @name CheckDenylist
* @summary Check IP or domain on deny-list
* @request GET:/mailstats/blacklist/{domainOrIP}
* @secure
*/
checkDenylist: (domainOrIp, params = {}) => this.request(Object.assign({ path: `/mailstats/blacklist/${domainOrIp}`, method: "GET", secure: true, format: "json" }, params)),
};
this.webSockets = {
/**
* @description *Note: this does not work in Swagger UI. Visit https://sock.mailsac.com to test.* You can receive email via web socket for private email addresses and custom domains. To enable web socket forwarding: * Addresses: Select *Edit* for the email address you want to forward. Then check the checkbox for web socket forwarding, and save. * Custom Domains: Select *Manage* for the domain and click the *Forwarding* tab. Toggle the *Enable Web Sockets* option. Note: Web socket forwarding is **not enabled by default.** ### Web Socket Examples #### Web Socket Test Page https://sock.mailsac.com Receive emails in your web browser. Experiment with the web socket gateway in realtime. #### Web Socket Node.js Listen for Mailsac emails via websocket in this tiny Node.js example app. https://github.com/ruffrey/mailsac-node-websocket-example ### Web Socket Connection Endpoint The web socket endpoint is `wss://sock.mailsac.com/incoming-messages` Example: > wss://sock.mailsac.com/incoming-messages?key=k_e9bPnd2adexample&addresses=jeff@mailsac.com,asdf-outbound.mailsac.com > First frame: ``` { "status": 200, "msg": "Listening", "addresses": [ "jeff@mailsac.com" ], "domains": [ "asdf-outbound.mailsac.com" ] } ``` All web socket messages are JSON. After parsing the JSON, there will be a status field with an HTTP status code (usually 200). An email coming over the web socket will also have an email property, and its value will be the same as the messages REST API, plus some additional fields.
*
* @tags Web Sockets
* @name DoNotUseWebSocketDocsOnly
* @summary Connect a web socket to wss://sock.mailsac.com/incoming-messages
* @request POST:/custom_web_sockets
*/
doNotUseWebSocketDocsOnly: (query, params = {}) => this.request(Object.assign({ path: `/custom_web_sockets`, method: "POST", query: query }, params)),
};
this.webhooks = {
/**
* @description *Note: this does not work in Swagger UI.* Webhook Forwarding is one of several options available for enhanced addresses and custom domains (via catch-all addresses enabled under a custom domain). Forwarding to a Webhook can be configured by selecting Manage Email Addresses from the Dashboard. Select the Settings button next to the email address to manage, then input the URL under Forward To Custom Webhook and select Save Settings. Troubleshoot webhooks using your account *Audit Logs*.
*
* @tags Webhooks
* @name DoNotUseWebhookDocsOnly
* @summary Receive a webhook email message on your server
* @request POST:/custom_webhooks
*/
doNotUseWebhookDocsOnly: (params = {}) => this.request(Object.assign({ path: `/custom_webhooks`, method: "POST" }, params)),
};
}
}
exports.Mailsac = Mailsac;