Sha256: 751436a09669ad850aed5fd24a67df8404e8b74e7edccb8779f859ae94a5f658

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

module Workarea
  if Plugin.installed?(:api)
    module Api
      module Admin
        class PaymentGiftCardsController < Admin::ApplicationController
          before_action :find_gift_card, except: [:index, :create]

          def index
            @gift_cards = Payment::GiftCard
                          .all
                          .order_by(sort_field => sort_direction)
                          .page(params[:page])

            respond_with gift_cards: @gift_cards
          end

          def show
            respond_with gift_card: @gift_card
          end

          def update
            @gift_card.update_attributes!(params[:gift_card])
            respond_with gift_card: @gift_card
          end

          def create
            @gift_card = Payment::GiftCard.create!(params[:gift_card])
            respond_with(
              { gift_card: @gift_card },
              { status: :created,
              location: payment_gift_card_path(@gift_card) }
            )
          end

          def destroy
            @gift_card.destroy
            head :no_content
          end

          private

          def find_gift_card
            @gift_card = Payment::GiftCard.find(params[:id])
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
workarea-gift_cards-3.4.11 app/controllers/workarea/api/admin/payment_gift_cards_controller.rb
workarea-gift_cards-3.4.10 app/controllers/workarea/api/admin/payment_gift_cards_controller.rb
workarea-gift_cards-3.4.9 app/controllers/workarea/api/admin/payment_gift_cards_controller.rb
workarea-gift_cards-3.4.8 app/controllers/workarea/api/admin/payment_gift_cards_controller.rb
workarea-gift_cards-3.4.7 app/controllers/workarea/api/admin/payment_gift_cards_controller.rb
workarea-gift_cards-3.4.6 app/controllers/workarea/api/admin/payment_gift_cards_controller.rb