Class: Telnyx::Resources::EmailBlocks
- Inherits:
-
Object
- Object
- Telnyx::Resources::EmailBlocks
- Defined in:
- lib/telnyx/resources/email_blocks.rb,
lib/telnyx/resources/email_blocks/import.rb,
sig/telnyx/resources/email_blocks.rbs,
sig/telnyx/resources/email_blocks/import.rbs
Overview
Recipient suppression records (/v2/email_blocks).
Defined Under Namespace
Classes: Import
Instance Attribute Summary collapse
-
#import ⇒ Telnyx::Resources::EmailBlocks::Import
readonly
Async CSV import of competitor suppression lists.
Instance Method Summary collapse
-
#create(to:, domain_id: nil, expires_at: nil, from: nil, request_options: {}) ⇒ Telnyx::Models::EmailBlockResponse
Creates a suppression with
reason: manual_blockandsource: manual. -
#delete(id, request_options: {}) ⇒ Telnyx::Models::EmailBlockResponse
Soft-deletes (status →
removed; tombstone retained). -
#initialize(client:) ⇒ EmailBlocks
constructor
private
A new instance of EmailBlocks.
-
#list(filter_created_after: nil, filter_created_before: nil, filter_domain_id: nil, filter_reason: nil, page_after: nil, page_before: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::EmailBlock>
Some parameter documentations has been truncated, see Models::EmailBlockListParams for more details.
-
#retrieve(id, request_options: {}) ⇒ Telnyx::Models::EmailBlockResponse
Retrieve a suppression.
-
#retrieve_events(id, page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Models::EmailBlockRetrieveEventsResponse
Offset pagination only (
page[number]default 1,page[size]default 50, max 100). -
#retrieve_export(filter_created_after: nil, filter_created_before: nil, filter_domain_id: nil, filter_reason: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ String
Some parameter documentations has been truncated, see Models::EmailBlockRetrieveExportParams for more details.
Constructor Details
#initialize(client:) ⇒ EmailBlocks
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of EmailBlocks.
243 244 245 246 |
# File 'lib/telnyx/resources/email_blocks.rb', line 243 def initialize(client:) @client = client @import = Telnyx::Resources::EmailBlocks::Import.new(client: client) end |
Instance Attribute Details
#import ⇒ Telnyx::Resources::EmailBlocks::Import (readonly)
Async CSV import of competitor suppression lists.
9 10 11 |
# File 'lib/telnyx/resources/email_blocks.rb', line 9 def import @import end |
Instance Method Details
#create(to:, domain_id: nil, expires_at: nil, from: nil, request_options: {}) ⇒ Telnyx::Models::EmailBlockResponse
Creates a suppression with reason: manual_block and source: manual.
Caller-supplied reason / source are ignored; scope is derived
server-side from domain_id / from and is never trusted. Idempotent: if a
matching row already exists (NULL-safe dedupe key: account_id, scope, to,
reason, domain_id, from), returns the existing record with 200 (no new audit
event).
bounce_category, dsn_code, meta, and group_id are not accepted on
the public surface. Use the unsubscribe-group suppression endpoint or the
internal create surface for those.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/telnyx/resources/email_blocks.rb', line 37 def create(params) parsed, = Telnyx::EmailBlockCreateParams.dump_request(params) @client.request( method: :post, path: "email_blocks", body: parsed, model: Telnyx::EmailBlockResponse, options: ) end |
#delete(id, request_options: {}) ⇒ Telnyx::Models::EmailBlockResponse
Soft-deletes (status → removed; tombstone retained). A removed audit event
is appended unless the block was already removed (idempotent — returns the
existing row with 200 and no new event). Mutates updated_at.
143 144 145 146 147 148 149 150 |
# File 'lib/telnyx/resources/email_blocks.rb', line 143 def delete(id, params = {}) @client.request( method: :delete, path: ["email_blocks/%1$s", id], model: Telnyx::EmailBlockResponse, options: params[:request_options] ) end |
#list(filter_created_after: nil, filter_created_before: nil, filter_domain_id: nil, filter_reason: nil, page_after: nil, page_before: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::EmailBlock>
Some parameter documentations has been truncated, see Models::EmailBlockListParams for more details.
Account-scoped list. Two mutually exclusive pagination modes:
- Offset:
page[number](default 1) +page[size](default 25, max 100).metacontainstotal_pages. - Cursor:
page[after]and/orpage[before](opaqueBase.url_encode64of{"created_at","id"}). Cannot combine withpage[number];after+beforetogether is an error.metacontainsnext_cursor/previous_cursor(omitted when their flag is false).
Sort defaults to -created_at (desc); only created_at is sortable. A --
prefix is an error. nil/empty filter values are silently dropped.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/telnyx/resources/email_blocks.rb', line 108 def list(params = {}) parsed, = Telnyx::EmailBlockListParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "email_blocks", query: query.transform_keys( filter_created_after: "filter[created_after]", filter_created_before: "filter[created_before]", filter_domain_id: "filter[domain_id]", filter_reason: "filter[reason]", page_after: "page[after]", page_before: "page[before]", page_number: "page[number]", page_size: "page[size]" ), page: Telnyx::Internal::DefaultFlatPagination, model: Telnyx::EmailBlock, options: ) end |
#retrieve(id, request_options: {}) ⇒ Telnyx::Models::EmailBlockResponse
Retrieve a suppression
59 60 61 62 63 64 65 66 |
# File 'lib/telnyx/resources/email_blocks.rb', line 59 def retrieve(id, params = {}) @client.request( method: :get, path: ["email_blocks/%1$s", id], model: Telnyx::EmailBlockResponse, options: params[:request_options] ) end |
#retrieve_events(id, page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Models::EmailBlockRetrieveEventsResponse
Offset pagination only (page[number] default 1, page[size] default 50,
max 100). No sort, no filter, no cursor — ordering is fixed
desc occurred_at, desc id. Verifies the block belongs to the account first
(cross-account → 404).
170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/telnyx/resources/email_blocks.rb', line 170 def retrieve_events(id, params = {}) parsed, = Telnyx::EmailBlockRetrieveEventsParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["email_blocks/%1$s/events", id], query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"), model: Telnyx::Models::EmailBlockRetrieveEventsResponse, options: ) end |
#retrieve_export(filter_created_after: nil, filter_created_before: nil, filter_domain_id: nil, filter_reason: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ String
Some parameter documentations has been truncated, see Models::EmailBlockRetrieveExportParams for more details.
Streams the account's suppressions as a chunked CSV (server-side cursor; never
materialized). Content-type text/csv, header
Content-Disposition: attachment; filename="email_blocks_export.csv".
Filters (filter[reason], filter[domain_id], filter[created_after],
filter[created_before]) are the only params that affect output. sort and
page[*] are parsed (bad values still produce 400) but ignored — rows
stream ORDER BY created_at ASC, id ASC with no pagination.
CSV columns:
id,to,from,reason,source,scope,status,domain_id, created_at,updated_at,expires_at,group_id.
The CSV carries the group_id column so group-scoped suppressions' group link
survives the export (empty for account-scope rows).
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/telnyx/resources/email_blocks.rb', line 220 def retrieve_export(params = {}) parsed, = Telnyx::EmailBlockRetrieveExportParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "email_blocks/export", query: query.transform_keys( filter_created_after: "filter[created_after]", filter_created_before: "filter[created_before]", filter_domain_id: "filter[domain_id]", filter_reason: "filter[reason]", page_number: "page[number]", page_size: "page[size]" ), headers: {"accept" => "text/csv"}, model: String, options: ) end |