Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development #66

Merged
merged 2 commits into from
Oct 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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