class Ckeditor::Webhook::Event

Constants

PROPERTIES

Public Class Methods

new(payload) click to toggle source

@raise [InvalidPayload] raised if required properties are missing

# 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

Public Instance Methods

environment_id() click to toggle source
# File lib/ckeditor/webhook/event.rb, line 24
def environment_id
  @payload[:environment_id]
end
id() click to toggle source

Returns a virtual event id for idempotency.

# File lib/ckeditor/webhook/event.rb, line 29
def id
  Digest::SHA2.hexdigest @payload.to_json
end
payload() click to toggle source
# File lib/ckeditor/webhook/event.rb, line 33
def payload
  @payload[:payload]
end
sent_at() click to toggle source
# File lib/ckeditor/webhook/event.rb, line 37
def sent_at
  ::Time.parse @payload[:sent_at]
end
type() click to toggle source
# File lib/ckeditor/webhook/event.rb, line 41
def type
  @payload[:event]
end