UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

105 lines • 4.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Addresses = exports.BaseAddresses = void 0; // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. const resource_1 = require("../../core/resource.js"); const pagination_1 = require("../../core/pagination.js"); const path_1 = require("../../internal/utils/path.js"); var BaseAddresses = /* @__PURE__ */ (() => { class BaseAddresses extends resource_1.APIResource { /** * Create a destination address to forward your emails to. Destination addresses * need to be verified before they can be used. * * @example * ```ts * const address = await client.emailRouting.addresses.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * email: 'user@example.com', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post((0, path_1.path) `/accounts/${account_id}/email/routing/addresses`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Lists destination addresses configured for Email Routing in an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const address of client.emailRouting.addresses.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/email/routing/addresses`, (pagination_1.V4PagePaginationArray), { query, ...options }); } /** * Deletes a specific destination address. * * @example * ```ts * const address = await client.emailRouting.addresses.delete( * 'ea95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(destinationAddressIdentifier, params, options) { const { account_id } = params; return this._client.delete((0, path_1.path) `/accounts/${account_id}/email/routing/addresses/${destinationAddressIdentifier}`, options)._thenUnwrap((obj) => obj.result); } /** * Updates the status of a specific destination address. * * @example * ```ts * const address = await client.emailRouting.addresses.edit( * 'ea95132c15732412d22c1476fa83f27a', * { * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * status: 'verified', * }, * ); * ``` */ edit(destinationAddressIdentifier, params, options) { const { account_id, ...body } = params; return this._client.patch((0, path_1.path) `/accounts/${account_id}/email/routing/addresses/${destinationAddressIdentifier}`, { body, ...options })._thenUnwrap((obj) => obj.result); } /** * Gets information for a specific destination email already created. * * @example * ```ts * const address = await client.emailRouting.addresses.get( * 'ea95132c15732412d22c1476fa83f27a', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(destinationAddressIdentifier, params, options) { const { account_id } = params; return this._client.get((0, path_1.path) `/accounts/${account_id}/email/routing/addresses/${destinationAddressIdentifier}`, options)._thenUnwrap((obj) => obj.result); } } BaseAddresses._key = Object.freeze([ 'emailRouting', 'addresses', ]); return BaseAddresses; })(); exports.BaseAddresses = BaseAddresses; class Addresses extends BaseAddresses { } exports.Addresses = Addresses; //# sourceMappingURL=addresses.js.map