Class: Urbanairship::Reports::ResponseList

Inherits:
Common::PageIterator show all
Defined in:
lib/urbanairship/reports/response_statistics.rb

Constant Summary

Constants included from Common

Common::CONTENT_TYPE

Instance Attribute Summary

Attributes inherited from Common::PageIterator

#data_attribute

Instance Method Summary collapse

Methods inherited from Common::PageIterator

#count, #each

Methods included from Loggable

create_logger, logger, #logger

Methods included from Common

#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper

Constructor Details

#initialize(client: required('client'), start_date: required('start_date'), end_date: required('end_date'), limit: nil, push_id_start: nil) ⇒ ResponseList

Returns a new instance of ResponseList.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/urbanairship/reports/response_statistics.rb', line 57

def initialize(client: required('client'), start_date: required('start_date'),
    end_date: required('end_date'), limit: nil, push_id_start: nil)
  super(client: client)
  fail ArgumentError,
     'start_date and end_date are required fields' if start_date.nil? or end_date.nil?
  fail ArgumentError,
     'limit must be a number' if !limit.nil? and !limit.is_a? Numeric
  fail ArgumentError,
     'push_id_start must be a string' if !push_id_start.nil? and !push_id_start.is_a? String

  begin
    start_parsed = Time.parse(start_date)
    end_parsed = Time.parse(end_date)
  rescue ArgumentError
    fail ArgumentError,
         'start_date and end_date must be valid date strings'
  end
  path = reports_path('responses/list?start=' + start_parsed.iso8601 + '&end=' + end_parsed.iso8601)
  path += '&limit' + limit.to_s unless limit.nil?
  path += '&push_id_start&' + push_id_start unless push_id_start.nil?
  @next_page_path = path
  @data_attribute = 'pushes'
end