class Vesync::Event
Public Class Methods
new(attributes = {})
click to toggle source
# File lib/vesync/event.rb, line 3 def initialize(attributes = {}) attributes.each {|k, v| send("#{k}=", v) if respond_to?("#{k}=")} device = device_id(attributes[:device_name]) RestClient.put("#{Vesync::SWITCH_URI}/#{device}/status/#{attributes[:event_type]}", {}, headers) end
Public Instance Methods
account_id()
click to toggle source
# File lib/vesync/event.rb, line 9 def account_id Vesync.auth["accountID"] end
device_id(device_name)
click to toggle source
# File lib/vesync/event.rb, line 21 def device_id(device_name) devices = JSON.parse(RestClient.get(Vesync::DEVICES_URI, headers).body) device = devices.detect {|device| device["deviceName"] == device_name } device["cid"] end
headers()
click to toggle source
# File lib/vesync/event.rb, line 17 def headers {"tk":token,"accountid":account_id} end
token()
click to toggle source
# File lib/vesync/event.rb, line 13 def token Vesync.auth["tk"] end