Sha256: da0af275dc6da1aaf7462d0038200b8570498ea083fe0027db2369324661b41e

Contents?: true

Size: 963 Bytes

Versions: 17

Compression:

Stored size: 963 Bytes

Contents

module Helium
  class Timeseries < Cursor
    include Helium::Utils

    # Creates a new data point on this timeseries
    # @option opts [String] :port A port for the data point
    # @option opts [String] :value A value for the data point
    # @option opts [DateTime] :timestamp A timestamp for the data point. If not provided, it will default to the current time.
    # @return [DataPoint]
    def create(opts = {})
      port      = opts.fetch(:port)
      value     = opts.fetch(:value)
      timestamp = opts.fetch(:timestamp, DateTime.now)

      body = {
        data: {
          attributes: {
            port:      port,
            value:     value,
            timestamp: datetime_to_iso(timestamp)
          },
          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

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
helium-ruby-0.26.0 lib/helium/timeseries.rb
helium-ruby-0.25.0 lib/helium/timeseries.rb
helium-ruby-0.24.0 lib/helium/timeseries.rb
helium-ruby-0.23.0 lib/helium/timeseries.rb
helium-ruby-0.22.0 lib/helium/timeseries.rb
helium-ruby-0.21.0 lib/helium/timeseries.rb
helium-ruby-0.20.0 lib/helium/timeseries.rb
helium-ruby-0.19.0 lib/helium/timeseries.rb
helium-ruby-0.18.0 lib/helium/timeseries.rb
helium-ruby-0.17.0 lib/helium/timeseries.rb
helium-ruby-0.16.0 lib/helium/timeseries.rb
helium-ruby-0.15.0 lib/helium/timeseries.rb
helium-ruby-0.14.0 lib/helium/timeseries.rb
helium-ruby-0.13.0 lib/helium/timeseries.rb
helium-ruby-0.12.0 lib/helium/timeseries.rb
helium-ruby-0.11.0 lib/helium/timeseries.rb
helium-ruby-0.10.0 lib/helium/timeseries.rb