Sha256: d5b68db9f598031aace0f46ef43f6d2e3a1eb8c515d557a0823c56c96eac2807

Contents?: true

Size: 703 Bytes

Versions: 80

Compression:

Stored size: 703 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

80 entries across 80 versions & 1 rubygems

Version Path
spree_api-4.0.9 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.1.15 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.2.7 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.3 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.4.1 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.2.6 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.2 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.4.0 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.4.0.rc2 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.1 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.4.0.rc1 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.0 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.0.rc3 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.0.rc2 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.3.0.rc1 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.2.5 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.1.14 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.0.8 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-4.2.4 app/controllers/spree/api/v1/promotions_controller.rb
spree_api-3.7.14.1 app/controllers/spree/api/v1/promotions_controller.rb