Class: Urbanairship::Reports::DevicesReport

Inherits:
Object
  • Object
show all
Includes:
Common, Loggable
Defined in:
lib/urbanairship/reports/response_statistics.rb

Constant Summary

Constants included from Common

Common::CONTENT_TYPE

Instance Method Summary collapse

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')) ⇒ DevicesReport

Returns a new instance of DevicesReport.



86
87
88
# File 'lib/urbanairship/reports/response_statistics.rb', line 86

def initialize(client: required('client'))
  @client = client
end

Instance Method Details

#get(date: required('date')) ⇒ Object



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/urbanairship/reports/response_statistics.rb', line 90

def get(date: required('date'))
  fail ArgumentError,
     'date cannot be set to nil' if date.nil?
  begin
    date_parsed = Time.parse(date)
  rescue ArgumentError
    fail ArgumentError,
         'date must be a valid date string'
  end
  response = @client.send_request(
    method: 'GET',
    path: reports_path('devices/?date=' + date_parsed.iso8601)
  )
  logger.info("Retrieved device report for date #{date}")
  response
end