Format applicant details response #3

Merged
nabarun merged 3 commits from iv-add-script-for-cli into main 2024-07-29 13:41:47 +00:00
2 changed files with 12 additions and 7 deletions

View File

@ -22,6 +22,7 @@
},
"scripts": {
"build": "tsc",
"start": "node dist/index.js"
"start": "node dist/index.js",
"cli": "node dist/cli/index.js"
}
}

View File

@ -5,13 +5,13 @@ import { sumsubAxios } from '../../../utils';
dotenv.config();
export const command = 'applicant-details';
export const desc = 'Get applicant details.';
const SUMSUB_BASE_URL = 'https://api.sumsub.com';
const SUMSUB_APP_TOKEN = process.env.SUMSUB_APP_TOKEN || '';
export const command = 'applicant-details [applicantId]';
export const desc = 'Get applicant details.';
export const builder = (yargs: any) => {
return yargs.positional('applicantId', {
describe: 'The applicant ID to query',
@ -39,7 +39,7 @@ function getApplicantDetails (applicantId: string | number) {
}
export const handler = async (argv: Arguments) => {
const applicantId = argv._[2];
const applicantId = argv.applicantId as string;
if (!applicantId) {
console.error('Applicant ID is required');
@ -47,7 +47,11 @@ export const handler = async (argv: Arguments) => {
try {
const response = await sumsubAxios(getApplicantDetails(applicantId));
console.log('Applicant Data:', response.data);
// 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);
}