Skip to content

Commit

Permalink
Don't decode CSV results
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
tyscorp committed Dec 19, 2016
1 parent 36bb0e3 commit 200e84c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
13 changes: 3 additions & 10 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const request = require('request');
const tls = require('tls');
const parser = require('xml2json');
const Type = require('./types');
const iconv = require('iconv-lite');

Promise.promisifyAll(request);

Expand All @@ -22,10 +21,6 @@ function getMetadata(data) {
return data[_.keys(data)[0]].ResponseMetadata;
}

function hasNext(result) {

}

class AmazonMwsClient {
/**
* Constructor for the main MWS client interface used to make api calls and
Expand All @@ -47,7 +42,8 @@ class AmazonMwsClient {
max_backoff: 10000,
max_attempts: Infinity,
attempt: -1,
contentType: 'application/x-www-form-urlencoded'
contentType: 'application/x-www-form-urlencoded',
parseCSVResult: (data) => Promise.resolve(data)
}
});

Expand Down Expand Up @@ -135,10 +131,7 @@ class AmazonMwsClient {
const body = response.body;

if (body.slice(0, 5) !== '<?xml') {
const result = iconv.decode(new Buffer(body), 'iso-8859-1');
const metadata = null;

return { result, metadata };
return meta.parseCSVResult(result).then((result) => ({ result, metadata: null }));
}

const data = JSON.parse(parser.toJson(body));
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"dependencies": {
"bluebird": "^3.4.4",
"iconv-lite": "^0.4.13",
"lodash": "^4.17.0",
"request": "^2.79.0",
"xml": "^1.0.1",
Expand Down

1 comment on commit 200e84c

@dciccale
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.