Sha256: 005a8bab4fe39ef24e107da3bca5f80d4f767631c14f20c79ffd60ab8ee62fea

Contents?: true

Size: 1 KB

Versions: 9

Compression:

Stored size: 1 KB

Contents

module Spree
  module Api
    module V1
      class ZonesController < Spree::Api::V1::BaseController
        def index
          @zones = Zone.order('name ASC')
        end

        def show
          zone
        end

        def create
          authorize! :create, Zone
          @zone = Zone.new(map_nested_attributes_keys(Spree::Zone, params[:zone]))
          if @zone.save
            render :show, :status => 201
          else
            invalid_resource!(@zone)
          end
        end

        def update
          authorize! :update, Zone
          if zone.update_attributes(map_nested_attributes_keys(Spree::Zone, params[:zone]))
            render :show, :status => 200
          else
            invalid_resource!(@zone)
          end
        end

        def destroy
          authorize! :delete, Zone
          zone.destroy
          render :text => nil, :status => 200
        end

        private
        def zone
          @zone ||= Spree::Zone.find(params[:id])
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spree_api-1.1.6 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.1.5 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.1.4 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.2.0 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.2.0.rc2 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.2.0.rc1 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.1.3 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.1.2 app/controllers/spree/api/v1/zones_controller.rb
spree_api-1.1.2.rc1 app/controllers/spree/api/v1/zones_controller.rb