about summary refs log tree commit diff
path: root/app/serializers/rest/admin/webhook_event_serializer.rb
blob: fe0ac23f986742de899d5f23ec2c63f5588d0900 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# frozen_string_literal: true

class REST::Admin::WebhookEventSerializer < ActiveModel::Serializer
  def self.serializer_for(model, options)
    case model.class.name
    when 'Account'
      REST::Admin::AccountSerializer
    when 'Report'
      REST::Admin::ReportSerializer
    else
      super
    end
  end

  attributes :event, :created_at

  has_one :virtual_object, key: :object

  def virtual_object
    object.object
  end

  def event
    object.type
  end
end