Update applicant-details CLI to use user ID #4

Merged
nabarun merged 2 commits from pm-update-cli into main 2024-07-31 08:14:52 +00:00
Showing only changes of commit e112437a13 - Show all commits

View File

@ -19,7 +19,8 @@ export const builder = (yargs: any) => {
});
};
function getApplicantDetails (userId: string) {
// https://docs.sumsub.com/reference/get-applicant-data-via-externaluserid
function getApplicantDetailsRequest (userId: string) {
const config: any = { baseURL: SUMSUB_BASE_URL};
var method = 'GET';
@ -42,19 +43,17 @@ export const handler = async (argv: Arguments) => {
const userId = argv.userId as string;
if (!userId) {
console.error('User ID is required');
process.exit(1);
throw new Error('User ID is required')
}
try {
const response = await sumsubAxios(getApplicantDetails(userId));
const response = await sumsubAxios(getApplicantDetailsRequest(userId));
// Exclude this key because the includedCountries and docSets data is not required
delete response.data.requiredIdDocs;
console.log('Applicant Data:', JSON.stringify(response.data, null, 2));
} catch (error: any) {
console.error('Failed to fetch applicant data:', error.response ? error.response.data : error.message);
process.exit(1);
throw new Error(`Failed to fetch applicant data: ${JSON.stringify(error.response ? error.response.data : error.message)}`)
}
}