From ef1f987dd18fc226567154a4b61f9a036c479077 Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 26 Feb 2022 20:13:49 +0100 Subject: [PATCH] Added ErrorCode.NetworkError --- .../net/dankito/banking/client/model/response/ErrorCode.kt | 2 ++ .../net/dankito/banking/fints/mapper/FinTsModelMapper.kt | 1 + .../banking/fints/response/client/FinTsClientResponse.kt | 4 +++- .../banking/fints/response/client/GetTransactionsResponse.kt | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/response/ErrorCode.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/response/ErrorCode.kt index 4686c3eb..5324b1a6 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/response/ErrorCode.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/response/ErrorCode.kt @@ -5,6 +5,8 @@ enum class ErrorCode { BankDoesNotSupportFinTs3, + NetworkError, + InternalError, BankReturnedError, diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/mapper/FinTsModelMapper.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/mapper/FinTsModelMapper.kt index c6f17ed1..b9586afd 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/mapper/FinTsModelMapper.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/mapper/FinTsModelMapper.kt @@ -98,6 +98,7 @@ open class FinTsModelMapper { open fun mapErrorCode(response: FinTsClientResponse): ErrorCode? { return when { + response.didReceiveResponse == false -> ErrorCode.NetworkError response.internalError != null -> ErrorCode.InternalError response.errorMessagesFromBank.isNotEmpty() -> ErrorCode.BankReturnedError response.isPinLocked -> ErrorCode.AccountLocked diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt index b032d1af..e61a13f4 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/FinTsClientResponse.kt @@ -10,6 +10,8 @@ open class FinTsClientResponse( open val successful: Boolean, + open val didReceiveResponse: Boolean, + open val noTanMethodSelected: Boolean, open val isStrongAuthenticationRequired: Boolean, @@ -40,7 +42,7 @@ open class FinTsClientResponse( ) { - constructor(context: JobContext, response: BankResponse) : this(response.successful, response.noTanMethodSelected, + constructor(context: JobContext, response: BankResponse) : this(response.successful, response.didReceiveResponse, response.noTanMethodSelected, response.isStrongAuthenticationRequired, response.tanResponse, context.messageLogWithoutSensitiveData, response.internalError, response.errorsToShowToUser, response.isPinLocked, response.wrongCredentialsEntered, response.tanRequiredButUserDidNotEnterOne, response.tanRequiredButWeWereToldToAbortIfSo, diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt index 8ab62382..32664155 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/client/GetTransactionsResponse.kt @@ -6,7 +6,7 @@ import net.dankito.banking.fints.model.RetrievedAccountData open class GetTransactionsResponse( open val retrievedResponses: List, errorMessage: String? = null -) : FinTsClientResponse(isSuccessful(retrievedResponses), retrievedResponses.any { it.noTanMethodSelected }, +) : FinTsClientResponse(isSuccessful(retrievedResponses), retrievedResponses.all { it.didReceiveResponse }, retrievedResponses.any { it.noTanMethodSelected }, retrievedResponses.any { it.isStrongAuthenticationRequired }, retrievedResponses.map { it.tanRequired }.firstOrNull(), retrievedResponses.flatMap { it.messageLogWithoutSensitiveData }, errorMessage ?: retrievedResponses.mapNotNull { it.internalError }.joinToString("\r\n"),