class SamsaraSDK::Event
Contains methods for event manipulation.
Public Class Methods
enrich(event)
click to toggle source
Enriches missing event properties with ones from config.
@param event [Hash] Event
for Ingestion API. @return [Hash] Event
for Ingestion API filled with missing properties.
# File lib/samsara_sdk/event.rb, line 34 def enrich(event) event[:sourceId] = event.fetch(:sourceId, Config.get[:sourceId]) event[:timestamp] = event.fetch(:timestamp, Config.timestamp) event end
validate(event)
click to toggle source
Validates event to conform Ingestion API requirements.
@param event [Hash] Event
. @return [Hash] Passed back event. @raise [SamsaraSDK::EventValidationError] if any option of the given event is invalid.
# File lib/samsara_sdk/event.rb, line 45 def validate(event) @schema.each do |schema_param, schema_value| schema_value.each do |rule_key, rule_value| @rules[rule_key].call(schema_param, event[schema_param], rule_value) end end event end