Created
July 29, 2015 01:34
-
-
Save calderonroberto/2b8a05825d2c6f17d7fa to your computer and use it in GitHub Desktop.
Example using the stsplatform ruby library.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Require the stsplatform gem. Make sure to install it | |
# To install from source run: "bundle exec rake install" | |
# to install from RubyGems run : "gem install stsplatform" | |
require 'stsplatform' | |
# A sensor to use for this example. We will use | |
SENSOR_NAME = 'calderonroberto.demo' | |
# First, create a client that will handle all the REST calls | |
c = STSPlatform::Client.new() | |
# Create a sensor object, that uses the client: | |
s = STSPlatform::Sensors.new(c, SENSOR_NAME) | |
# Print the sensor object: | |
res = s.get() | |
puts res.data | |
puts res.code | |
# To acccess data from a sensor create a data object that uses the sensor object | |
d = STSPlatform::Data.new(s) | |
# Print the last data point. Do a get request on the data resource, passing | |
# a parameter: "beforeE", according to: | |
# http://wotkit.readthedocs.org/en/latest/api_v1/api_sensor_data.html#raw-data-retrieval | |
res = d.get({beforeE:1}) | |
puts res.data | |
puts res.code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment