2016-06-16 01:49:57 +08:00
|
|
|
class AdminWebHookSerializer < ApplicationSerializer
|
|
|
|
attributes :id,
|
|
|
|
:payload_url,
|
|
|
|
:content_type,
|
|
|
|
:last_delivery_status,
|
|
|
|
:secret,
|
|
|
|
:wildcard_web_hook,
|
|
|
|
:verify_certificate,
|
|
|
|
:active,
|
|
|
|
:web_hook_event_types
|
|
|
|
|
|
|
|
has_many :categories, serializer: BasicCategorySerializer, embed: :ids, include: false
|
2018-12-05 17:14:06 +08:00
|
|
|
has_many :tags, key: :tag_names, serializer: TagSerializer, embed: :ids, embed_key: :name, include: false
|
2016-06-16 01:49:57 +08:00
|
|
|
has_many :groups, serializer: BasicGroupSerializer, embed: :ids, include: false
|
|
|
|
|
|
|
|
def web_hook_event_types
|
|
|
|
ActiveModel::ArraySerializer.new(object.web_hook_event_types).as_json
|
|
|
|
end
|
2019-03-21 23:13:09 +08:00
|
|
|
|
|
|
|
def last_delivery_status
|
|
|
|
object.active ? object.last_delivery_status : WebHook.last_delivery_statuses[:disabled]
|
|
|
|
end
|
2016-06-16 01:49:57 +08:00
|
|
|
end
|