2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-10-22 15:53:08 -04:00
|
|
|
class ApiKeySerializer < ApplicationSerializer
|
|
|
|
|
|
|
|
attributes :id,
|
2019-10-09 09:24:14 -04:00
|
|
|
:key,
|
2019-12-12 06:45:00 -05:00
|
|
|
:truncated_key,
|
2019-11-05 09:10:23 -05:00
|
|
|
:description,
|
2019-10-09 09:24:14 -04:00
|
|
|
:last_used_at,
|
2019-11-05 09:10:23 -05:00
|
|
|
:created_at,
|
|
|
|
:updated_at,
|
|
|
|
:revoked_at
|
2013-10-22 15:53:08 -04:00
|
|
|
|
|
|
|
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
|
|
|
|
|
|
|
def include_user_id?
|
|
|
|
!object.user_id.nil?
|
|
|
|
end
|
|
|
|
|
2019-12-12 06:45:00 -05:00
|
|
|
def include_key?
|
|
|
|
# Only available when first created. Not stored in db
|
|
|
|
object.key_available?
|
|
|
|
end
|
2013-10-22 15:53:08 -04:00
|
|
|
end
|