Sha256: 9ce99347fbe388174665c323f3508717d22a0a95713a52f59802217428735da2

Contents?: true

Size: 715 Bytes

Versions: 36

Compression:

Stored size: 715 Bytes

Contents

module Spree
  module Api
    module V1
      class PromotionsController < Spree::Api::BaseController
        before_action :requires_admin
        before_action :load_promotion

        def show
          if @promotion
            respond_with(@promotion, default_template: :show)
          else
            raise ActiveRecord::RecordNotFound
          end
        end

        private 
          def requires_admin
            return if @current_user_roles.include?("admin")
            unauthorized and return
          end

          def load_promotion
            @promotion = Spree::Promotion.find_by_id(params[:id]) || Spree::Promotion.with_coupon_code(params[:id])
          end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
goca-spree-api-3.1.14.rails.5.0 app/controllers/spree/api/v1/promotions_controller.rb
goca-spree-api-3.1.15.rails.5.0 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.9 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.14 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.8 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.13 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.7 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.12 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.6 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.11 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.10 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.5 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.9 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.4 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.8 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.7 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.3 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.2.2 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.3.0.rc2 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.1.6 app/controllers/spree/api/v1/promotions_controller.rb