Class: Insnergy::Client::Control
- Inherits:
-
Object
- Object
- Insnergy::Client::Control
- Defined in:
- lib/insnergy-api-ruby-client.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#device_id ⇒ Object
Returns the value of attribute device_id.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(client: nil, device_id: nil, action: nil) ⇒ Control
constructor
A new instance of Control.
- #response! ⇒ Object
Constructor Details
#initialize(client: nil, device_id: nil, action: nil) ⇒ Control
Returns a new instance of Control.
105 106 107 108 109 110 111 112 113 |
# File 'lib/insnergy-api-ruby-client.rb', line 105 def initialize(client: nil, device_id: nil, action: nil) @access_token = client.access_token @user_id = client.user_id @domain = client.domain @device_id = device_id @action = action @response = nil response! end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
103 104 105 |
# File 'lib/insnergy-api-ruby-client.rb', line 103 def action @action end |
#device_id ⇒ Object
Returns the value of attribute device_id.
103 104 105 |
# File 'lib/insnergy-api-ruby-client.rb', line 103 def device_id @device_id end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
104 105 106 |
# File 'lib/insnergy-api-ruby-client.rb', line 104 def response @response end |
Instance Method Details
#response! ⇒ Object
115 116 117 118 119 120 |
# File 'lib/insnergy-api-ruby-client.rb', line 115 def response! parameter = {:params => {:apsystem => "IFA", :email => @user_id, :dev_id => @device_id ,:action => @action}, :Authorization => "Bearer #{@access_token}"} @response = JSON.parse(RestClient.get "#{@domain}/if/3/device/control" , parameter) raise "#{response['err']['code']}" unless response['err']['code'] == '0' @response end |