refactor: yagni and flow of external compliance

This commit is contained in:
Rafael Taranto 2024-06-17 22:11:24 +01:00
parent b06927fd1c
commit 04eea85a0d
29 changed files with 389 additions and 1417 deletions

View file

@ -0,0 +1,99 @@
const request = require('./request')
const createApplicant = (account, userId, level) => {
if (!userId || !level) {
return Promise.reject(`Missing required fields: userId: ${userId}, level: ${level}`)
}
const config = {
method: 'POST',
url: `/resources/applicants?levelName=${level}`,
data: {
externalUserId: userId,
sourceKey: 'lamassu'
},
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
return request(account, config)
}
const createLink = (account, userId, level) => {
if (!userId || !level) {
return Promise.reject(`Missing required fields: userId: ${userId}, level: ${level}`)
}
const config = {
method: 'POST',
url: `/resources/sdkIntegrations/levels/${level}/websdkLink?ttlInSecs=${600}&externalUserId=${userId}`,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
}
return request(account, config)
}
const getApplicantByExternalId = (account, id) => {
console.log('id', id)
if (!id) {
return Promise.reject('Missing required fields: id')
}
const config = {
method: 'GET',
url: `/resources/applicants/-;externalUserId=${id}/one`,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
return request(account, config)
}
const getApplicantStatus = (account, id) => {
if (!id) {
return Promise.reject(`Missing required fields: id`)
}
const config = {
method: 'GET',
url: `/resources/applicants/${id}/status`,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
return request(account, config)
}
const getApplicantById = (account, id) => {
if (!id) {
return Promise.reject(`Missing required fields: id`)
}
const config = {
method: 'GET',
url: `/resources/applicants/${id}/one`,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}
return request(account, config)
}
module.exports = {
createLink,
createApplicant,
getApplicantByExternalId,
getApplicantById,
getApplicantStatus
}