createApplicant method
Create an applicant
customerIdentifier - Unique identifier for the customer
If an applicant with the same customerIdentifier already exists,
returns the existing applicant ID (does not create a duplicate)
Returns applicant ID
Implementation
Future<String> createApplicant({
required String customerIdentifier,
String? fullName,
String? email,
String? phone,
String? dateOfBirth,
String? nationality,
}) async {
try {
final body = <String, dynamic>{'customerIdentifier': customerIdentifier};
if (fullName != null) body['fullName'] = fullName;
if (email != null) body['email'] = email;
if (phone != null) body['phone'] = phone;
if (dateOfBirth != null) body['dateOfBirth'] = dateOfBirth;
if (nationality != null) body['nationality'] = nationality;
final response = await _apiClient.post(
'/sdk/kyc-verification/applicants',
body: body,
);
final jsonData = json.decode(response.body) as Map<String, dynamic>;
return jsonData['id'] as String;
} catch (e) {
if (e is ApexKycException) {
rethrow;
}
throw ApexKycException(
'Failed to create applicant: ${e.toString()}',
originalError: e,
);
}
}