Class: SamsaraSDK::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/samsara_sdk/config.rb

Overview

Samsara SDK default configuration and request constants.

Constant Summary collapse

PUBLISHED_TIMESTAMP_HEADER =

Samsara specific HTTP Header

'X-Samsara-publishedTimestamp'.freeze
API_PATH =

Samsara Ingestion API endpoint

'/v1/events'.freeze

Class Method Summary collapse

Class Method Details

.getHash

Get configuration values.

Returns:

  • (Hash)

    Configuration values.



72
73
74
# File 'lib/samsara_sdk/config.rb', line 72

def get
  @values
end

.setup!(input_config) ⇒ Object

Set up configuration. Merges given config with defaults and validates the result.

Parameters:

  • input_config (Hash)

    Input configuration options.

Raises:



64
65
66
67
# File 'lib/samsara_sdk/config.rb', line 64

def setup!(input_config)
  @values = @defaults.merge input_config
  validate @values
end

.timestampInteger

Generates current timestamp.

Returns:

  • (Integer)

    timestamp in milliseconds.



79
80
81
# File 'lib/samsara_sdk/config.rb', line 79

def timestamp
  (Time.now.to_f.round(3) * 1000).to_i
end