Class: InstagramConnect::Ingest::Envelope
- Inherits:
-
Struct
- Object
- Struct
- InstagramConnect::Ingest::Envelope
- Defined in:
- lib/instagram_connect/ingest/envelope.rb
Overview
One webhook event, plus the context needed to interpret it: which account it belongs to, which field Meta delivered it under, and when it actually happened on the wire (as opposed to when we got round to storing it).
Constant Summary collapse
- MAX_SECONDS =
Anything outside this is not a timestamp Meta could have sent, and storing it would corrupt every ordering that reads occurred_at.
4_102_444_800
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#config ⇒ Object
Returns the value of attribute config.
-
#entry_id ⇒ Object
Returns the value of attribute entry_id.
-
#event ⇒ Object
Returns the value of attribute event.
-
#event_type ⇒ Object
Returns the value of attribute event_type.
-
#field ⇒ Object
Returns the value of attribute field.
-
#object ⇒ Object
Returns the value of attribute object.
-
#occurred_at ⇒ Object
Returns the value of attribute occurred_at.
Class Method Summary collapse
-
.time_from(millis) ⇒ Object
Meta timestamps are milliseconds since the epoch.
Instance Method Summary collapse
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def account @account end |
#config ⇒ Object
Returns the value of attribute config
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def config @config end |
#entry_id ⇒ Object
Returns the value of attribute entry_id
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def entry_id @entry_id end |
#event ⇒ Object
Returns the value of attribute event
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def event @event end |
#event_type ⇒ Object
Returns the value of attribute event_type
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def event_type @event_type end |
#field ⇒ Object
Returns the value of attribute field
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def field @field end |
#object ⇒ Object
Returns the value of attribute object
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def object @object end |
#occurred_at ⇒ Object
Returns the value of attribute occurred_at
6 7 8 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 6 def occurred_at @occurred_at end |
Class Method Details
.time_from(millis) ⇒ Object
Meta timestamps are milliseconds since the epoch. Ordering off this rather than our own created_at is what stops a delayed webhook batch silently reordering a conversation.
17 18 19 20 21 22 23 24 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 17 def self.time_from(millis) return nil if millis.nil? seconds = millis.to_i / 1000.0 return nil unless seconds.finite? && seconds >= 0 && seconds <= MAX_SECONDS Time.at(seconds).utc end |
Instance Method Details
#dig(*keys) ⇒ Object
26 27 28 |
# File 'lib/instagram_connect/ingest/envelope.rb', line 26 def dig(*keys) event.dig(*keys) end |