mrjcleaver/freshbooks-javascript-library — Issue #1: Freshbooks Sync calls need making asynchronous
Author: mrjcleaver
Created: 2012-03-08 13:06:54+00:00
State: open

Node waits for no (man), well, IO.

So this call to

node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	**return httpClient.send(requestXML); **

will not wait.

Instead this

node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js:
FreshBooks_Element.prototype.sendRequest = function(content,methodName){
this.lastError = "";
var requestXML = this.requestEnvelope(content,methodName);
return httpClient.send(requestXML);
}

needs to be changed to include a callback on the method signature and to pass that callback down to httpClient.send:

FreshBooks_Element.prototype.sendRequest = function(content,methodName, callback){
this.lastError = "";
var requestXML = this.requestEnvelope(content,methodName);
httpClient.send(requestXML, callback);
}

This affects Element.js, BaseInvoice and Invoice:

martincleaversmbp:nodeTimelogServerToFreshbooks martincleaver$ grep -C4 -i -r sendRequest node_modules/freshbooks-javascript-library/library/FreshBooks/*.js

--
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-FreshBooks_Element.prototype.create = function(){
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var content = "";
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	content = this.internalPrepareCreate(content);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js:	var responseXML = this.sendRequest(content,"create");
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	this.internalCreate(responseStatus,responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	return responseStatus;
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-}
--
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-FreshBooks_Element.prototype.update = function (){
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var content = "";
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	content = this.internalPrepareUpdate(content);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js:	var responseXML = this.sendRequest(content,"update");
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	this.internalUpdate(responseStatus,responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	return responseStatus;
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-}
--
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-FreshBooks_Element.prototype.get = function(id){
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var content = "";
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	content = this.internalPrepareGet(id,content);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js:	var responseXML = this.sendRequest(content,"get");
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	this.internalGet(responseStatus,responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	return responseStatus;
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-}
--
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-FreshBooks_Element.prototype.del = function(){
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var content = "";
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	content = this.internalPrepareDelete(content);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js:	var responseXML = this.sendRequest(content,"delete");
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	this.internalDelete(responseStatus,responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	return responseStatus;
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-}
--
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-FreshBooks_Element.prototype.listing = function(page,perPage,filters){
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var content = this.getTagXML("page",page) + this.getTagXML("per_page",perPage);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	content = content + this.internalPrepareListing(filters,content);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js:	var responseXML = this.sendRequest(content,"list");
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-	return this.internalListing(responseStatus,responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-}
node_modules/freshbooks-javascript-library/library/FreshBooks/Element.js-/**
--
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-* send invoice by snail mail
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-FreshBooks_Invoice.prototype.sendBySnailMail = function(){
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-	var content = this.getTagXML("invoice_id",this.invoiceId);
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js:	var responseXML = this.sendRequest(content,"sendBySnailMail");
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-	return responseStatus;
node_modules/freshbooks-javascript-library/library/FreshBooks/Invoice.js-}
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-*/
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-FreshBooks_BaseInvoice.prototype.sendByEmail = function(){
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-	var content = "";
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-	content = this.internalPrepareSendByEmail(content);
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js:	var responseXML = this.sendRequest(content,"sendByEmail");
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-	var responseStatus = this.processResponse(responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-	this.internalSendByEmail(responseStatus,responseXML);
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-	return responseStatus;
node_modules/freshbooks-javascript-library/library/FreshBooks/BaseInvoice.js-}
--