require 'sanitize'
class ApiPosaCardsController < ApiController
  before_filter :api_signed_in_user, :only => [:claim]
  before_filter :posa_http_basic_auth, :only => [:activate]

  #before_filter :lookup_review_summary, :only => [:details]
  #before_filter :lookup_review, :only => [:update, :delete, :show]

  respond_to :json

  # Create a review:
  def activate

    @posa_card = PosaCard.find_by_code!(params[:code])

    PosaCard.activate(@posa_card, @retailer)

    if @posa_card.errors.any?
      respond_with_model(@posa_card)
      return
    end
  end

  def claim
    @posa_card = PosaCard.find_by_code!(params[:code])

    @posa_card.claim(current_user)

    if @posa_card.errors.any?
      respond_with_model(@posa_card)
      return
    end
  end

end
