hensei-api/app/blueprints/api/v1/phantom_player_blueprint.rb
Justin Edmund de72d21e24 add decline/pending endpoints for phantom claims
- decline_claim action lets assigned user reject assignment
- pending_phantom_claims endpoint for user's pending claims
- with_crew blueprint view for phantom claims context
2025-12-17 18:28:23 -08:00

40 lines
1 KiB
Ruby

# frozen_string_literal: true
module Api
module V1
class PhantomPlayerBlueprint < ApiBlueprint
fields :name, :granblue_id, :notes, :claim_confirmed, :retired, :retired_at, :joined_at
field :claimed do |phantom|
phantom.claimed_by_id.present?
end
view :with_claimed_by do
field :claimed_by do |phantom|
phantom.claimed_by ? UserBlueprint.render_as_hash(phantom.claimed_by, view: :minimal) : nil
end
end
view :with_scores do
include_view :with_claimed_by
field :total_score do |phantom|
phantom.gw_individual_scores.sum(:score)
end
field :score_count do |phantom|
phantom.gw_individual_scores.count
end
end
# Used for pending phantom claims - includes crew info for context
view :with_crew do
include_view :with_claimed_by
field :crew do |phantom|
phantom.crew ? CrewBlueprint.render_as_hash(phantom.crew, view: :minimal) : nil
end
end
end
end
end