2020-02-10 19:09:06 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module API
|
|
|
|
module Entities
|
|
|
|
class Event < Grape::Entity
|
2020-08-19 05:09:58 -04:00
|
|
|
expose :id
|
2020-02-10 19:09:06 -05:00
|
|
|
expose :project_id, :action_name
|
|
|
|
expose :target_id, :target_iid, :target_type, :author_id
|
|
|
|
expose :target_title
|
|
|
|
expose :created_at
|
|
|
|
expose :note, using: Entities::Note, if: ->(event, options) { event.note? }
|
|
|
|
expose :author, using: Entities::UserBasic, if: ->(event, options) { event.author }
|
2020-03-24 08:09:42 -04:00
|
|
|
expose :wiki_page, using: Entities::WikiPageBasic, if: ->(event, _options) { event.wiki_page? }
|
2020-02-10 19:09:06 -05:00
|
|
|
|
|
|
|
expose :push_event_payload,
|
|
|
|
as: :push_data,
|
|
|
|
using: Entities::PushEventPayload,
|
|
|
|
if: -> (event, _) { event.push_action? }
|
|
|
|
|
|
|
|
expose :author_username do |event, options|
|
|
|
|
event.author&.username
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|