Class: WeConnect::Client
- Inherits:
-
API
- Object
- API
- WeConnect::Client
show all
- Defined in:
- lib/weconnect/client.rb
Overview
Wrapper for the WeConnect REST API
Constant Summary
Authentication::REFRESH_URL, Authentication::TOKENS, Authentication::TOKEN_URL
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from API
#config
#api_process_token, #auth_tokens, #login, #refresh_token
Methods included from Connection
#reauth_connection
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
12
13
14
15
16
|
# File 'lib/weconnect/client.rb', line 12
def initialize(options = {})
super(options)
@openid_config = openid_configuration
end
|
Instance Attribute Details
#openid_config ⇒ Object
Returns the value of attribute openid_config.
10
11
12
|
# File 'lib/weconnect/client.rb', line 10
def openid_config
@openid_config
end
|
Instance Method Details
#control(vin, operation, value) ⇒ Object
38
39
40
|
# File 'lib/weconnect/client.rb', line 38
def control(vin, operation, value)
self.post(vehicle_api(vin,"/#{operation}/#{value}"))
end
|
#control_charging(vin, value) ⇒ Object
41
42
43
44
45
|
# File 'lib/weconnect/client.rb', line 41
def control_charging(vin, value)
if ControlOperation.allowed_values.includes? value
control(vin,'charging',value)
end
end
|
#images(vin) ⇒ Object
34
35
36
|
# File 'lib/weconnect/client.rb', line 34
def images(vin)
self.get("/media/v2/vehicle-images/{self.vin.value}?resolution=2x")
end
|
#parking(vin) ⇒ Object
26
27
28
|
# File 'lib/weconnect/client.rb', line 26
def parking(vin)
self.get(vehicle_api(vin,'/parkingposition'))
end
|
#trips(vin, trip_type = TripType::SHORT_TERM, period) ⇒ Object
30
31
32
|
# File 'lib/weconnect/client.rb', line 30
def trips(vin,trip_type=TripType::SHORT_TERM,period)
sef.get('/vehicle/v1/trips/#{vin}/#{trip_type.downcase}/last',params)
end
|
#vehicle_status(vin, jobs = ['all']) ⇒ Object
21
22
23
24
|
# File 'lib/weconnect/client.rb', line 21
def vehicle_status(vin, jobs=['all'])
jobs = jobs.join(',') if jobs.is_a? Array
self.get(vehicle_api(vin,"/selectivestatus?jobs=#{jobs}"))
end
|
#vehicles(params = {}) ⇒ Object
18
19
20
|
# File 'lib/weconnect/client.rb', line 18
def vehicles(params={})
self.get(vehicle_api,params)
end
|