Sha256: 14f9005f4a305d177b12018fe3d876068e88c8bfe67b422b093685ca59e154e2
Contents?: true
Size: 1.08 KB
Versions: 8
Compression:
Stored size: 1.08 KB
Contents
module Spree module Api class ShipmentsController < Spree::Api::BaseController respond_to :json before_filter :find_order before_filter :find_and_update_shipment, :only => [:ship, :ready] def ready authorize! :read, Shipment unless @shipment.ready? if @shipment.can_ready? @shipment.ready! else render "spree/api/shipments/cannot_ready_shipment", :status => 422 and return end end respond_with(@shipment, :default_template => :show) end def ship authorize! :read, Shipment unless @shipment.shipped? @shipment.ship! end respond_with(@shipment, :default_template => :show) end private def find_order @order = Spree::Order.find_by_number!(params[:order_id]) authorize! :read, @order end def find_and_update_shipment @shipment = @order.shipments.find_by_number!(params[:id]) @shipment.update_attributes(params[:shipment]) @shipment.reload end end end end
Version data entries
8 entries across 8 versions & 2 rubygems