uploadDocumentsBatch method

Future<SdkVerificationResponse> uploadDocumentsBatch({
  1. required String verificationId,
  2. required dynamic frontFile,
  3. dynamic backFile,
})

Upload documents in batch (front and optionally back)

verificationId - The verification ID frontFile - The front document image file (File on mobile, XFile on web) backFile - The back document image file (optional, File on mobile, XFile on web)

Returns SdkVerificationResponse

Implementation

Future<SdkVerificationResponse> uploadDocumentsBatch({
  required String verificationId,
  required dynamic frontFile, // File on mobile, XFile on web
  dynamic backFile, // Optional, File on mobile, XFile on web
}) async {
  try {
    final files = <String, dynamic>{'front': frontFile};

    if (backFile != null) {
      files['back'] = backFile;
    }

    final response = await _apiClient.postMultipartMultiple(
      '/sdk/kyc-verification/verifications/$verificationId/documents/batch',
      files: files,
    );

    final jsonData = json.decode(response.body) as Map<String, dynamic>;
    return SdkVerificationResponse.fromJson(jsonData);
  } catch (e) {
    if (e is ApexKycException) {
      rethrow;
    }
    throw ApexKycException(
      'Failed to upload documents batch: ${e.toString()}',
      originalError: e,
    );
  }
}