Class: Smtpcom::Sendapi::Campaign
- Inherits:
-
ApiResource
- Object
- ApiResource
- Smtpcom::Sendapi::Campaign
- Defined in:
- lib/smtpcom/sendapi/campaign.rb
Constant Summary collapse
- MAPPINGS =
{ id: :CampaignID, name: :CampaignName, opens: :Opens, clicks: :Clicks, delivered: :Delivered, bounced: :Bounced }
Instance Attribute Summary collapse
-
#bounced ⇒ Object
readonly
Returns the value of attribute bounced.
-
#clicks ⇒ Object
readonly
Returns the value of attribute clicks.
-
#delivered ⇒ Object
readonly
Returns the value of attribute delivered.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#opens ⇒ Object
readonly
Returns the value of attribute opens.
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from ApiResource
#_get, #_get_raw, #_post, build_from_response, #initialize, #prepare_params
Methods included from Request
Constructor Details
This class inherits a constructor from Smtpcom::Sendapi::ApiResource
Instance Attribute Details
#bounced ⇒ Object (readonly)
Returns the value of attribute bounced.
14 15 16 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 14 def bounced @bounced end |
#clicks ⇒ Object (readonly)
Returns the value of attribute clicks.
14 15 16 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 14 def clicks @clicks end |
#delivered ⇒ Object (readonly)
Returns the value of attribute delivered.
14 15 16 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 14 def delivered @delivered end |
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 13 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
13 14 15 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 13 def name @name end |
#opens ⇒ Object (readonly)
Returns the value of attribute opens.
14 15 16 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 14 def opens @opens end |
Class Method Details
.all ⇒ Object
17 18 19 20 21 |
# 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) ⇒ Object
23 24 25 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 23 def find(id) all.find { |c| c.id == id } end |
Instance Method Details
#delete ⇒ Object
39 40 41 |
# File 'lib/smtpcom/sendapi/campaign.rb', line 39 def delete _post('/campaigns/delete', { CampaignID: @id }, :formatted) end |
#save ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# 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 |