Module: Helium::Client::Elements
- Included in:
- Helium::Client
- Defined in:
- lib/helium/client/elements.rb
Instance Method Summary collapse
- #element(id) ⇒ Object
- #element_device_configuration(element) ⇒ Object
- #element_timeseries(element, opts = {}) ⇒ Object
- #elements ⇒ Object
Instance Method Details
#element(id) ⇒ Object
8 9 10 |
# File 'lib/helium/client/elements.rb', line 8 def element(id) Element.find(id, client: self) end |
#element_device_configuration(element) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/helium/client/elements.rb', line 12 def element_device_configuration(element) path = "/element/#{element.id}/device-configuration" response = get(path) dc_data = JSON.parse(response.body)["data"] # dc_data is an array, but there will only be one for one return DeviceConfiguration.new(client: self, params: dc_data[0]) end |
#element_timeseries(element, opts = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/helium/client/elements.rb', line 20 def element_timeseries(element, opts = {}) path = "/element/#{element.id}/timeseries" params = { "page[size]" => opts.fetch(:size, nil), "filter[port]" => opts.fetch(:port, nil), "filter[start]" => datetime_to_iso(opts.fetch(:start_time, nil)), "filter[end]" => datetime_to_iso(opts.fetch(:end_time, nil)), "agg[type]" => opts.fetch(:aggtype), "agg[size]" => opts.fetch(:aggsize) }.delete_if { |_key, value| value.to_s.empty? } paginated_get(path, klass: Helium::DataPoint, cursor_klass: Helium::Timeseries, params: params ) end |
#elements ⇒ Object
4 5 6 |
# File 'lib/helium/client/elements.rb', line 4 def elements Element.all(client: self) end |