Class: Smtpcom::Sendapi::SendsReport
- Inherits:
-
ApiResource
- Object
- ApiResource
- Smtpcom::Sendapi::SendsReport
- Defined in:
- lib/smtpcom/sendapi/sends_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
- #failed(count = 100, page = 1) ⇒ Object
- #format_response(data) ⇒ Object
-
#initialize(start, finish, sender = nil, campaign = nil) ⇒ SendsReport
constructor
A new instance of SendsReport.
- #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) ⇒ SendsReport
Returns a new instance of SendsReport.
6 7 8 9 10 11 |
# File 'lib/smtpcom/sendapi/sends_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/sends_report.rb', line 4 def campaign @campaign end |
#finish ⇒ Object (readonly)
Returns the value of attribute finish.
4 5 6 |
# File 'lib/smtpcom/sendapi/sends_report.rb', line 4 def finish @finish end |
#sender ⇒ Object (readonly)
Returns the value of attribute sender.
4 5 6 |
# File 'lib/smtpcom/sendapi/sends_report.rb', line 4 def sender @sender end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
4 5 6 |
# File 'lib/smtpcom/sendapi/sends_report.rb', line 4 def start @start end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
4 5 6 |
# File 'lib/smtpcom/sendapi/sends_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/sends_report.rb', line 13 def all(count = 100, page = 1) response = _get('/sends/get', prepare_params(count, page)) @total = response['Total'] format_response response['Data'] end |
#failed(count = 100, page = 1) ⇒ Object
19 20 21 22 23 |
# File 'lib/smtpcom/sendapi/sends_report.rb', line 19 def failed(count = 100, page = 1) response = _get('/sends/failed', prepare_params(count, page)) @total = response['Total'] format_response response['Data'] end |
#format_response(data) ⇒ Object
37 38 39 40 41 |
# File 'lib/smtpcom/sendapi/sends_report.rb', line 37 def format_response(data) data.map do |row| Utils.format_response_row(row) end end |
#prepare_params(count, page) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/smtpcom/sendapi/sends_report.rb', line 25 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 |