Sha256: 016623ff3208c5fffbf84c89f59191a0ffc9d1ec78cd42d8833d391bf510189c

Contents?: true

Size: 640 Bytes

Versions: 20

Compression:

Stored size: 640 Bytes

Contents

module Spree
  module Api
    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 && return
      end

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
solidus_api-2.2.2 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.1.1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.0.3 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.4.2 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.0.2 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.4.1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.2.1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.2.0 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.2.0.rc1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.2.0.beta1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.1.0 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.1.0.rc1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.0.1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.1.0.beta1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.0.0 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.4.0 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.0.0.rc1 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.4.0.rc1 app/controllers/spree/api/promotions_controller.rb
solidus_api-2.0.0.beta1 app/controllers/spree/api/promotions_controller.rb
solidus_api-1.4.0.beta1 app/controllers/spree/api/promotions_controller.rb