Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Commit

Permalink
Fix api helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed Nov 21, 2017
1 parent e338337 commit 2228215
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/spree/api/stock_transfers_controller.rb
Original file line number Diff line number Diff line change
@@ -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])
Expand Down
6 changes: 6 additions & 0 deletions app/controllers/spree/api/transfer_items_controller.rb
Original file line number Diff line number Diff line change
@@ -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])
Expand Down Expand Up @@ -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
12 changes: 12 additions & 0 deletions app/helpers/solidus_stock_transfers/api_helper.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2228215

Please sign in to comment.