feat: notifications and flow fixes

This commit is contained in:
Rafael Taranto 2024-06-18 23:43:35 +01:00
parent 423cfd4bbb
commit 8f8e95c292
9 changed files with 103 additions and 26 deletions

View file

@ -21,7 +21,7 @@ const getStatus = (settings, service, customerId) => {
status
}))
.catch((error) => {
logger.error(`Error getting applicant for service ${service}:`, error)
if (error.response.status !== 404) logger.error(`Error getting applicant for service ${service}:`, error.message)
return {
service: service,
status: null,
@ -45,7 +45,6 @@ const getStatusMap = (settings, customerExternalCompliance) => {
_.uniq
)(triggers)
const meta = {}
const applicantPromises = _.map(service => {
return getStatus(settings, service, customerExternalCompliance)
})(services)
@ -53,7 +52,7 @@ const getStatusMap = (settings, customerExternalCompliance) => {
return Promise.all(applicantPromises)
.then((applicantResults) => {
return _.reduce((map, result) => {
map[result.service] = result.status
if (result.status) map[result.service] = result.status
return map
}, {})(applicantResults)
})
@ -73,16 +72,9 @@ const createLink = (settings, externalService, customerId) => {
return plugin.createLink(account, customerId, account.applicantLevel)
}
const getApplicantByExternalId = (settings, externalService, customerId) => {
const account = settings.accounts[externalService]
const { plugin } = getPlugin(settings, externalService)
return plugin.getApplicantByExternalId(account, customerId)
}
module.exports = {
getStatusMap,
getStatus,
createApplicant,
getApplicantByExternalId,
createLink
}