elyngved/ruby-mws — pull request #4 by alexdowad (2012-10-11 14:41:40+00:00)
Title: Add support for Inventory Feed API (via new Inventory#update_inventory_supply method)

(Development of this patch was funded by Sam Hamilton of Mad Jungle. It was done for Sam's web site, but he gave me permission to donate the code back to ruby-mws so others can benefit from it. Thanks, Sam!)

This PR adds support for the Inventory Feeds API, so users of ruby-mws can update the inventory stock levels for their Amazon MWS products.

Using the Feeds API is a bit different from the other APIs. Most of the others just require a single HTTP request, but the Feeds API requires a series of related requests; first to submit a "feed" or XML document, then to check whether Amazon is finished processing the "feed", then to check whether Amazon encountered any errors while processing the "feed".

This means that the code for the new method is rather long compared to the other existing ones. If support for more of the Feeds APIs was desired, a lot of this code could be factored out into a common method. But for now, this is the first one.

The Feeds API requires a "Content-MD5" header be used on the HTTP POST request, so I added some code to MWS::API::Base which can compute and add the needed header. I think it might be useful for access to more of the Amazon MWS API in the future.