Sha256: c9c1ddf156f7efb0d46f804665d0a25636088417930d5f9f64c56ef0e946b322
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
module Helium class Client module Labels def labels Label.all(client: self) end def label(id) Label.find(id, client: self) end def create_label(attributes) Label.create(attributes, client: self) end # TODO incorporate this logic into Helium::Collection def update_label_sensors(label, opts = {}) sensors = opts.fetch(:sensors, []) path = "/label/#{label.id}/relationships/sensor" sensors = Array(sensors) new_sensor_data = sensors.map do |sensor| { id: sensor.id, type: 'sensor' } end body = { data: new_sensor_data } response = patch(path, body: body) sensors_data = JSON.parse(response.body)["data"] # TODO: these come back deflated. need to either inflate at this point or # when needed sensors = sensors_data.map do |sensor_data| Sensor.new(client: self, params: sensor_data) end return sensors end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
helium-ruby-0.23.0 | lib/helium/client/labels.rb |
helium-ruby-0.22.0 | lib/helium/client/labels.rb |
helium-ruby-0.21.0 | lib/helium/client/labels.rb |