Class: Insnergy::Client::Power
- Inherits:
-
Object
- Object
- Insnergy::Client::Power
- Defined in:
- lib/insnergy-api-ruby-client.rb
Instance Attribute Summary collapse
-
#device_ids ⇒ Object
Returns the value of attribute device_ids.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Instance Method Summary collapse
-
#initialize(client: nil, device_ids: [], start_time: nil, end_time: nil) ⇒ Power
constructor
A new instance of Power.
- #response! ⇒ Object
Constructor Details
#initialize(client: nil, device_ids: [], start_time: nil, end_time: nil) ⇒ Power
Returns a new instance of Power.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/insnergy-api-ruby-client.rb', line 40 def initialize(client: nil, device_ids: [], start_time: nil, end_time: nil) @access_token = client.access_token @user_id = client.user_id @domain = client.domain @device_ids = device_ids @dev_ids = '' device_ids = Array(device_ids) device_ids.each do |ele| @dev_ids += ele @dev_ids += ';' end @start_time = start_time @end_time = end_time @response = nil response! end |
Instance Attribute Details
#device_ids ⇒ Object
Returns the value of attribute device_ids.
37 38 39 |
# File 'lib/insnergy-api-ruby-client.rb', line 37 def device_ids @device_ids end |
#end_time ⇒ Object
Returns the value of attribute end_time.
37 38 39 |
# File 'lib/insnergy-api-ruby-client.rb', line 37 def end_time @end_time end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
38 39 40 |
# File 'lib/insnergy-api-ruby-client.rb', line 38 def response @response end |
#start_time ⇒ Object
Returns the value of attribute start_time.
37 38 39 |
# File 'lib/insnergy-api-ruby-client.rb', line 37 def start_time @start_time end |
Instance Method Details
#response! ⇒ Object
57 58 59 60 61 62 |
# File 'lib/insnergy-api-ruby-client.rb', line 57 def response! parameter = {:params => {:apsystem => "IFA", :email => @user_id, :attr => "dm1mi", :start_time => @start_time, :end_time => @end_time, :dev_ids => @dev_ids}, :Authorization => "Bearer #{@access_token}"} @response = JSON.parse(RestClient.get "#{@domain}/if/3/device/history_ext", parameter) raise "#{response['err']['code']}" unless response['err']['code'] == '0' @response end |