Class: Alexa::API::TrafficHistory

Inherits:
Base
  • Object
show all
Defined in:
lib/alexa/api/traffic_history.rb

Instance Attribute Summary

Attributes inherited from Base

#arguments, #response_body

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parsed_body

Methods included from Utils

camelize, safe_retrieve

Constructor Details

This class inherits a constructor from Alexa::API::Base

Instance Method Details

#dataObject



33
34
35
# File 'lib/alexa/api/traffic_history.rb', line 33

def data
  @data ||= safe_retrieve(parsed_body, "TrafficHistoryResponse", "Response", "TrafficHistoryResult", "Alexa", "TrafficHistory", "HistoricalData", "Data")
end

#fetch(arguments = {}) ⇒ Object

Raises:



6
7
8
9
10
11
12
13
14
15
# File 'lib/alexa/api/traffic_history.rb', line 6

def fetch(arguments = {})
  raise ArgumentError, "You must specify url" unless arguments.has_key?(:url)
  @arguments = arguments

  @arguments[:range] = arguments.fetch(:range, 31)
  @arguments[:start] = arguments.fetch(:start) { Time.now - (3600 * 24 * @arguments[:range].to_i) }

  @response_body = Alexa::Connection.new(@credentials).get(params)
  self
end

#rangeObject



27
28
29
30
31
# File 'lib/alexa/api/traffic_history.rb', line 27

def range
  return @range if defined?(@range)
  range = safe_retrieve(parsed_body, "TrafficHistoryResponse", "Response", "TrafficHistoryResult", "Alexa", "TrafficHistory", "Range")
  @range = range ? range.to_i : nil
end

#request_idObject



41
42
43
# File 'lib/alexa/api/traffic_history.rb', line 41

def request_id
  @request_id ||= safe_retrieve(parsed_body, "TrafficHistoryResponse", "Response", "OperationRequest", "RequestId")
end

#siteObject

Response attributes



19
20
21
# File 'lib/alexa/api/traffic_history.rb', line 19

def site
  @site ||= safe_retrieve(parsed_body, "TrafficHistoryResponse", "Response", "TrafficHistoryResult", "Alexa", "TrafficHistory", "Site")
end

#startObject



23
24
25
# File 'lib/alexa/api/traffic_history.rb', line 23

def start
  @start ||= safe_retrieve(parsed_body, "TrafficHistoryResponse", "Response", "TrafficHistoryResult", "Alexa", "TrafficHistory", "Start")
end

#status_codeObject



37
38
39
# File 'lib/alexa/api/traffic_history.rb', line 37

def status_code
  @status_code ||= safe_retrieve(parsed_body, "TrafficHistoryResponse", "Response", "ResponseStatus", "StatusCode")
end