Class: SamsaraSDK::Event
- Inherits:
-
Object
- Object
- SamsaraSDK::Event
- Defined in:
- lib/samsara_sdk/event.rb
Overview
Contains methods for event manipulation.
Class Method Summary collapse
-
.enrich(event) ⇒ Hash
Enriches missing event properties with ones from config.
-
.validate(event) ⇒ Hash
Validates event to conform Ingestion API requirements.
Class Method Details
.enrich(event) ⇒ Hash
Enriches missing event properties with ones from config.
34 35 36 37 38 |
# 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.) event end |
.validate(event) ⇒ Hash
Validates event to conform Ingestion API requirements.
45 46 47 48 49 50 51 52 |
# 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 |