Skip to content

Commit

Permalink
Merge pull request #66 from bhushankumarl/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Bhushankumar L authored Oct 26, 2018
2 parents b0ddcc4 + 096ac56 commit 1761da3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ node_modules/
.tmp/*
npm-debug.log
npm-debug.log/*
package-lock.json
package-lock.json
response.txt
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
0.0.23
- Bug Fix for Feed Result charset

0.0.22
- Bug Fix Default value for XML parsing
- Add Support for the Subscription APIs, Recommendations API
Expand Down
9 changes: 4 additions & 5 deletions examples/javaScript/feeds/getFeedSubmissionResultCharset.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ var accessKey = process.env.AWS_ACCESS_KEY_ID || 'YOUR_KEY';
var accessSecret = process.env.AWS_SECRET_ACCESS_KEY || 'YOUR_SECRET';

var amazonMws = require('../../../lib/amazon-mws')(accessKey, accessSecret);
var fse = require('fs-extra');

/**
* Use __CHARSET__ to override charset option.;
* This along with __RAW__ do not get written in the request.
* This along with __RAW__ do NOT get written in the request.
* */
function feedRequest() {
var FeedSubmissionId = '10101010XXX';
Expand All @@ -18,14 +17,14 @@ function feedRequest() {
'SellerId': 'SELLER_ID',
'MWSAuthToken': 'MWS_AUTH_TOKEN',
'FeedSubmissionId': FeedSubmissionId,
__CHARSET__: 'latin1'
// __CHARSET__: 'latin1'
__CHARSET__: 'ISO-8859-1'
}, function (error, response) {
if (error) {
console.log('error ', error);
return;
}
fse.writeFileSync('response.txt', response.data);
console.log('Headers', response.Headers);
console.log('response ', JSON.stringify(response));
});
}

Expand Down
8 changes: 2 additions & 6 deletions lib/AmazonMwsResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,7 @@ AmazonMwsResource.prototype = {
debug('Inside user Charset option');
charset = userOptions.userCharset;
try {
/**
* https://github.com/ashtuchkin/iconv-lite/issues/32
*/
var win1251String = iconv.decode(bufferString, 'win1251');
responseString = iconv.encode(win1251String, charset);
responseString = iconv.decode(bufferString, charset);
} catch (Exception) {
debug('Exception iconv ', Exception);
return callback.call(self, new Error.AmazonMwsAPIError({
Expand Down Expand Up @@ -336,7 +332,7 @@ AmazonMwsResource.prototype = {
}
// debug('response', response);
try {
ResponseMetadata = response.ResponseMetadata;
ResponseMetadata = response.ResponseMetadata || {};
} catch (exception) {
debug('exception', exception);
ResponseMetadata = {};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amazon-mws",
"version": "0.0.22",
"version": "0.0.23",
"description": "Amazon MWS API wrapper",
"keywords": [
"Amazon MWS",
Expand Down

0 comments on commit 1761da3

Please sign in to comment.