Module: Resend::Suppressions

Defined in:
lib/resend/suppressions.rb,
lib/resend/suppressions/batch.rb

Overview

Suppressions API wrapper

Defined Under Namespace

Modules: Batch

Class Method Summary collapse

Class Method Details

.add(params) ⇒ Object

Add an email address to the suppression list. Suppressed addresses are skipped by future sends. Adding an address that is already suppressed succeeds and returns the existing suppression.

https://resend.com/docs/api-reference/suppressions/add-suppression

Parameters:

  • params (Hash)

    the parameters

Options Hash (params):

  • :email (String)

    the email address to suppress (required). The API lowercases and trims it.



17
18
19
# File 'lib/resend/suppressions.rb', line 17

def add(params)
  Resend::Request.new("suppressions", params, "post").perform
end

.get(id_or_email) ⇒ Object

Retrieve a single suppression. The API returns 404 'Suppression not found' when the address or ID is not suppressed.

https://resend.com/docs/api-reference/suppressions/get-suppression

Parameters:

  • id_or_email (String)

    the suppression ID or the suppressed email address (required)

Raises:

  • (ArgumentError)


44
45
46
47
48
# File 'lib/resend/suppressions.rb', line 44

def get(id_or_email)
  raise ArgumentError, "Missing required `id_or_email` field" if id_or_email.nil? || id_or_email.empty?

  Resend::Request.new("suppressions/#{ERB::Util.url_encode(id_or_email)}", {}, "get").perform
end

.list(params = {}) ⇒ Object

Retrieve a list of suppressions. Each entry has id, email, origin, source_id and created_at; unlike get, list entries carry no object key.

https://resend.com/docs/api-reference/suppressions/list-suppressions

Parameters:

  • params (Hash) (defaults to: {})

    optional filtering and pagination parameters

Options Hash (params):

  • :origin (String)

    filter by origin: 'bounce', 'complaint' or 'manual'

  • :limit (Integer)

    number of results to return (1-100)

  • :after (String)

    cursor for forward pagination

  • :before (String)

    cursor for backward pagination



32
33
34
35
# File 'lib/resend/suppressions.rb', line 32

def list(params = {})
  path = Resend::PaginationHelper.build_paginated_path("suppressions", params)
  Resend::Request.new(path, {}, "get").perform
end

.remove(id_or_email) ⇒ Object

Remove a single suppression, which allows sending to that address again. The API returns 404 'Suppression not found' when the address or ID is not suppressed.

https://resend.com/docs/api-reference/suppressions/remove-suppression

Parameters:

  • id_or_email (String)

    the suppression ID or the suppressed email address (required)

Raises:

  • (ArgumentError)


57
58
59
60
61
# File 'lib/resend/suppressions.rb', line 57

def remove(id_or_email)
  raise ArgumentError, "Missing required `id_or_email` field" if id_or_email.nil? || id_or_email.empty?

  Resend::Request.new("suppressions/#{ERB::Util.url_encode(id_or_email)}", {}, "delete").perform
end