Class: Ckeditor::Webhook::Event
- Inherits:
-
Object
- Object
- Ckeditor::Webhook::Event
- Defined in:
- lib/ckeditor/webhook/event.rb
Constant Summary collapse
- PROPERTIES =
%i[event environment_id payload sent_at]
Instance Method Summary collapse
- #environment_id ⇒ Object
-
#id ⇒ Object
Returns a virtual event id for idempotency.
-
#initialize(payload) ⇒ Event
constructor
A new instance of Event.
- #payload ⇒ Object
- #sent_at ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(payload) ⇒ Event
Returns a new instance of Event.
16 17 18 19 20 21 22 |
# File 'lib/ckeditor/webhook/event.rb', line 16 def initialize(payload) raise InvalidPayload.new( "Expected a hash with :#{PROPERTIES.join(", :")} keys" ) unless PROPERTIES.all? { |s| payload.key? s } @payload = payload end |
Instance Method Details
#environment_id ⇒ Object
24 25 26 |
# File 'lib/ckeditor/webhook/event.rb', line 24 def environment_id @payload[:environment_id] end |
#id ⇒ Object
Returns a virtual event id for idempotency.
29 30 31 |
# File 'lib/ckeditor/webhook/event.rb', line 29 def id Digest::SHA2.hexdigest @payload.to_json end |
#payload ⇒ Object
33 34 35 |
# File 'lib/ckeditor/webhook/event.rb', line 33 def payload @payload[:payload] end |
#sent_at ⇒ Object
37 38 39 |
# File 'lib/ckeditor/webhook/event.rb', line 37 def sent_at ::Time.parse @payload[:sent_at] end |
#type ⇒ Object
41 42 43 |
# File 'lib/ckeditor/webhook/event.rb', line 41 def type @payload[:event] end |