uploadSessionDoc method
CALL API
Implementation
/// CALL API
Future<RemoteResponse<UploadDTO>> uploadSessionDoc({
required DocTypes docTypes,
required String issuingCountry,
required String sessionId,
required String accessToken,
String? frontDocUri,
String? backDocUri,
String? frontDocBase64,
String? backDocBase64,
}) async {
try {
Dio dio = getDio(accessToken);
debugPrint(frontDocBase64??'');
final body = {
"doc_type": docTypes.value,
"issuing_country": issuingCountry,
if(frontDocUri!=null)"front_doc_uri": frontDocUri,
if(backDocUri!=null)"back_doc_uri": backDocUri,
if(frontDocBase64!=null)"front_doc_base64": frontDocBase64,
if(backDocBase64!=null)"back_doc_base64": backDocBase64,
};
print('POST: ${dio.options.baseUrl}${uploadDocPath(sessionId)}, body: $body');
final response = await dio.post<Map<String, dynamic>>(
uploadDocPath(sessionId),
data: body,
);
final Map<String, dynamic>? data = response.data;
log('STATUS: ${response.statusCode}, DATA: $data');
if (response.statusCode == 200) {
final Map<String, dynamic> payload =
data?['payload'] as Map<String, dynamic>;
if (isSuccessResponse(data)) {
return RemoteResponse.withNewData(
UploadDTO.fromJson(payload),
);
} else {
throw EkycApiException.fromJson(payload);
}
} else {
throw EkycApiException.fromJson(response.data!);
}
} on DioError catch (e) {
return handleDioError(e);
}
}