Class: Urbanairship::Reports::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/urbanairship/reports/response_statistics.rb

Instance Method Summary collapse

Instance Method Details

#get_period_params(start_date, end_date, precision) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/urbanairship/reports/response_statistics.rb', line 7

def get_period_params(start_date, end_date, precision)
  validates_parameters_presence!(start_date, end_date, precision)
  validates_precision_format!(precision)

  begin
    start_parsed = Time.parse(start_date).iso8601
    end_parsed = Time.parse(end_date).iso8601

    "?start=#{start_parsed}&end=#{end_parsed}&precision=#{precision}"
  rescue ArgumentError
    fail ArgumentError, 'start_date and end_date must be valid date strings'
  end
end