Created
June 27, 2012 19:11
-
-
Save adamstrickland/3006114 to your computer and use it in GitHub Desktop.
sample workflow in js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateLead (lead, _callback) { | |
var _lead = { | |
id: lead.correlationId || generateCorrelationId(), | |
foo: 'foo', | |
bar: 'bar' | |
}; | |
var _respond = function (attrs) { | |
_callback($.extend(attrs, _lead)); //invoke the _callback provided by client | |
}; | |
clarity.inquireAsync(lead, function (_data) { | |
if (_data) { | |
var _response = function (a) { | |
return { | |
accept: a || undefined, | |
data: [_data] | |
}; | |
}; | |
if (_data.creditScore < 400) { | |
_respond(_response(false)); //reject lead | |
} | |
else if (_data.creditScore > 600) { | |
_respond(_response(true)); //accept lead | |
} | |
else { | |
[trans_union, c_l_verify, tele_track]._each(function (provider) { | |
provider.inquireAsync(lead, function (__data) { | |
_response.data.push(__data); | |
if (_response.data.length == 4) { //wait until all 3 have returned | |
_respond(_response); //don't provide an accept; defer decision to client (provenir) | |
} | |
}); | |
}) | |
} | |
} | |
}); | |
}; | |
// invoked using something like: | |
generateLead({ | |
firstName: ' Arthur', | |
lastName: 'Dent', | |
ssn: '123-45-6789', | |
address: { | |
street1: '123 Main St', | |
zip: '12345-0098' | |
} | |
}, function (result) { | |
provenir.queues.inbox.put(result); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment