Class: Smtpcom::Sendapi::ClicksReport
- Inherits:
-
ApiResource
- Object
- ApiResource
- Smtpcom::Sendapi::ClicksReport
- Defined in:
- lib/smtpcom/sendapi/clicks_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.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #all(count = 100, page = 1) ⇒ Object
- #csv(count = 100, page = 1) ⇒ Object
- #csv_url ⇒ Object
-
#initialize(start, finish, sender = nil, campaign = nil, url = nil) ⇒ ClicksReport
constructor
A new instance of ClicksReport.
- #list_url ⇒ Object
- #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, url = nil) ⇒ ClicksReport
Returns a new instance of ClicksReport.
6 7 8 9 10 11 12 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 6 def initialize(start, finish, sender = nil, campaign = nil, url = nil) @start = start @finish = finish @sender = sender @campaign = campaign @url = url end |
Instance Attribute Details
#campaign ⇒ Object (readonly)
Returns the value of attribute campaign.
4 5 6 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 4 def campaign @campaign end |
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
4 5 6 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 4 def finish @finish end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
4 5 6 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 4 def sender @sender end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
4 5 6 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 4 def start @start end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 4 def total @total end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 4 def url @url end |
Instance Method Details
#all(count = 100, page = 1) ⇒ Object
14 15 16 17 18 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 14 def all(count = 100, page = 1) response = _get(list_url, prepare_params(count, page)) @total = response['Total'] format_response response['Data'] end |
#csv(count = 100, page = 1) ⇒ Object
20 21 22 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 20 def csv(count = 100, page = 1) _get_raw(csv_url, prepare_params(count, page).merge(headers: { 'Accept' => 'text/csv' })) end |
#csv_url ⇒ Object
28 29 30 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 28 def csv_url @url ? '/clicksbyurlexport/get' : '/clicksexport/get' end |
#list_url ⇒ Object
24 25 26 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 24 def list_url @url ? '/clicksbyurl/get' : '/clicks/get' end |
#prepare_params(count, page) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/smtpcom/sendapi/clicks_report.rb', line 32 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[:Url] = @url if @url attributes end |