Class: Webhooks::EventSerializer

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON
Defined in:
app/models/webhooks/event_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ EventSerializer

Returns a new instance of EventSerializer.



12
13
14
15
16
17
18
19
# File 'app/models/webhooks/event_serializer.rb', line 12

def initialize(request)
  event = request.event

  @id = event.id
  @type = event.event_type
  @event = ActiveSupport::JSON.decode(event.event)
  @created_at = event.created_at.iso8601(6)
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'app/models/webhooks/event_serializer.rb', line 10

def created_at
  @created_at
end

#eventObject (readonly)

Returns the value of attribute event.



9
10
11
# File 'app/models/webhooks/event_serializer.rb', line 9

def event
  @event
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'app/models/webhooks/event_serializer.rb', line 7

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'app/models/webhooks/event_serializer.rb', line 8

def type
  @type
end

Instance Method Details

#attributesObject



21
22
23
24
25
26
27
28
# File 'app/models/webhooks/event_serializer.rb', line 21

def attributes
  {
    'id' => id,
    'type' => type,
    'event' => event,
    'created_at' => created_at,
  }
end