cloudflare
Version:
The official TypeScript library for the Cloudflare API
77 lines • 3.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmailSending = exports.BaseEmailSending = void 0;
const tslib_1 = require("../../internal/tslib.js");
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
const resource_1 = require("../../core/resource.js");
const SuppressionsAPI = tslib_1.__importStar(require("./suppressions.js"));
const suppressions_1 = require("./suppressions.js");
const SubdomainsAPI = tslib_1.__importStar(require("./subdomains/subdomains.js"));
const subdomains_1 = require("./subdomains/subdomains.js");
const path_1 = require("../../internal/utils/path.js");
var BaseEmailSending = /* @__PURE__ */ (() => {
class BaseEmailSending extends resource_1.APIResource {
/**
* Send an email for the specified account using the structured builder. Provide
* the sender, recipients, subject, and at least one of text or html; attachments
* are optional.
*
* @example
* ```ts
* const response = await client.emailSending.send({
* account_id: 'account_id',
* from: 'sender@example.com',
* subject: 'Monthly Report',
* });
* ```
*/
send(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email/sending/send`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Send a raw RFC 5322 (MIME) email for the specified account. Provide the full
* MIME message plus the SMTP envelope (from and recipients).
*
* @example
* ```ts
* const response = await client.emailSending.sendRaw({
* account_id: 'account_id',
* from: 'sender@example.com',
* mime_message:
* 'From: sender@example.com\r\nTo: recipient@example.com\r\nSubject: Hello\r\nContent-Type: text/plain\r\n\r\nHello, World!',
* recipients: ['recipient@example.com'],
* });
* ```
*/
sendRaw(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email/sending/send_raw`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseEmailSending._key = Object.freeze(['emailSending']);
return BaseEmailSending;
})();
exports.BaseEmailSending = BaseEmailSending;
var EmailSending = /* @__PURE__ */ (() => {
class EmailSending extends BaseEmailSending {
constructor() {
super(...arguments);
this.suppressions = new SuppressionsAPI.Suppressions(this._client);
this.subdomains = new SubdomainsAPI.Subdomains(this._client);
}
}
EmailSending.Suppressions = suppressions_1.Suppressions;
EmailSending.BaseSuppressions = suppressions_1.BaseSuppressions;
EmailSending.Subdomains = subdomains_1.Subdomains;
EmailSending.BaseSubdomains = subdomains_1.BaseSubdomains;
return EmailSending;
})();
exports.EmailSending = EmailSending;
//# sourceMappingURL=email-sending.js.map