Class: Integral::Webhook::Event

Inherits:
Object
  • Object
show all
Defined in:
app/models/integral/webhook/event.rb

Overview

An event instance which a Webhook::Endpoint might be listening too, for example a post publication, creation or deletion

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_name, payload = {}) ⇒ Event

Returns a new instance of Event.



8
9
10
11
# File 'app/models/integral/webhook/event.rb', line 8

def initialize(event_name, payload = {})
  @event_name = event_name
  @payload = payload
end

Instance Attribute Details

#event_nameObject (readonly)

Returns the value of attribute event_name.



6
7
8
# File 'app/models/integral/webhook/event.rb', line 6

def event_name
  @event_name
end

#payloadObject (readonly)

Returns the value of attribute payload.



6
7
8
# File 'app/models/integral/webhook/event.rb', line 6

def payload
  @payload
end

Instance Method Details

#as_json(*_args) ⇒ Object

Adds the event_name to the JSON representation



14
15
16
17
# File 'app/models/integral/webhook/event.rb', line 14

def as_json(*_args)
  payload[:event_name] = event_name
  payload
end