cloudflare
Version:
The official TypeScript library for the Cloudflare API
138 lines • 5.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Suppressions = exports.BaseSuppressions = 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 BaseSuppressions = /* @__PURE__ */ (() => {
class BaseSuppressions extends resource_1.APIResource {
/**
* Creates a suppression for every sending domain of the account (default) or for
* one sending domain (`scope.type = sending_domain`). Creating an existing active
* suppression returns its identifier. If a mutable legacy zone-linked account row
* already exists, it is promoted without changing its identifier.
*
* @example
* ```ts
* const suppression =
* await client.emailSending.suppressions.create({
* account_id: '12345678',
* email: 'user@example.com',
* });
* ```
*/
create(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email/sending/suppressions`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Lists every active Email Sending suppression owned by the account:
* sending-domain suppressions first, then account-wide suppressions (including
* legacy rows with internal zone memberships). Each group is newest first.
*
* @example
* ```ts
* // Automatically fetches more pages as needed.
* for await (const suppressionListResponse of client.emailSending.suppressions.list(
* { account_id: '12345678' },
* )) {
* // ...
* }
* ```
*/
list(params, options) {
const { account_id, ...query } = params;
return this._client.getAPIList((0, path_1.path) `/accounts/${account_id}/email/sending/suppressions`, (pagination_1.CursorPagination), { query, ...options });
}
/**
* Deletes the suppression, its note, and every legacy internal zone membership,
* allowing future delivery attempts to the address.
*
* @example
* ```ts
* const suppression =
* await client.emailSending.suppressions.delete(
* '396a5436-d4b0-42a6-b3fc-48e8fa522321',
* { account_id: '12345678' },
* );
* ```
*/
delete(suppressionID, params, options) {
const { account_id } = params;
return this._client.delete((0, path_1.path) `/accounts/${account_id}/email/sending/suppressions/${suppressionID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Updates expiry or advisory note fields without changing legacy internal zone
* memberships. Scope cannot be changed.
*
* @example
* ```ts
* const response =
* await client.emailSending.suppressions.edit(
* '396a5436-d4b0-42a6-b3fc-48e8fa522321',
* { account_id: '12345678' },
* );
* ```
*/
edit(suppressionID, params, options) {
const { account_id, ...body } = params;
return this._client.patch((0, path_1.path) `/accounts/${account_id}/email/sending/suppressions/${suppressionID}`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
/**
* Gets an Email Sending suppression owned by the account.
*
* @example
* ```ts
* const suppression =
* await client.emailSending.suppressions.get(
* '396a5436-d4b0-42a6-b3fc-48e8fa522321',
* { account_id: '12345678' },
* );
* ```
*/
get(suppressionID, params, options) {
const { account_id } = params;
return this._client.get((0, path_1.path) `/accounts/${account_id}/email/sending/suppressions/${suppressionID}`, options)._thenUnwrap((obj) => obj.result);
}
/**
* Imports up to 1,000 Email Sending suppressions in one request. Each item applies
* to every sending domain of the account (default) or to one sending domain.
*
* @example
* ```ts
* const response =
* await client.emailSending.suppressions.import({
* account_id: '12345678',
* items: [
* { email: 'user@example.com' },
* { email: 'other@example.com' },
* ],
* });
* ```
*/
import(params, options) {
const { account_id, ...body } = params;
return this._client.post((0, path_1.path) `/accounts/${account_id}/email/sending/suppressions/bulk`, {
body,
...options,
})._thenUnwrap((obj) => obj.result);
}
}
BaseSuppressions._key = Object.freeze([
'emailSending',
'suppressions',
]);
return BaseSuppressions;
})();
exports.BaseSuppressions = BaseSuppressions;
class Suppressions extends BaseSuppressions {
}
exports.Suppressions = Suppressions;
//# sourceMappingURL=suppressions.js.map