diff --git a/app/controllers/spree/api/stock_transfers_controller.rb b/app/controllers/spree/api/stock_transfers_controller.rb index f57d501..2651c30 100644 --- a/app/controllers/spree/api/stock_transfers_controller.rb +++ b/app/controllers/spree/api/stock_transfers_controller.rb @@ -1,6 +1,8 @@ module Spree module Api class StockTransfersController < Spree::Api::BaseController + helper 'solidus_stock_transfers/api' + def receive authorize! :update, TransferItem @stock_transfer = Spree::StockTransfer.accessible_by(current_ability, :update).find_by!(number: params[:id]) diff --git a/app/controllers/spree/api/transfer_items_controller.rb b/app/controllers/spree/api/transfer_items_controller.rb index af0f9e7..d2d9599 100644 --- a/app/controllers/spree/api/transfer_items_controller.rb +++ b/app/controllers/spree/api/transfer_items_controller.rb @@ -1,6 +1,8 @@ module Spree module Api class TransferItemsController < Spree::Api::BaseController + helper 'solidus_stock_transfers/api' + def create authorize! :create, TransferItem stock_transfer = Spree::StockTransfer.accessible_by(current_ability, :update).find_by(number: params[:stock_transfer_id]) @@ -37,6 +39,10 @@ def destroy def transfer_item_params params.require(:transfer_item).permit(permitted_transfer_item_attributes) end + + def permitted_transfer_item_attributes + [:variant_id, :expected_quantity, :received_quantity] + end end end end diff --git a/app/helpers/solidus_stock_transfers/api_helper.rb b/app/helpers/solidus_stock_transfers/api_helper.rb new file mode 100644 index 0000000..017e7dd --- /dev/null +++ b/app/helpers/solidus_stock_transfers/api_helper.rb @@ -0,0 +1,12 @@ +module SolidusStockTransfers + module ApiHelper + mattr_accessor :stock_transfer_attributes + @@stock_transfer_attributes = [:id, :number] + + mattr_accessor :transfer_item_attributes + @@transfer_item_attributes = [:id, :expected_quantity, :received_quantity] + + mattr_accessor :transfer_item_variant_attributes + @@transfer_item_variant_attributes = [] + end +end