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