Class: AlsoEnergy::HardWare

Inherits:
Object
  • Object
show all
Includes:
APIConnection, HashWrangler
Defined in:
lib/also_energy/hardware.rb

Instance Method Summary collapse

Methods included from APIConnection

#connection

Methods included from HashWrangler

#find_in_hash

Constructor Details

#initialize(params = {}) ⇒ HardWare

Returns a new instance of HardWare.



18
19
20
# File 'lib/also_energy/hardware.rb', line 18

def initialize(params = {})
  super(params)
end

Instance Method Details

#get_bin_data(period_start, period_end, bin_size, query_blob) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/also_energy/hardware.rb', line 22

def get_bin_data(period_start, period_end, bin_size, query_blob)
  message = {
              'als:sessionID' => session_id,
              'als:fromLocal' => period_start,
              'als:toLocal' => period_end,
              'als:binSize' => bin_size,
              'als:Fields' => query_blob
            }
  response = find_in_hash(:data_set, (connection.call(:get_bin_data, message: message).body))
  response.nil? ? (fail QueryError, 'Query Failed!') : response
end