diff --git a/src/cli/cmds/sumsub-cmds/applicant-details.ts b/src/cli/cmds/sumsub-cmds/applicant-details.ts index ebd4631..6fc3bf4 100644 --- a/src/cli/cmds/sumsub-cmds/applicant-details.ts +++ b/src/cli/cmds/sumsub-cmds/applicant-details.ts @@ -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)}`) } }