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/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'); 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",