From 8fa331a07ac04ad78e47334ad45e9d7eb30522ec Mon Sep 17 00:00:00 2001 From: IshaVenikar Date: Mon, 29 Jul 2024 18:45:04 +0530 Subject: [PATCH] Exclude requiredIdDocs from the applicant details --- src/cli/cmds/sumsub-cmds/applicant-details.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli/cmds/sumsub-cmds/applicant-details.ts b/src/cli/cmds/sumsub-cmds/applicant-details.ts index b89fc3b..da5f428 100644 --- a/src/cli/cmds/sumsub-cmds/applicant-details.ts +++ b/src/cli/cmds/sumsub-cmds/applicant-details.ts @@ -38,6 +38,17 @@ function getApplicantDetails (applicantId: string | number) { return config; } +function customReplacer(key: string, value: any): any { + if (key === 'requiredIdDocs' && typeof value === 'object' && value !== null) { + const containsArray = Object.values(value).some(Array.isArray); + if (containsArray) { + return undefined; // Exclude this key because the includedCountries and docSets data is not required + } + } + + return value; +} + export const handler = async (argv: Arguments) => { const applicantId = argv.applicantId as string; @@ -47,7 +58,7 @@ export const handler = async (argv: Arguments) => { try { const response = await sumsubAxios(getApplicantDetails(applicantId)); - console.log('Applicant Data:', JSON.stringify(response.data, null, 2)); + console.log('Applicant Data:', JSON.stringify(response.data, customReplacer, 1)); } catch (error: any) { console.error('Failed to fetch applicant data:', error.response ? error.response.data : error.message); }