From 933c761a0d7b8774113094071a193b7f163233cf Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 15 Oct 2024 03:06:59 +0200 Subject: [PATCH] Added messageLog to GetAccountDataResponse and TransferMoneyResponse --- .../model/response/GetAccountDataResponse.kt | 4 +++- .../model/response/TransferMoneyResponse.kt | 5 ++++- .../BridgeFintTsToBankingClientCallback.kt | 6 +----- .../banking/client/fints4k/FinTs4kMapper.kt | 18 ++++++++++++++++-- 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt index 3053bf7f..fe7e0392 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt @@ -2,13 +2,15 @@ package net.codinux.banking.client.model.response import net.codinux.banking.client.model.AccountTransaction import net.codinux.banking.client.model.BankAccess +import net.codinux.banking.client.model.MessageLogEntry import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor @Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class GetAccountDataResponse( - val bank: BankAccess + val bank: BankAccess, + val messageLog: List ) { @get:JsonIgnore diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/TransferMoneyResponse.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/TransferMoneyResponse.kt index 1a90eb2c..99eec9a4 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/TransferMoneyResponse.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/TransferMoneyResponse.kt @@ -1,9 +1,12 @@ package net.codinux.banking.client.model.response +import net.codinux.banking.client.model.MessageLogEntry import net.codinux.banking.client.model.config.NoArgConstructor /** * Transfer money process does not return any data, only if successful or not (and in latter case an error message). */ @NoArgConstructor -open class TransferMoneyResponse \ No newline at end of file +open class TransferMoneyResponse( + val messageLog: List +) \ No newline at end of file diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt index 0b5d1d07..7d35c8ba 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt @@ -36,11 +36,7 @@ open class BridgeFintTsToBankingClientCallback( } override fun messageLogAdded(messageLogEntry: MessageLogEntry) { - val mapped = net.codinux.banking.client.model.MessageLogEntry( - MessageLogEntryType.valueOf(messageLogEntry.type.name), - messageLogEntry.message, messageLogEntry.messageTrace, - messageLogEntry.error, messageLogEntry.time - ) + val mapped = mapper.mapMessageLogEntry(messageLogEntry) bankingClientCallback.messageLogAdded(mapped) } diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt index 62cfc8ef..4fa6d3da 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt @@ -7,6 +7,7 @@ import kotlinx.datetime.toLocalDateTime import net.codinux.banking.client.model.* import net.codinux.banking.client.model.AccountTransaction import net.codinux.banking.client.model.Amount +import net.codinux.banking.client.model.MessageLogEntryType import net.codinux.banking.client.model.extensions.EuropeBerlin import net.codinux.banking.client.model.tan.* import net.codinux.banking.client.model.options.GetAccountDataOptions @@ -23,6 +24,7 @@ import net.dankito.banking.client.model.BankAccountIdentifierImpl import net.dankito.banking.client.model.parameter.GetAccountDataParameter import net.dankito.banking.client.model.parameter.RetrieveTransactions import net.dankito.banking.client.model.response.ErrorCode +import net.dankito.banking.client.model.response.FinTsClientResponse import net.codinux.banking.fints.mapper.FinTsModelMapper import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.* import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.MobilePhoneTanMedium @@ -30,6 +32,7 @@ import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanGe import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus import net.codinux.banking.fints.model.* +import net.codinux.banking.fints.model.MessageLogEntry import net.codinux.banking.fints.serialization.FinTsModelSerializer import net.codinux.banking.fints.transactions.swift.model.Holding import net.dankito.banking.banklistcreator.prettifier.BankingGroupMapper @@ -93,7 +96,7 @@ open class FinTs4kMapper { open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse, bank: BankInfo? = null): Response = if (response.successful && response.customerAccount != null) { - Response.success(GetAccountDataResponse(mapBank(response.customerAccount!!, bank, response.serializedFinTsModel))) + Response.success(GetAccountDataResponse(mapBank(response.customerAccount!!, bank, response.serializedFinTsModel), mapMessageLog(response))) } else { mapError(response) } @@ -397,7 +400,7 @@ open class FinTs4kMapper { open fun mapTransferMoneyResponse(response: net.dankito.banking.client.model.response.TransferMoneyResponse): Response = if (response.successful) { - Response.success(TransferMoneyResponse()) + Response.success(TransferMoneyResponse(mapMessageLog(response))) } else { mapError(response) } @@ -405,6 +408,17 @@ open class FinTs4kMapper { open fun mapToMoney(amount: Amount, currency: String): Money = Money(amount.toString(), currency) + open fun mapMessageLog(response: FinTsClientResponse) = mapMessageLog(response.messageLog) + + open fun mapMessageLog(messageLog: List) = messageLog.map { mapMessageLogEntry(it) } + + open fun mapMessageLogEntry(messageLogEntry: MessageLogEntry) = net.codinux.banking.client.model.MessageLogEntry( + MessageLogEntryType.valueOf(messageLogEntry.type.name), + messageLogEntry.message, messageLogEntry.messageTrace, + messageLogEntry.error, messageLogEntry.time + ) + + protected open fun mapError(response: net.dankito.banking.client.model.response.FinTsClientResponse): Response { return if (response.error != null) { Response.error(ErrorType.valueOf(response.error!!.name), if (response.error == ErrorCode.BankReturnedError) null else response.errorMessage,