createVerificationRequest method
Future<SdkVerificationResponse>
createVerificationRequest({
- required String applicantId,
- required VerificationType verificationType,
Create a verification request
applicantId - The applicant ID
verificationType - Type of verification (ID_CARD, PASSPORT, etc.)
Returns SdkVerificationResponse
Implementation
Future<SdkVerificationResponse> createVerificationRequest({
required String applicantId,
required VerificationType verificationType,
}) async {
try {
final response = await _apiClient.post(
'/sdk/kyc-verification/applicants/$applicantId/verifications',
body: {'verificationType': _verificationTypeToString(verificationType)},
);
final jsonData = json.decode(response.body) as Map<String, dynamic>;
// Debug: Log the response keys to help identify issues
if (ApexKycConfig.instance.enableLogging) {
debugPrint('[ApexKYC] Response keys: ${jsonData.keys.join(", ")}');
debugPrint('[ApexKYC] Response sample: ${jsonEncode(jsonData)}');
}
try {
return SdkVerificationResponse.fromJson(jsonData);
} catch (parseError) {
if (ApexKycConfig.instance.enableLogging) {
debugPrint('[ApexKYC] JSON parsing error: $parseError');
debugPrint('[ApexKYC] Error type: ${parseError.runtimeType}');
debugPrint('[ApexKYC] Response body: ${response.body}');
}
rethrow;
}
} catch (e) {
if (e is ApexKycException) {
rethrow;
}
throw ApexKycException(
'Failed to create verification request: ${e.toString()}',
originalError: e,
);
}
}