Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jordanwalsh23/xero-node
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Walsh committed Mar 7, 2017
2 parents 03d0052 + e2c8efc commit 8e76123
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ _.extend(Application.prototype, {
this.oa[method](url, this.options.accessToken, this.options.accessSecret, { xml: body }, function(err, data, res) {

if (err && data && data.indexOf('oauth_problem') >= 0) {
var dataParts = qs.parse(data);
var errObj = { statusCode: err.statusCode, data: dataParts };
var errObj = new Error(method.toUpperCase() + ' call failed with: ' + err.statusCode);
errObj.data = qs.parse(data);
deferred.reject(errObj);
callback && callback(errObj);
return;
Expand All @@ -125,11 +125,12 @@ _.extend(Application.prototype, {
self.xml2js(data)
.then(function(obj) {
if (err) {
var errObj = { statusCode: err.statusCode };
var exception = "";
if (obj.ApiException)
errObj.exception = obj.ApiException;
exception = obj.ApiException;
else if (obj.Response.ErrorNumber)
errObj.exception = obj.Response;
exception = obj.Response;
var errObj = new Error(method.toUpperCase() + 'call failed with: ' + err.statusCode + ' and exception: ' + JSON.stringify(exception, null, 2));
deferred.reject(errObj);
callback && callback(errObj);
} else {
Expand Down Expand Up @@ -172,15 +173,15 @@ _.extend(Application.prototype, {
return deferred.resolve();
}
if (err && data && data.indexOf('oauth_problem') >= 0) {
var dataParts = qs.parse(data);
var errObj = { statusCode: err.statusCode, data: dataParts };
var errObj = new Error('DELETE call failed with: ' + err.statusCode);
errObj.data = qs.parse(data);
deferred.reject(errObj);
callback && callback(errObj);
return;
}

if (err) {
var errObj = { statusCode: err.statusCode, exception: obj.ApiException };
var errObj = new Error('DELETE call failed with: ' + err.statusCode + ' and message: ' + err.data);
deferred.reject(errObj);
callback && callback(errObj);
return;
Expand Down Expand Up @@ -264,7 +265,8 @@ _.extend(Application.prototype, {
else
dataParts = data;

var errObj = { statusCode: err.statusCode, data: dataParts };
var errObj = new Error('GET call failed with: ' + err.statusCode);
errObj.data = dataParts;
deferred.reject(errObj);
callback && callback(errObj);
return;
Expand All @@ -274,7 +276,7 @@ _.extend(Application.prototype, {
.then(function(obj) {
var ret = { response: obj.Response, res: res };
if (err) {
var errObj = { statusCode: err.statusCode, exception: obj.ApiException };
var errObj = new Error('GET call failed with: ' + err.statusCode + ' and exception: ' + JSON.stringify(obj.ApiException, null, 2));
deferred.reject(errObj);
callback && callback(errObj);
return;
Expand Down
4 changes: 2 additions & 2 deletions test/accountingtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ describe('regression tests', function() {
})
})

describe('taxrates', function() {

describe.skip('taxrates', function() {
it('gets tax rates', function(done) {
this.timeout(10000);
currentApp.core.taxrates.getTaxRates()
.then(function(taxRates) {
// This test requires that some tax rates are set up in the targeted company
expect(taxRates).to.have.length.greaterThan(0);
_.each(taxRates, function(taxRate) {
expect(taxRate.Name).to.not.equal("");
Expand Down

0 comments on commit 8e76123

Please sign in to comment.