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.



178
179
180
# File 'lib/supersendtx/resources.rb', line 178

def initialize(http)
  @http = http
end

Instance Method Details

#create(**params) ⇒ Object



189
190
191
# File 'lib/supersendtx/resources.rb', line 189

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

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



182
183
184
185
186
187
# File 'lib/supersendtx/resources.rb', line 182

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



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

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