Class: Redlink::Endpoint
- Inherits:
-
Object
show all
- Defined in:
- lib/redlink/endpoint.rb
Defined Under Namespace
Classes: InvalidSessionError, NoCredentialsError
Class Method Summary
collapse
Class Method Details
.get_volatile_thermostat_data(thermostat_id) ⇒ Object
50
51
52
53
54
55
56
|
# File 'lib/redlink/endpoint.rb', line 50
def self.get_volatile_thermostat_data(thermostat_id)
verify_token
result = call_remote_method(:get_locations, message: {sessionID: Configuration.session_id, thermostatID: thermostat_id})
result[:ui]
end
|
.locations ⇒ Object
43
44
45
46
47
48
|
# File 'lib/redlink/endpoint.rb', line 43
def self.locations
result = call_remote_method(:get_locations, message: {sessionID: Configuration.session_id})
[result[:locations]].flatten.map do |loc|
loc[:location_info]
end
end
|
.login(username = Configuration.username, password = Configuration.password) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/redlink/endpoint.rb', line 6
def self.login(username = Configuration.username, password = Configuration.password)
return unless username && password
params = {
username: username,
password: password,
applicationID: Redlink::Configuration.app_token,
applicationVersion: 2,
uiLanguage: 'Default'
}
result = call_remote_method(:authenticate_user_login, message: params)
if result[:result] == 'Success'
user = result[:user_info]
session_id = result[:session_id]
Configuration.username = username
Configuration.password = password
Configuration.session_id = session_id
Configuration.user = user
Configuration.save
return true
else
return false
end
end
|
.logout ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/redlink/endpoint.rb', line 35
def self.logout
if Configuration.session_id
call_remote_method(:log_off, message: {sessionID: Configuration.session_id})
end
Configuration.clear!
end
|