Module: Resend::Suppressions::Batch
- Defined in:
- lib/resend/suppressions/batch.rb
Overview
Suppressions Batch API wrapper
Class Method Summary collapse
-
.add(params) ⇒ Object
Add up to 100 email addresses to the suppression list at once.
-
.remove(params) ⇒ Object
Remove up to 100 suppressions at once, either by email address or by suppression ID.
Class Method Details
.add(params) ⇒ Object
Add up to 100 email addresses to the suppression list at once. Addresses that are already suppressed come back with their existing suppression instead of failing.
https://resend.com/docs/api-reference/suppressions/add-suppressions
17 18 19 |
# File 'lib/resend/suppressions/batch.rb', line 17 def add(params) Resend::Request.new("suppressions/batch/add", params, "post").perform end |
.remove(params) ⇒ Object
Remove up to 100 suppressions at once, either by email address or by
suppression ID. Provide exactly one of emails or ids.
https://resend.com/docs/api-reference/suppressions/remove-suppressions
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/resend/suppressions/batch.rb', line 30 def remove(params) normalized = params.transform_keys(&:to_sym) emails = normalized[:emails] ids = normalized[:ids] raise ArgumentError, "Missing required `emails` or `ids` field" if emails.nil? && ids.nil? raise ArgumentError, "Provide either `emails` or `ids`, but not both" if !emails.nil? && !ids.nil? # The API rejects a null `emails`/`ids`, so the unused key is omitted rather than sent as nil. body = emails.nil? ? { ids: ids } : { emails: emails } Resend::Request.new("suppressions/batch/remove", body, "post").perform end |