Class: Axene::Mailer::Resources::Suppressions
- Inherits:
-
Object
- Object
- Axene::Mailer::Resources::Suppressions
- Defined in:
- lib/axene/mailer/resources/suppressions.rb
Overview
The suppressions resource: manage the do-not-send list. Accessed as client.suppressions.
Instance Method Summary collapse
-
#add(email:, reason: "manual") ⇒ Hash
Suppress a single address.
-
#bulk_upload(file, filename: "suppressions.txt") ⇒ Hash
Bulk-import suppressions from a file (one email per line).
-
#initialize(transport) ⇒ Suppressions
constructor
A new instance of Suppressions.
-
#list(page: 0, limit: 50, search: nil) ⇒ Hash
List suppressed addresses (paginated envelope; zero-based
page). -
#remove(id) ⇒ nil
Remove an address from the suppression list.
Constructor Details
#initialize(transport) ⇒ Suppressions
Returns a new instance of Suppressions.
10 11 12 |
# File 'lib/axene/mailer/resources/suppressions.rb', line 10 def initialize(transport) @transport = transport end |
Instance Method Details
#add(email:, reason: "manual") ⇒ Hash
Suppress a single address. The email argument maps to the wire field email_address.
30 31 32 |
# File 'lib/axene/mailer/resources/suppressions.rb', line 30 def add(email:, reason: "manual") @transport.request(:post, "/v1/suppressions", body: { email_address: email, reason: reason }) end |
#bulk_upload(file, filename: "suppressions.txt") ⇒ Hash
Bulk-import suppressions from a file (one email per line). file may be raw bytes (a String) or a path to a readable file.
40 41 42 43 |
# File 'lib/axene/mailer/resources/suppressions.rb', line 40 def bulk_upload(file, filename: "suppressions.txt") bytes = read_file(file) @transport.upload("/v1/suppressions/bulk", bytes, filename) end |
#list(page: 0, limit: 50, search: nil) ⇒ Hash
List suppressed addresses (paginated envelope; zero-based page).
20 21 22 |
# File 'lib/axene/mailer/resources/suppressions.rb', line 20 def list(page: 0, limit: 50, search: nil) @transport.request(:get, "/v1/suppressions", query: { page: page, limit: limit, search: search }) end |