mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
🐛Fix Close.io lead query by name
This commit is contained in:
parent
7a49eb4c77
commit
8f16f5f487
1 changed files with 10 additions and 4 deletions
|
@ -343,8 +343,14 @@ function createAddIntercomDataFn(lead, email) {
|
||||||
};
|
};
|
||||||
request.get(options, (error, response, body) => {
|
request.get(options, (error, response, body) => {
|
||||||
if (error) return done(error);
|
if (error) return done(error);
|
||||||
const user = JSON.parse(body);
|
try {
|
||||||
lead.addIntercomUser(email, user);
|
const user = JSON.parse(body);
|
||||||
|
lead.addIntercomUser(email, user);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
console.log(body);
|
||||||
|
}
|
||||||
return done();
|
return done();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -455,7 +461,8 @@ function saveNewLead(lead, done) {
|
||||||
function createUpdateLeadFn(lead) {
|
function createUpdateLeadFn(lead) {
|
||||||
return (done) => {
|
return (done) => {
|
||||||
// console.log('DEBUG: updateLead', lead.name);
|
// console.log('DEBUG: updateLead', lead.name);
|
||||||
const url = `https://${closeIoApiKey}:X@app.close.io/api/v1/lead/?query=name:${encodeURIComponent(lead.name)}`;
|
const query = `name:"${lead.name}"`;
|
||||||
|
const url = `https://${closeIoApiKey}:X@app.close.io/api/v1/lead/?query=${encodeURIComponent(query)}`;
|
||||||
request.get(url, (error, response, body) => {
|
request.get(url, (error, response, body) => {
|
||||||
if (error) return done(error);
|
if (error) return done(error);
|
||||||
try {
|
try {
|
||||||
|
@ -576,7 +583,6 @@ function sendMail(toEmail, leadId, contactId, template, done) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateLeads(leads, done) {
|
function updateLeads(leads, done) {
|
||||||
const tasks = []
|
const tasks = []
|
||||||
for (const name in leads) {
|
for (const name in leads) {
|
||||||
|
|
Loading…
Reference in a new issue