Class: Broadcast::Resources::Suppressions
- Defined in:
- lib/broadcast/resources/suppressions.rb
Overview
The current channel's suppression list. Addresses on it never receive broadcasts, sequences, or transactionals from this channel.
The installation-wide list is a separate resource — see
GlobalSuppressions — but check reads across both on purpose: it
answers the question an integration actually asks, "will this address
receive mail?".
Instance Method Summary collapse
-
#add(email) ⇒ Object
Add an address to the channel's suppression list.
-
#bulk_add(emails) ⇒ Object
Add up to 10,000 addresses at once.
-
#bulk_remove(emails) ⇒ Object
Remove up to 10,000 addresses at once.
-
#check(email) ⇒ Object
Will this address receive mail? Reads across both the global and the channel list — a globally blocked address reports
suppressed: truehere even though it is absent from the channel's own list. -
#list(**params) ⇒ Object
List the channel's suppressions (250 per page, with
paginationmetadata; passpage:). -
#remove(email) ⇒ Object
Remove an address from the channel's suppression list.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Broadcast::Resources::Base
Instance Method Details
#add(email) ⇒ Object
Add an address to the channel's suppression list.
Adding an address that is already suppressed is a success (the server answers 200 instead of 201), so callers do not have to check first.
24 25 26 |
# File 'lib/broadcast/resources/suppressions.rb', line 24 def add(email) post('/api/v1/suppressions.json', { email: email }) end |
#bulk_add(emails) ⇒ Object
Add up to 10,000 addresses at once. Idempotent: a retried batch cannot
duplicate. Returns added, already_suppressed, and invalid counts.
37 38 39 |
# File 'lib/broadcast/resources/suppressions.rb', line 37 def bulk_add(emails) post('/api/v1/suppressions/bulk.json', { emails: emails }) end |
#bulk_remove(emails) ⇒ Object
Remove up to 10,000 addresses at once. Returns removed and
not_found counts.
43 44 45 |
# File 'lib/broadcast/resources/suppressions.rb', line 43 def bulk_remove(emails) @client.request(:delete, '/api/v1/suppressions/bulk.json', { emails: emails }) end |
#check(email) ⇒ Object
Will this address receive mail? Reads across both the global and the
channel list — a globally blocked address reports suppressed: true
here even though it is absent from the channel's own list. The
response's scope says which list matched.
51 52 53 |
# File 'lib/broadcast/resources/suppressions.rb', line 51 def check(email) get('/api/v1/suppressions/check.json', { email: email }) end |
#list(**params) ⇒ Object
List the channel's suppressions (250 per page, with pagination
metadata; pass page:). Optional email: filters by partial,
case-insensitive match.
16 17 18 |
# File 'lib/broadcast/resources/suppressions.rb', line 16 def list(**params) get('/api/v1/suppressions.json', params) end |
#remove(email) ⇒ Object
Remove an address from the channel's suppression list. Returns
removed: false (not an error) when the address was not on it.
Does not touch the global list.
31 32 33 |
# File 'lib/broadcast/resources/suppressions.rb', line 31 def remove(email) @client.request(:delete, '/api/v1/suppressions.json', { email: email }) end |