'use strict';
var BBPromise = require('bluebird');
var xml2js = require('xml2js');
var OAuth = require('oauth').OAuth;
var crypto = require('crypto');
var _ = require('lodash');
var baseUrl = 'https://api.xero.com/api.xro/2.0';

function XeroConnector(settings) {
  this.settings = settings;
  this.parser = BBPromise.promisifyAll(new xml2js.Parser({
    explicitArray: false,
    ignoreAttrs: false,
    async: true
  }));
  this.auth = BBPromise.promisifyAll(new OAuth(
    null,
    null,
    settings.consumerKey,
    settings.consumerSecret,
    '1.0A',
    null,
    'RSA-SHA1'
  ));

  this.auth._signatureMethod = 'RSA-SHA1';
  this.auth._createSignature = _.bind(function (signatureBase) {
    return crypto.createSign('RSA-SHA1').update(signatureBase).sign(this.settings.privateKey, "base64");
  }, this);
  this.auth._performSecureRequestAsync = BBPromise.promisify(this.auth._performSecureRequest, this.auth);
}

XeroConnector.prototype.get = function (url) {
  return this.request('GET', url);
};

XeroConnector.prototype.request = function (method, path) {
  return this.auth._performSecureRequestAsync(this.settings.consumerKey, this.settings.consumerSecret, method, baseUrl + path, null, null, 'application/xml')
    .bind(this).spread(function (xml) {
      return this.parser.parseStringAsync(xml);
    });
};


module.exports = XeroConnector;

@@ -225,43 +225,156 @@
 0';%0A
-%0Afunction XeroConnector(settings) %7B
+var logger = require('hoist-logger');%0A%0Afunction XeroConnector(settings) %7B%0A  logger.info(%7B%0A    settings: settings%0A  %7D, 'constructed xero-connector');
 %0A  t
@@ -787,16 +787,35 @@
 unction 
+createXeroSignature
 (signatu
@@ -820,24 +820,138 @@
 tureBase) %7B%0A
+    logger.info(%7B%0A      signatureBase: signatureBase,%0A      settings: this.settings%0A    %7D, 'creating signature');%0A
     return c
@@ -978,16 +978,23 @@
 A-SHA1')
+%0A      
 .update(
@@ -1007,16 +1007,23 @@
 ureBase)
+%0A      
 .sign(th
@@ -1221,24 +1221,73 @@
 ion (url) %7B%0A
+  logger.log('inside hoist-connector-xero.get');%0A
   return thi
@@ -1373,16 +1373,111 @@
 path) %7B%0A
+  logger.log(%7B%0A    method: method,%0A    path: path%0A  %7D, 'inside hoist-connector-xero.request');%0A
   return
@@ -1662,24 +1662,99 @@
 ion (xml) %7B%0A
+      logger.log(%7B%0A        xml: xml%0A      %7D, 'got response from request');%0A
       return

add some more logging