Class: Zaikio::Webhooks::Event
- Inherits:
-
Object
- Object
- Zaikio::Webhooks::Event
- Extended by:
- Forwardable
- Defined in:
- lib/zaikio/webhooks/event.rb
Instance Attribute Summary collapse
-
#client_name ⇒ Object
readonly
Returns the value of attribute client_name.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #created_at ⇒ Object
-
#initialize(event_data) ⇒ Event
constructor
A new instance of Event.
- #received_at ⇒ Object
- #subject_id ⇒ Object
- #subject_type ⇒ Object
Constructor Details
#initialize(event_data) ⇒ Event
Returns a new instance of Event.
12 13 14 15 16 17 18 19 20 |
# File 'lib/zaikio/webhooks/event.rb', line 12 def initialize(event_data) event_data = event_data.to_h.stringify_keys event_data.each do |key, value| instance_variable_set("@#{key}", value) end @data = event_data end |
Instance Attribute Details
#client_name ⇒ Object (readonly)
Returns the value of attribute client_name.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def client_name @client_name end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def id @id end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def link @link end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def name @name end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def payload @payload end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
8 9 10 |
# File 'lib/zaikio/webhooks/event.rb', line 8 def version @version end |
Instance Method Details
#==(other) ⇒ Object
38 39 40 |
# File 'lib/zaikio/webhooks/event.rb', line 38 def ==(other) data == other.data end |
#created_at ⇒ Object
22 23 24 |
# File 'lib/zaikio/webhooks/event.rb', line 22 def created_at DateTime.parse(data["timestamp"]) end |
#received_at ⇒ Object
26 27 28 |
# File 'lib/zaikio/webhooks/event.rb', line 26 def received_at DateTime.parse(data["received_at"]) end |
#subject_id ⇒ Object
30 31 32 |
# File 'lib/zaikio/webhooks/event.rb', line 30 def subject_id data["subject"].split("/").last end |
#subject_type ⇒ Object
34 35 36 |
# File 'lib/zaikio/webhooks/event.rb', line 34 def subject_type data["subject"].split("/").first == "Org" ? "Organization" : "Person" end |