lib/ruby-mws/api/fulfillment.rb
# Takes a hash of order and item details
# Returns true if the order was acknowledged successfully
# Otherwise raises an exception
Takes a hash of order and item details
Returns true if the order was acknowledged successfully
Otherwise raises an exception
Takes a hash of order and item details Returns true if the order was acknowledged successfully Otherwise raises an exception
def order_acknowledgement(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(@connection.seller_id)
          end
          env.MessageType('OrderAcknowledgement')
          env.Message do |mes|
            mes.MessageID('1')
            mes.OrderAcknowledgement do |oa|
              oa.AmazonOrderID(hash[:amazon_order_id])
              oa.MerchantOrderID(hash[:merchant_order_id]) unless hash[:merchant_order_id].blank?
              oa.StatusCode(hash[:status])
              (hash[:items] || {}).each do |item_code, merchant_item_id|
                oa.Item do |item|
                  item.AmazonOrderItemCode(item_code)
                  item.MerchantOrderItemID(merchant_item_id) unless merchant_item_id.blank?
                end
              end
            end
          end
        end
        submit_feed('_POST_ORDER_ACKNOWLEDGEMENT_DATA_', xml)
      end
def order_acknowledgement ( 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 ( @connection . seller_id ) end env . MessageType ( 'OrderAcknowledgement' ) env . Message do | mes | mes . MessageID ( '1' ) mes . OrderAcknowledgement do | oa | oa . AmazonOrderID ( hash [ :amazon_order_id ] ) oa . MerchantOrderID ( hash [ :merchant_order_id ] ) unless hash [ :merchant_order_id ] . blank? oa . StatusCode ( hash [ :status ] ) ( hash [ :items ] || { } ) . each do | item_code , merchant_item_id | oa . Item do | item | item . AmazonOrderItemCode ( item_code ) item . MerchantOrderItemID ( merchant_item_id ) unless merchant_item_id . blank? end end end end end submit_feed ( '_POST_ORDER_ACKNOWLEDGEMENT_DATA_' , xml ) end
Takes a hash of order and item details
Returns true if the order was acknowledged successfully
Otherwise raises an exception
Takes a hash of order and item details Returns true if the order was acknowledged successfully Otherwise raises an exception
# example use: order_acknowledgement(amazon_order_id: '112-2598432-0713054', merchant_order_id: 336, status: 'Success', items: {'47979057082330' => '438'}) #              order_acknowledgement(amazon_order_id: '112-2598432-0713054', merchant_order_id: 336, status: 'Success') # order acknowledgment 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 # https://images-na.ssl-images-amazon.com/images/G/01/mwsportal/doc/en_US/bde/MWSFeedsApiReference._V372272627_.pdf # <?xml version="1.0" encoding="UTF-8"?>
hash
<not_specific>