in src/libs/transforms.ts [179:217]
async function subscriptionToOptionalPhoneNumber(
stage: string,
phoneBook: PhoneBook,
subscription: ZuoraSubscription,
identityAPIBearerToken: string,
): Promise<string> {
const identityId = identityIdLookUp(
phoneBook,
subscription.subscription_name,
);
// If we could not determine an identityId, then there will be no phone number
if (identityId === null || identityId == '') {
return '';
}
if (
await validateIdentityIdForPhoneNumberInclusion(
stage,
identityId,
identityAPIBearerToken,
)
) {
console.log(
`authorised to perform phone number look up for identity id: ${identityId}`,
);
const number = phoneNumberLookUp(
phoneBook,
subscription.subscription_name,
);
if (number) {
console.log(`found number: ${number}`);
}
return number || '';
} else {
console.log(
`not authorised to perform phone number look up for identity id: ${identityId}`,
);
return '';
}
}