class Smtpcom::Sendapi::Campaign

Constants

MAPPINGS

Attributes

bounced[R]
clicks[R]
delivered[R]
id[RW]
name[RW]
opens[R]

Public Class Methods

all() click to toggle source
# File lib/smtpcom/sendapi/campaign.rb, line 17
def all
  _get('/campaigns/get')['Data'].map do |row|
    build_from_response row
  end
end
find(id) click to toggle source
# File lib/smtpcom/sendapi/campaign.rb, line 23
def find(id)
  all.find { |c| c.id == id }
end

Public Instance Methods

delete() click to toggle source
# File lib/smtpcom/sendapi/campaign.rb, line 39
def delete
  _post('/campaigns/delete', { CampaignID: @id }, :formatted)
end
save() click to toggle source
# File lib/smtpcom/sendapi/campaign.rb, line 28
def save
  attrs = { CampaignName: @name }
  res = if @id
          _get '/campaigns/update', attrs.merge(CampaignID: @id), :formatted
        else
          _post '/campaigns/add', attrs, :formatted
        end
  @id = res[:id]
  res
end