verifyFace method
Future<Map<String, dynamic> >
verifyFace(
- String sessionId,
- Map<
String, dynamic> verificationData, - VerificationType verificationType
override
Verify face
Implementation
@override
Future<Map<String, dynamic>> verifyFace(String sessionId, Map<String, dynamic> verificationData, VerificationType verificationType) async {
try {
// Create multipart request for form-data
final request = http.MultipartRequest(
'POST',
Uri.parse('$_baseAppUrl/verify/${verificationType.value}/$sessionId'),
);
// Add headers including Accept-Language
request.headers.addAll(getMultipartHeaders());
// Add video file
if (verificationData['video'] is File) {
final videoFile = verificationData['video'] as File;
final videoStream = http.ByteStream(videoFile.openRead());
final videoLength = await videoFile.length();
request.files.add(http.MultipartFile(
'video',
videoStream,
videoLength,
filename: videoFile.path.split('/').last,
));
} else if (verificationData['video'] is String) {
// Handle base64 string
final videoBytes = base64Decode(verificationData['video'] as String);
request.files.add(http.MultipartFile.fromBytes(
'video',
videoBytes,
filename: 'video.mp4',
));
}
final streamedResponse = await request.send();
final response = await http.Response.fromStream(streamedResponse);
if (response.statusCode == 200) {
final responseData = jsonDecode(response.body);
print('=== API RESPONSE: VERIFY FACE ===');
print('Verification Type: ${verificationType.value}');
print('Status Code: ${response.statusCode}');
print('Response Data: $responseData');
print('=====================================');
return responseData;
} else {
print('=== API ERROR: VERIFY FACE ===');
print('Verification Type: ${verificationType.value}');
print('Status Code: ${response.statusCode}');
print('Error Body: ${response.body}');
print('=====================================');
throw Exception('Failed to verify face: ${response.statusCode}');
}
} catch (e) {
throw Exception('Error verifying face: $e');
}
}