Class: Alexa::API::TrafficHistory
- Inherits:
-
Base
- Object
- Base
- Alexa::API::TrafficHistory
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
Instance Method Details
#data ⇒ Object
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
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
|
#range ⇒ Object
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_id ⇒ Object
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
|
#site ⇒ Object
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
|
#start ⇒ Object
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_code ⇒ Object
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
|