Class: Smtpcom::Sendapi::OpensReport
- Inherits:
-
ApiResource
- Object
- ApiResource
- Smtpcom::Sendapi::OpensReport
- Defined in:
- lib/smtpcom/sendapi/opens_report.rb
Instance Attribute Summary collapse
-
#campaign ⇒ Object
readonly
Returns the value of attribute campaign.
-
#finish ⇒ Object
readonly
Returns the value of attribute finish.
-
#sender ⇒ Object
readonly
Returns the value of attribute sender.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #all(count = 100, page = 1) ⇒ Object
- #csv(count = 100, page = 1) ⇒ Object
-
#initialize(start, finish, sender = nil, campaign = nil) ⇒ OpensReport
constructor
A new instance of OpensReport.
- #prepare_params(count, page) ⇒ Object
Methods inherited from ApiResource
#_get, #_get_raw, #_post, build_from_response
Methods included from Request
Constructor Details
#initialize(start, finish, sender = nil, campaign = nil) ⇒ OpensReport
Returns a new instance of OpensReport.
6 7 8 9 10 11 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 6 def initialize(start, finish, sender = nil, campaign = nil) @start = start @finish = finish @sender = sender @campaign = campaign end |
Instance Attribute Details
#campaign ⇒ Object (readonly)
Returns the value of attribute campaign.
4 5 6 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 4 def campaign @campaign end |
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
4 5 6 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 4 def finish @finish end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
4 5 6 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 4 def sender @sender end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
4 5 6 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 4 def start @start end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 4 def total @total end |
Instance Method Details
#all(count = 100, page = 1) ⇒ Object
13 14 15 16 17 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 13 def all(count = 100, page = 1) response = _get('/opens/get', prepare_params(count, page)) @total = response['Total'] format_response response['Data'] end |
#csv(count = 100, page = 1) ⇒ Object
19 20 21 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 19 def csv(count = 100, page = 1) _get_raw('/opensexport/get', prepare_params(count, page).merge(headers: { 'Accept' => 'text/csv' })) end |
#prepare_params(count, page) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/smtpcom/sendapi/opens_report.rb', line 23 def prepare_params(count, page) attributes = { DateFrom: @start.strftime("%m/%d/%Y"), DateTo: @finish.strftime("%m/%d/%Y"), Count: count, Page: page } attributes[:Sender] = @sender if @sender attributes[:CampaignID] = @campaign if @campaign attributes end |