Class: Spree::Api::V2::Tenant::FreeVoteClaimController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v2/tenant/free_vote_claim_controller.rb

Instance Method Summary collapse

Methods inherited from BaseController

#current_vendor, #render_serialized_payload, #require_tenant, #scope

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/spree/api/v2/tenant/free_vote_claim_controller.rb', line 14

def create
  result = SpreeCmCommissioner::VotingCredits::ClaimFreeVotes.new(
    show: current_show,
    user: spree_current_user,
    tenant_id: MultiTenant.current_tenant_id,
    votable_id: voting_session.id
  ).call

  if result.failure?
    render_error_payload(result.error.to_s)
  elsif result.value.nil?
    head :no_content
  else
    render_serialized_payload { Spree::V2::Tenant::VotingCreditSerializer.new(result.value).serializable_hash }
  end
end

#showObject



8
9
10
11
12
# File 'app/controllers/spree/api/v2/tenant/free_vote_claim_controller.rb', line 8

def show
  load_effective_config_onto_show

  render_serialized_payload { serialize_resource(current_show) }
end