40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
return {
|
|
post(ani, dnis, agent, userData) {
|
|
return new Promise(async (resolve, reject) => {
|
|
try {
|
|
const OIDC = await CAInterface().getOIDC()
|
|
let config = CAInterface().settings().url.CA
|
|
const inapiURL = `https://${config.base}/interaction-notifier/${config.tenant}/notifications`
|
|
|
|
const { data } = await CAInterface().axios('inapi', {
|
|
method: 'post',
|
|
url: inapiURL,
|
|
headers: {
|
|
'Content-Type': 'application/ld+json',
|
|
Authorization: `OIDC_id_token ${OIDC.access_token}`,
|
|
},
|
|
data: {
|
|
'@type': 'vin:InteractionNotification',
|
|
'vin:target': {
|
|
'@type': 'vemorg:Agent',
|
|
'so:identifier': agent,
|
|
},
|
|
'vin:interaction': {
|
|
'@type': 'vin:InboundTelephonyInteraction',
|
|
'vin:dnis': dnis,
|
|
'vin:cli': ani,
|
|
'vin:userData': userData,
|
|
},
|
|
},
|
|
})
|
|
console.log({
|
|
inapiresult: data,
|
|
})
|
|
resolve()
|
|
} catch (error) {
|
|
reject(error)
|
|
}
|
|
})
|
|
},
|
|
}
|