UNPKG

cloudflare

Version:

The official TypeScript library for the Cloudflare API

98 lines 3.36 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../../resource.mjs"; import { V4PagePaginationArray } from "../../../pagination.mjs"; export class BlockSenders extends APIResource { /** * Create a blocked email sender * * @example * ```ts * const blockSender = * await client.emailSecurity.settings.blockSenders.create({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * is_regex: false, * pattern: 'test@example.com', * pattern_type: 'EMAIL', * }); * ``` */ create(params, options) { const { account_id, ...body } = params; return this._client.post(`/accounts/${account_id}/email-security/settings/block_senders`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * List blocked email senders * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const blockSenderListResponse of client.emailSecurity.settings.blockSenders.list( * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * )) { * // ... * } * ``` */ list(params, options) { const { account_id, ...query } = params; return this._client.getAPIList(`/accounts/${account_id}/email-security/settings/block_senders`, BlockSenderListResponsesV4PagePaginationArray, { query, ...options }); } /** * Delete a blocked email sender * * @example * ```ts * const blockSender = * await client.emailSecurity.settings.blockSenders.delete( * 2402, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ delete(patternId, params, options) { const { account_id } = params; return this._client.delete(`/accounts/${account_id}/email-security/settings/block_senders/${patternId}`, options)._thenUnwrap((obj) => obj.result); } /** * Update a blocked email sender * * @example * ```ts * const response = * await client.emailSecurity.settings.blockSenders.edit( * 2402, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ edit(patternId, params, options) { const { account_id, ...body } = params; return this._client.patch(`/accounts/${account_id}/email-security/settings/block_senders/${patternId}`, { body, ...options, })._thenUnwrap((obj) => obj.result); } /** * Get a blocked email sender * * @example * ```ts * const blockSender = * await client.emailSecurity.settings.blockSenders.get( * 2402, * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(patternId, params, options) { const { account_id } = params; return this._client.get(`/accounts/${account_id}/email-security/settings/block_senders/${patternId}`, options)._thenUnwrap((obj) => obj.result); } } export class BlockSenderListResponsesV4PagePaginationArray extends V4PagePaginationArray { } BlockSenders.BlockSenderListResponsesV4PagePaginationArray = BlockSenderListResponsesV4PagePaginationArray; //# sourceMappingURL=block-senders.mjs.map