Class: Insnergy::Client::Power
- Inherits:
-
Object
- Object
- Insnergy::Client::Power
- Defined in:
- lib/insnergy-api-ruby-client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#device_type_pointer ⇒ Object
readonly
Returns the value of attribute device_type_pointer.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Instance Method Summary collapse
- #get_device ⇒ Object
- #get_response ⇒ Object
-
#initialize(client: nil, device_id: nil, start_time: nil, end_time: nil) ⇒ Power
constructor
A new instance of Power.
Constructor Details
#initialize(client: nil, device_id: nil, start_time: nil, end_time: nil) ⇒ Power
Returns a new instance of Power.
44 45 46 47 48 49 50 51 |
# File 'lib/insnergy-api-ruby-client.rb', line 44 def initialize(client: nil, device_id: nil, start_time: nil, end_time: nil) @access_token = client.access_token @user_id = client.user_id @domain = client.domain @device_id = device_id @start_time = start_time @end_time = end_time end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
42 43 44 |
# File 'lib/insnergy-api-ruby-client.rb', line 42 def access_token @access_token end |
#device_type_pointer ⇒ Object (readonly)
Returns the value of attribute device_type_pointer.
42 43 44 |
# File 'lib/insnergy-api-ruby-client.rb', line 42 def device_type_pointer @device_type_pointer end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
42 43 44 |
# File 'lib/insnergy-api-ruby-client.rb', line 42 def response @response end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
42 43 44 |
# File 'lib/insnergy-api-ruby-client.rb', line 42 def user_id @user_id end |
Instance Method Details
#get_device ⇒ Object
53 54 55 |
# File 'lib/insnergy-api-ruby-client.rb', line 53 def get_device Power.new(@response) end |
#get_response ⇒ Object
57 58 59 60 61 |
# File 'lib/insnergy-api-ruby-client.rb', line 57 def get_response parameter = {:params => {:apsystem => "IFA", :email => @user_id, :attr => "dm1mi", :start_time => @start_time, :end_time => @end_time, :dev_ids => @device_id}, :Authorization => "Bearer #{@access_token}"} @response = JSON.parse(RestClient.get "#{@domain}/if/3/device/history_ext", parameter) @response end |