Class: Vesync
- Inherits:
-
Object
- Object
- Vesync
- Defined in:
- lib/vesync.rb,
lib/vesync/event.rb,
lib/vesync/config.rb,
lib/vesync/version.rb
Defined Under Namespace
Constant Summary collapse
- BASE_URI =
"https://smartapi.vesync.com"
- AUTH_URI =
"#{Vesync::BASE_URI}/vold/user/login"
- DEVICES_URI =
"#{Vesync::BASE_URI}/vold/user/devices"
- SWITCH_URI =
"#{Vesync::BASE_URI}/v1/wifi-switch-1.3"
- VERSION =
"0.1.0"
Class Method Summary collapse
- .auth ⇒ Object
- .config ⇒ Object
- .password ⇒ Object
- .send_event(event_type, device_name, auth) ⇒ Object
- .username ⇒ Object
Class Method Details
.auth ⇒ Object
27 28 29 30 |
# File 'lib/vesync.rb', line 27 def auth payload = { account: Vesync.username, password: Vesync.password }.to_json JSON.parse(RestClient.post(AUTH_URI, payload).body) end |
.config ⇒ Object
15 16 17 |
# File 'lib/vesync.rb', line 15 def config Config.instance end |
.password ⇒ Object
23 24 25 |
# File 'lib/vesync.rb', line 23 def password Digest::MD5.hexdigest(config.password.encode("utf-8")) end |
.send_event(event_type, device_name, auth) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/vesync.rb', line 32 def send_event(event_type, device_name, auth) event = Vesync::Event.new( event_type: event_type, device_name: device_name ) end |
.username ⇒ Object
19 20 21 |
# File 'lib/vesync.rb', line 19 def username config.username end |