Class: Dirigera::Client
- Inherits:
-
Object
- Object
- Dirigera::Client
- Defined in:
- lib/dirigera/client.rb
Instance Method Summary collapse
- #blinds ⇒ Object
- #devices ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(ip, bearer_token) ⇒ Client
constructor
A new instance of Client.
- #lights ⇒ Object
- #outlets ⇒ Object
- #patch(path, data) ⇒ Object
Constructor Details
#initialize(ip, bearer_token) ⇒ Client
Returns a new instance of Client.
4 5 6 7 |
# File 'lib/dirigera/client.rb', line 4 def initialize(ip, bearer_token) @ip = ip @bearer_token = bearer_token end |
Instance Method Details
#blinds ⇒ Object
9 10 11 |
# File 'lib/dirigera/client.rb', line 9 def blinds devices.select { |data| data['type'] == 'blinds' }.map { |data| make_device(data) } end |
#devices ⇒ Object
21 22 23 |
# File 'lib/dirigera/client.rb', line 21 def devices get("/devices") end |
#get(path, params = {}) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/dirigera/client.rb', line 25 def get(path, params = {}) HTTParty.get( "#{base_url}#{path}", query: params, headers: headers, verify: false ) end |
#lights ⇒ Object
17 18 19 |
# File 'lib/dirigera/client.rb', line 17 def lights devices.select { |data| data['type'] == 'light' }.map { |data| make_device(data) } end |
#outlets ⇒ Object
13 14 15 |
# File 'lib/dirigera/client.rb', line 13 def outlets devices.select { |data| data['type'] == 'outlet' }.map { |data| make_device(data) } end |
#patch(path, data) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/dirigera/client.rb', line 34 def patch(path, data) HTTParty.patch( "#{base_url}#{path}", body: data.to_json, headers: headers, verify: false ) end |