Created
April 12, 2018 13:57
-
-
Save roboli/361851bee36252a4efa7c602749922be to your computer and use it in GitHub Desktop.
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
var DBA_CLIO_URI = 'https://6d821675.ngrok.io/'; | |
var LEAD_GROUP = 51940; | |
function getUrlVars(url) { | |
var vars = [], hash; | |
var hashes = url.slice(window.location.href.indexOf('?') + 1).split('&'); | |
for(var i = 0; i < hashes.length; i++) | |
{ | |
hash = hashes[i].split('='); | |
vars.push(hash[0]); | |
vars[hash[0]] = hash[1]; | |
} | |
return vars; | |
} | |
function checkExperian($) { | |
return function(lead) { | |
return $.post(DBA_CLIO_URI + 'experian-check', lead); | |
}; | |
} | |
function searchLead($) { | |
return function(query) { | |
return $.get(DBA_CLIO_URI + 'leads', query); | |
}; | |
} | |
function createLead($) { | |
return function(lead) { | |
return $.post(DBA_CLIO_URI + 'leads', lead); | |
}; | |
} | |
function updateLead($) { | |
return function(lead) { | |
var dfd = $.Deferred(); | |
$.ajax({ | |
url: DBA_CLIO_URI + 'leads', | |
type: 'PUT', | |
data: lead, | |
success: dfd.resolve, | |
error: dfd.reject | |
}); | |
return dfd.promise(); | |
}; | |
} | |
function confirm($) { | |
return function(leadId, agreed) { | |
return $.post(DBA_CLIO_URI + 'confirm', { | |
lead_id: leadId, | |
agreed: agreed | |
}); | |
}; | |
} | |
function dbaClio($) { | |
return { | |
uri: DBA_CLIO_URI, | |
leadGroup: LEAD_GROUP, | |
checkExperian: checkExperian($), | |
confirm: confirm($), | |
createLead: createLead($), | |
updateLead: updateLead($), | |
searchLead: searchLead($) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment