Sha256: 71ebbb951559e39a15868f4ae17830a8f0be1c2fdf2d463b05203316627f46e1

Contents?: true

Size: 1.23 KB

Versions: 38

Compression:

Stored size: 1.23 KB

Contents

module Spree
  module Api
    class StoresController < Spree::Api::BaseController

      before_filter :get_store, except: [:index, :create]

      def index
        authorize! :read, Store
        @stores = Store.accessible_by(current_ability, :read).all
        respond_with(@stores)
      end

      def create
        authorize! :create, Store
        @store = Store.new(store_params)
        @store.code = params[:store][:code]
        if @store.save
          respond_with(@store, status: 201, default_template: :show)
        else
          invalid_resource!(@store)
        end
      end

      def update
        authorize! :update, @store
        if @store.update_attributes(store_params)
          respond_with(@store, status: 200, default_template: :show)
        else
          invalid_resource!(@store)
        end
      end

      def show
        authorize! :read, @store
        respond_with(@store)
      end

      def destroy
        authorize! :destroy, @store
        @store.destroy
        respond_with(@store, status: 204)
      end

      private

      def get_store
        @store = Store.find(params[:id])
      end

      def store_params
        params.require(:store).permit(permitted_store_attributes)
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
solidus_api-1.2.3 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.4 app/controllers/spree/api/stores_controller.rb
solidus_api-1.0.7 app/controllers/spree/api/stores_controller.rb
solidus_api-1.0.6 app/controllers/spree/api/stores_controller.rb
solidus_api-1.2.2 app/controllers/spree/api/stores_controller.rb
solidus_api-1.2.1 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.3 app/controllers/spree/api/stores_controller.rb
solidus_api-1.0.5 app/controllers/spree/api/stores_controller.rb
solidus_api-1.2.0 app/controllers/spree/api/stores_controller.rb
solidus_api-1.2.0.rc2 app/controllers/spree/api/stores_controller.rb
solidus_api-1.0.4 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.2 app/controllers/spree/api/stores_controller.rb
solidus_api-1.2.0.rc1 app/controllers/spree/api/stores_controller.rb
solidus_api-1.2.0.beta1 app/controllers/spree/api/stores_controller.rb
solidus_api-1.0.3 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.1 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.0 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.0.pre2 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.0.pre1 app/controllers/spree/api/stores_controller.rb
solidus_api-1.1.0.beta1 app/controllers/spree/api/stores_controller.rb