Class: Workarea::Api::Storefront::GiftCardsController

Inherits:
Api::Storefront::ApplicationController
  • Object
show all
Defined in:
app/controllers/workarea/api/storefront/gift_cards_controller.rb

Instance Method Summary collapse

Instance Method Details

#balanceObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/workarea/api/storefront/gift_cards_controller.rb', line 6

def balance
  email = params.fetch(:email, nil)
  token = params.fetch(:token, nil)

  if email.present? && token.present?
    @gift_card = Payment::GiftCard.find_by_token_and_email(token, email)
  end

  if @gift_card.blank?
    raise Mongoid::Errors::DocumentNotFound.new(
      Payment::GiftCard,
      email: email,
      token: token
    )
  end
end