Class: Attio::Webhooks::Event
- Inherits:
-
Object
- Object
- Attio::Webhooks::Event
- Defined in:
- lib/attio/webhooks.rb
Overview
Represents a webhook event
Instance Attribute Summary collapse
- #created_at ⇒ Object readonly
- #data ⇒ Object readonly
- #id ⇒ Object readonly
- #raw ⇒ Object readonly
- #type ⇒ Object readonly
- #workspace_id ⇒ Object readonly
Instance Method Summary collapse
-
#dig(*path) ⇒ Object
Get nested data value.
-
#initialize(payload) ⇒ Event
constructor
A new instance of Event.
-
#is?(type) ⇒ Boolean
Check if event is of a specific type.
Constructor Details
#initialize(payload) ⇒ Event
Returns a new instance of Event.
146 147 148 149 150 151 152 153 |
# File 'lib/attio/webhooks.rb', line 146 def initialize(payload) @raw = payload @id = payload["id"] @type = payload["type"] @created_at = Time.parse(payload["created_at"]) if payload["created_at"] @data = payload["data"] || {} @workspace_id = payload["workspace_id"] end |
Instance Attribute Details
#created_at ⇒ Object (readonly)
144 145 146 |
# File 'lib/attio/webhooks.rb', line 144 def created_at @created_at end |
#data ⇒ Object (readonly)
144 145 146 |
# File 'lib/attio/webhooks.rb', line 144 def data @data end |
#id ⇒ Object (readonly)
144 145 146 |
# File 'lib/attio/webhooks.rb', line 144 def id @id end |
#raw ⇒ Object (readonly)
144 145 146 |
# File 'lib/attio/webhooks.rb', line 144 def raw @raw end |
#type ⇒ Object (readonly)
144 145 146 |
# File 'lib/attio/webhooks.rb', line 144 def type @type end |
#workspace_id ⇒ Object (readonly)
144 145 146 |
# File 'lib/attio/webhooks.rb', line 144 def workspace_id @workspace_id end |
Instance Method Details
#dig(*path) ⇒ Object
Get nested data value
167 168 169 |
# File 'lib/attio/webhooks.rb', line 167 def dig(*path) @data.dig(*path) end |
#is?(type) ⇒ Boolean
Check if event is of a specific type
159 160 161 |
# File 'lib/attio/webhooks.rb', line 159 def is?(type) @type == type end |