@explita/cloud-mail-client
Version:
A simple mail client for Node applications.
53 lines (52 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendMail = sendMail;
exports.sendBatch = sendBatch;
exports.getEmails = getEmails;
exports.getEmail = getEmail;
const http_1 = require("./lib/http");
/**
* Sends an email using the mail service.
* @param data - The data for sending the email.
*
* @returns A promise that resolves to the response from the mail service.
*/
async function sendMail(data) {
return await (0, http_1.httpClient)("/send", {
body: data,
});
}
/**
* Sends a batch of emails using the mail service.
*
* @param data - The data for sending the emails.
*
* @returns A promise that resolves to an array of responses from the mail service.
*/
async function sendBatch(data) {
return await (0, http_1.httpClient)("/send/batch", {
body: data,
});
}
/**
* Gets all emails from the mail service.
*
* @returns A promise that resolves to an array of emails.
*/
async function getEmails() {
return await (0, http_1.httpClient)("/emails", {
method: "GET",
});
}
/**
* Gets an email by its ID from the mail service.
*
* @param id - The ID of the email to get.
*
* @returns A promise that resolves to the email.
*/
async function getEmail(id) {
return await (0, http_1.httpClient)(`/emails/${id}`, {
method: "GET",
});
}