Class: SuperSendTX::SuppressionsResource

Inherits:
Object
  • Object
show all
Defined in:
lib/supersendtx/resources.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ SuppressionsResource

Returns a new instance of SuppressionsResource.



176
177
178
# File 'lib/supersendtx/resources.rb', line 176

def initialize(http)
  @http = http
end

Instance Method Details

#create(**params) ⇒ Object



187
188
189
# File 'lib/supersendtx/resources.rb', line 187

def create(**params)
  @http.request("POST", "/suppressions", body: params)
end

#list(limit: nil, cursor: nil, email: nil) ⇒ Object



180
181
182
183
184
185
# File 'lib/supersendtx/resources.rb', line 180

def list(limit: nil, cursor: nil, email: nil)
  @http.request(
    "GET",
    "/suppressions#{@http.query({ "limit" => limit, "cursor" => cursor, "email" => email })}"
  )
end

#remove(id_or_email) ⇒ Object



191
192
193
194
195
196
197
# File 'lib/supersendtx/resources.rb', line 191

def remove(id_or_email)
  if id_or_email.include?("@")
    return @http.request("DELETE", "/suppressions#{@http.query({ "email" => id_or_email })}")
  end

  @http.request("DELETE", "/suppressions/#{URI.encode_www_form_component(id_or_email)}")
end