From 0cbe4948d7694c365803f40a2377c1e0ff03205e Mon Sep 17 00:00:00 2001 From: BL Date: Fri, 9 Feb 2018 12:01:22 +0530 Subject: [PATCH 1/2] Added headers in non-xml response --- lib/AmazonMwsResource.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/AmazonMwsResource.js b/lib/AmazonMwsResource.js index 2ed075a..01951c4 100644 --- a/lib/AmazonMwsResource.js +++ b/lib/AmazonMwsResource.js @@ -176,7 +176,15 @@ AmazonMwsResource.prototype = { }) .on('end', function () { debug('response after parsing tab delimited file %o ', data); - return callback(null, data); + response = {}; + response.data = data; + response.Headers = { + 'x-mws-quota-max': res.headers['x-mws-quota-max'] || 'unknown', + 'x-mws-quota-remaining': res.headers['x-mws-quota-remaining'] || 'unknown', + 'x-mws-quota-resetson': res.headers['x-mws-quota-resetson'] || 'unknown', + 'x-mws-timestamp': res.headers['x-mws-timestamp'] + }; + return callback(null, response); }); } } @@ -214,9 +222,12 @@ AmazonMwsResource.prototype = { var ResponseMetadata = {}; var Headers = {}; - //debug('res.headers[content-type]', res.headers['content-type']); + debug('res.headers[content-type]', res.headers['content-type']); if (RESPONSE_CONTENT_TYPE.indexOf(res.headers['content-type'].toLowerCase()) > -1) { - //debug('response.headers', response.headers); + /* + * It should execute for only XML response + */ + // debug('response.headers', response.headers); debug('response Before Process %o ', JSON.stringify(response)); Headers = response.Headers; if (response[requestParamsJSONCopy.Action + 'Response']) { @@ -229,10 +240,12 @@ AmazonMwsResource.prototype = { debug('exception', exception); ResponseMetadata = {}; } + // debug('ResponseMetadata %o ', ResponseMetadata); if (response[requestParamsJSONCopy.Action + 'Result']) { response = response[requestParamsJSONCopy.Action + 'Result']; } + response.ResponseMetadata = ResponseMetadata; response.Headers = Headers; debug('response before %o ', JSON.stringify(response)); processXml(response, 'update'); From 24e7c9ed02aa634111768cc0a3532a8d5b186091 Mon Sep 17 00:00:00 2001 From: BL Date: Fri, 16 Feb 2018 12:29:10 +0530 Subject: [PATCH 2/2] Added throttling details in non-xml response --- CHANGELOG.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 428f6bd..1ed049e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +0.0.15 + - Bug fixed ResponseMetadata (RequestId) in success response + - Added throttling details in non-xml response + 0.0.14 - Clean code - Added typeScript example of reports @@ -11,7 +15,6 @@ - Add support upto NODE 8 - Added ListOrderItems example of Orders - 0.0.13 December 08, 2017 - Add the MWS Version Detail - Additional error & exception handling diff --git a/package.json b/package.json index a01ddb7..f0abfce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "amazon-mws", - "version": "0.0.14", + "version": "0.0.15", "description": "Amazon MWS API wrapper", "keywords": [ "Amazon MWS",