Skip to content

Commit

Permalink
add: bullhorn Lead
Browse files Browse the repository at this point in the history
  • Loading branch information
DaKingKong committed Dec 31, 2024
1 parent 7a2908b commit 36d732d
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/adapters/bullhorn/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,26 @@ async function findContact({ user, phoneNumber }) {
additionalInfo: commentActionList?.length > 0 ? { noteActions: commentActionList } : null
});
}
// check for Lead
const leadPersonInfo = await axios.post(
`${user.platformAdditionalInfo.restUrl}search/Lead?fields=id,name,email,phone'`,
{
query: `(phone:${phoneNumberWithoutCountryCode} OR mobile:${phoneNumberWithoutCountryCode} OR phone2:${phoneNumberWithoutCountryCode} OR phone3:${phoneNumberWithoutCountryCode}) AND isDeleted:false`
},
{
headers: {
BhRestToken: user.platformAdditionalInfo.bhRestToken
}
});
for (const result of leadPersonInfo.data.data) {
matchedContactInfo.push({
id: result.id,
name: result.name,
phone: result.phone,
type: 'Lead',
additionalInfo: commentActionList?.length > 0 ? { noteActions: commentActionList } : null
});
}
extraDataTracking = {
ratelimitRemaining: candidatePersonInfo.headers['ratelimit-remaining'],
ratelimitAmount: candidatePersonInfo.headers['ratelimit-limit'],
Expand All @@ -226,6 +246,40 @@ async function findContact({ user, phoneNumber }) {
async function createContact({ user, authHeader, phoneNumber, newContactName, newContactType }) {
let extraDataTracking;
switch (newContactType) {
case 'Lead':
const leadPostBody = {
name: newContactName,
firstName: newContactName.split(' ')[0],
lastName: newContactName.split(' ').length > 1 ? newContactName.split(' ')[1] : '',
phone: phoneNumber.replace(' ', '+')
}
const leadInfoResp = await axios.put(
`${user.platformAdditionalInfo.restUrl}entity/Lead`,
leadPostBody,
{
headers: {
BhRestToken: user.platformAdditionalInfo.bhRestToken
}
}
);
extraDataTracking = {
ratelimitRemaining: leadInfoResp.headers['ratelimit-remaining'],
ratelimitAmount: leadInfoResp.headers['ratelimit-limit'],
ratelimitReset: leadInfoResp.headers['ratelimit-reset']
}

return {
contactInfo: {
id: leadInfoResp.data.changedEntityId,
name: newContactName
},
returnMessage: {
message: `New ${newContactType} created.`,
messageType: 'success',
ttl: 3000
},
extraDataTracking
}
case 'Candidate':
const candidatePostBody = {
name: newContactName,
Expand Down
4 changes: 4 additions & 0 deletions src/adapters/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,10 @@
{
"display": "Contact",
"value": "Contact"
},
{
"display": "Lead",
"value": "Lead"
}
],
"settings": [
Expand Down

0 comments on commit 36d732d

Please sign in to comment.