Class: CommaAPI::API
Constant Summary
Constants included
from Config
Config::API_HOST, Config::DONGLE_ID_DEFAULT
Class Method Summary
collapse
Methods included from HTTP
http, post_request, request
Class Method Details
.args ⇒ Object
87
88
89
|
# File 'lib/comma_api.rb', line 87
def args
defaultArgs end
|
.defaultArgs ⇒ Object
91
92
93
94
|
# File 'lib/comma_api.rb', line 91
def defaultArgs
one_week = 604800
"?from=#{(Time.now - one_week - 1).to_i}"
end
|
.device(id:) ⇒ Object
21
22
23
|
# File 'lib/comma_api.rb', line 21
def device(id:)
get "/v1.1/devices/#{id}/"
end
|
.device404Error ⇒ Object
114
115
116
|
# File 'lib/comma_api.rb', line 114
def device404Error
{ error: 'Error: DONGLE_ID_DEFAULT is missing - this method cannot be executed, you need to specify a dongle id' }.to_json
end
|
.deviceDefaultLocation ⇒ Object
.deviceDefaultSegments ⇒ Object
.deviceDefaultStats ⇒ Object
.deviceLocation(id:) ⇒ Object
25
26
27
|
# File 'lib/comma_api.rb', line 25
def deviceLocation(id:)
get "/v1/devices/#{id}/location"
end
|
.devices ⇒ Object
17
18
19
|
# File 'lib/comma_api.rb', line 17
def devices
get "/v1/me/devices/"
end
|
.deviceSegments(id:) ⇒ Object
77
78
79
80
|
# File 'lib/comma_api.rb', line 77
def deviceSegments(id:)
return device404Error unless DONGLE_ID_DEFAULT
get "/v1/devices/#{id}/segments#{args}"
end
|
.devicesStat(id:) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/comma_api.rb', line 48
def devicesStat(id:)
devices = get "/v1/devices"
devices.map { |device|
get "/v1/devices/#{device.f("dongle_id")}/stats#{args}"
}
end
|
.deviceStats(id:) ⇒ Object
44
45
46
|
# File 'lib/comma_api.rb', line 44
def deviceStats(id:)
get "/v1/devices/#{id}/stats"
end
|
.deviceStatsId(id:) ⇒ Object
56
57
58
|
# File 'lib/comma_api.rb', line 56
def deviceStatsId(id:)
get "/v1/devices/#{id}/stats#{args}"
end
|
.get(method_name) ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/comma_api.rb', line 103
def get(method_name)
puts "requesting: #{method_name}"
url = "#{API_HOST}#{method_name}"
puts url
request url: url
end
|
.me ⇒ Object
11
12
13
|
# File 'lib/comma_api.rb', line 11
def me
get "/v1/me/"
end
|
.opAuth ⇒ Object
96
97
98
|
# File 'lib/comma_api.rb', line 96
def opAuth
"https://api.commadotai.com/v2/pilotauth/"
end
|
.route(route_name:) ⇒ Object
62
63
64
|
# File 'lib/comma_api.rb', line 62
def route(route_name:)
get "/v1/route/#{route_name}/"
end
|
.routeFiles(route_name:) ⇒ Object
66
67
68
|
# File 'lib/comma_api.rb', line 66
def routeFiles(route_name:)
get "/v1/route/#{route_name}/files"
end
|