module Helium::Client::HeliumScripts
Public Instance Methods
create_library(name, file_content)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 20 def create_library(name, file_content) contents = Base64.strict_encode64(file_content) Library.create({ name: name , contents: contents }, client: self) end
create_package(script, libraries = [], name = nil)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 41 def create_package(script, libraries = [], name = nil) library_rels = Array(libraries).map do |lib| { id: lib.id, type: 'library' } end body = { data: { attributes: { name: name }, type: 'package', relationships: { script: { data: { id: script.id, type: 'script' } }, library: { data: library_rels } } } } response = post('/package', body: body) resource_data = JSON.parse(response.body)["data"] Package.new(client: self, params: resource_data) end
create_script(name, file_content)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 7 def create_script(name, file_content) contents = Base64.strict_encode64(file_content) Script.create({ name: name , contents: contents }, client: self) end
create_sensor_package(sensor, package)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 78 def create_sensor_package(sensor, package) body = { data: { type: 'sensor-package', relationships: { package: { data: { id: package.id, type: 'package' } }, sensor: { data: { id: sensor.id, type: 'sensor' } } } } } response = post('/sensor-package', body: body) resource_data = JSON.parse(response.body)["data"] SensorPackage.new(client: self, params: resource_data) end
libraries()
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 25 def libraries Library.all(client: self) end
library(id)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 29 def library(id) Library.find(id, client: self) end
package(id)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 37 def package(id) Package.find(id, client: self) end
packages()
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 33 def packages Package.all(client: self) end
script(id)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 16 def script(id) Script.find(id, client: self) end
scripts()
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 12 def scripts Script.all(client: self) end
sensor_package(id)
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 74 def sensor_package(id) SensorPackage.find(id, client: self) end
sensor_packages()
click to toggle source
# File lib/helium/client/helium_scripts.rb, line 70 def sensor_packages SensorPackage.all(client: self) end