claims_controller.rb 669 B

12345678910111213141516171819202122232425
  1. # frozen_string_literal: true
  2. class Api::V1::Crypto::Keys::ClaimsController < Api::BaseController
  3. before_action -> { doorkeeper_authorize! :crypto }
  4. before_action :require_user!
  5. before_action :set_claim_results
  6. def create
  7. render json: @claim_results, each_serializer: REST::Keys::ClaimResultSerializer
  8. end
  9. private
  10. def set_claim_results
  11. @claim_results = devices.filter_map { |device_params| ::Keys::ClaimService.new.call(current_account, device_params[:account_id], device_params[:device_id]) }
  12. end
  13. def resource_params
  14. params.permit(device: [:account_id, :device_id])
  15. end
  16. def devices
  17. Array(resource_params[:device])
  18. end
  19. end