class Urbanairship::Reports::ResponseList

Public Class Methods

new(client: required('client'), start_date: required('start_date'), end_date: required('end_date'), limit: nil, push_id_start: nil) click to toggle source
Calls superclass method Urbanairship::Common::PageIterator::new
# 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