From 535ed6b1ae590e1db5305a3b0e753df36d32c1f9 Mon Sep 17 00:00:00 2001 From: David Huston Date: Tue, 11 Jun 2013 10:56:40 -0400 Subject: [PATCH] Updated ReadMe, Additions to Products, Bugfixes Bugfixed the feeds.js submit feed request. Added Get My Price for SKU and ASIN to products. --- README.md | 26 +++++++++++++++++++++++++- lib/feeds.js | 4 ++-- lib/products.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c73cb79..8aa9e3b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ mws-js ====== +This is a continuation of the continuation of this code. I have made changes to the +explicit .js files, as I do not use coffee script. I have fixed some of the bugs with +the feed upload, core file, and FBA API requests. Note: I have not made any changes to +the .coffee files in this library. + This is a continuation of the unstable branch of https://github.com/eibbors/mws-js . While having very nice ideas, it was incomplete and a bit buggy. I needed only the products, orders and feeds APIs, so I have no idea what is the status @@ -17,7 +22,25 @@ should work fine and dandy like cotton candy. Usage ===== -Simple example +.js Example +------------- +Fetching a product info: +```javascript +var mws = require('./mws-js'); +client = new mws.products.Client(loginCredentials); + +client.getMatchingProductForId('ASIN', B005ISQ7JC, function(res){ + if (res.error) { + console.error(res.error); + } else if (res.result) { + console.log(res.result); + } +}); + +``` + + +Coffee Script example -------------- Fetching a product info: ``` @@ -32,4 +55,5 @@ client.getMatchingProductForId 'ASIN', ASIN_ID , (res) => ``` + You can have a look at test directory for more examples. \ No newline at end of file diff --git a/lib/feeds.js b/lib/feeds.js index 768fdf4..7c893e9 100644 --- a/lib/feeds.js +++ b/lib/feeds.js @@ -306,12 +306,12 @@ if (purgeReplace == null) { purgeReplace = false; } - req = new requests.GetFeedSubmissionResult({ + req = new requests.SubmitFeed({ FeedType: feedType, MarketplaceIdList: (_ref = marketplaces != null ? marketplaces : this.marketplaceIds) != null ? _ref : [this.marketplaceId], PurgeAndReplace: purgeReplace }, feedBody); - return this.invoke(req, {}, function(res) { + return this.invoke(req, {method:'POST', headers:{'content-type':'text/xml'}}, function(res) { if (typeof cb === 'function') { return cb(res); } diff --git a/lib/products.js b/lib/products.js index cb4bc9a..8faa737 100644 --- a/lib/products.js +++ b/lib/products.js @@ -126,9 +126,29 @@ _Class.__super__.constructor.call(this, MWS_PRODUCTS, 'GetLowestOfferListingsForASIN', [new mws.Param('MarketplaceId', 'Id', true), new enums.ItemCondition('ItemCondition'), new mws.ParamList('ASINList', 'ASIN')], {}, null, init); } + return _Class; + })(mws.Request), + GetMyPriceForSKU: (function(_super) { + + __extends(_Class, _super); + + function _Class(init) { + _Class.__super__.constructor.call(this, MWS_PRODUCTS, 'GetMyPriceForSKU', [new mws.Param('MarketplaceId', 'Id', true), new mws.ParamList('SellerSKUList', 'SellerSKU', true), new enums.ItemCondition('ItemCondition')], {}, null, init); + } + return _Class; })(mws.Request), + GetMyPriceForASIN: (function(_super) { + + __extends(_Class, _super); + + function _Class(init) { + _Class.__super__.constructor.call(this, MWS_PRODUCTS, 'GetMyPriceForASIN', [new mws.Param('MarketplaceId', 'Id', true), new enums.ItemCondition('ItemCondition'), new mws.ParamList('ASINList', 'ASIN')], {}, null, init); + } + + return _Class; + })(mws.Request), GetProductCategoriesForSKU: (function(_super) { __extends(_Class, _super); @@ -258,6 +278,32 @@ }); }; + ProductsClient.prototype.getMyPriceForSKU = function(skus, condition, cb) { + var req, + _this = this; + req = new requests.GetMyPriceForSKU({ + MarketplaceId: this.marketplaceId, + SellerSKUList: skus != null ? skus : [], + ItemCondition: condition != null ? condition : void 0 + }); + return this.invoke(req, {}, function(res) { + return cb(res); + }); + }; + + ProductsClient.prototype.getMyPriceForASIN = function(asins, condition, cb) { + var req, + _this = this; + req = new requests.GetMyPriceForASIN({ + MarketplaceId: this.marketplaceId, + ASINList: asins != null ? asins : [], + ItemCondition: condition != null ? condition : void 0 + }); + return this.invoke(req, {}, function(res) { + return cb(res); + }); + }; + ProductsClient.prototype.getProductCategoriesForSKU = function(sku, cb) { var req, _this = this;