Class: Helium::Timeseries
- Includes:
- Utils
- Defined in:
- lib/helium/timeseries.rb
Instance Method Summary collapse
-
#create(opts = {}) ⇒ DataPoint
Creates a new data point on this timeseries.
Methods included from Utils
Methods inherited from Cursor
Constructor Details
This class inherits a constructor from Helium::Cursor
Instance Method Details
#create(opts = {}) ⇒ DataPoint
Creates a new data point on this timeseries
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/helium/timeseries.rb', line 10 def create(opts = {}) port = opts.fetch(:port) value = opts.fetch(:value) = opts.fetch(:timestamp, DateTime.now) body = { data: { attributes: { port: port, value: value, timestamp: datetime_to_iso() }, type: 'data-point' } } response = @client.post(@path, body: body) resource_data = JSON.parse(response.body)["data"] return DataPoint.new(client: self, params: resource_data) end |