lib/ruby-mws/api/inventory.rb
# Takes a hash of SKUs -> quantities
# Returns true if all the products were updated successfully
# Otherwise raises an exception
Takes a hash of SKUs -> quantities
Returns true if all the products were updated successfully
Otherwise raises an exception
Takes a hash of SKUs - > quantities Returns true if all the products were updated successfully Otherwise raises an exception
def update_inventory_supply(merchant_id, hash)
        xml     = ""
        builder = Builder::XmlMarkup.new(:indent => 2, :target => xml)
        builder.instruct! 
        builder.AmazonEnvelope(:"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", :"xsi:noNamespaceSchemaLocation" => "amzn-envelope.xsd") do |env|
          env.Header do |head|
            head.DocumentVersion('1.01')
            head.MerchantIdentifier(merchant_id)
          end
          env.MessageType('Inventory')
          i = 0
          hash.each do |sku,quantity|
            env.Message do |msg|
              msg.MessageID(i += 1)
              msg.OperationType('Update')
              msg.Inventory do |inv|
                inv.SKU(sku)
                inv.Quantity(quantity)
              end
            end
          end
        end
        submit_feed('_POST_INVENTORY_AVAILABILITY_DATA_', xml)
      end
def update_inventory_supply ( merchant_id , hash ) xml = "" builder = Builder :: XmlMarkup . new ( :indent => 2 , :target => xml ) builder . instruct! builder . AmazonEnvelope ( :" xmlns:xsi " => "http://www.w3.org/2001/XMLSchema-instance" , :" xsi:noNamespaceSchemaLocation " => "amzn-envelope.xsd" ) do | env | env . Header do | head | head . DocumentVersion ( '1.01' ) head . MerchantIdentifier ( merchant_id ) end env . MessageType ( 'Inventory' ) i = 0 hash . each do | sku , quantity | env . Message do | msg | msg . MessageID ( i += 1 ) msg . OperationType ( 'Update' ) msg . Inventory do | inv | inv . SKU ( sku ) inv . Quantity ( quantity ) end end end end submit_feed ( '_POST_INVENTORY_AVAILABILITY_DATA_' , xml ) end
Takes a hash of SKUs -> quantities
Returns true if all the products were updated successfully
Otherwise raises an exception
Takes a hash of SKUs - > quantities Returns true if all the products were updated successfully Otherwise raises an exception
# updating inventory is done by sending an XML "feed" to Amazon # as of this writing, XML schema docs are available at: # https://images-na.ssl-images-amazon.com/images/G/01/rainier/help/XML_Documentation_Intl.pdf # <?xml version="1.0" encoding="UTF-8"?>
merchant_id
<not_specific>
hash
<not_specific>