diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt index d8eebe08..977a8d31 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt @@ -8,5 +8,8 @@ open class MessageLogEntry( open val message: String, open val messageTrace: String? = null, open val error: Throwable? = null, - open val time: Instant = Clock.System.now() + open val time: Instant = Clock.System.now(), + + val bank: BankAccess? = null, // TODO: make non-null + val account: BankAccount? = null ) \ No newline at end of file diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt index a0714d97..19a2a99e 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt @@ -66,7 +66,7 @@ open class FinTs4kBankingClient( override suspend fun transferMoneyAsync(request: TransferMoneyRequestForUser): Response { val response = client.transferMoneyAsync(mapper.mapToTransferMoneyParameter(request)) - return mapper.mapTransferMoneyResponse(response) + return mapper.mapTransferMoneyResponse(response, request.bank, request.account) } } \ No newline at end of file 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 b781764f..d32f0203 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 @@ -96,7 +96,8 @@ 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), mapMessageLog(response))) + val bank = mapBank(response.customerAccount!!, bank, response.serializedFinTsModel) + Response.success(GetAccountDataResponse(bank, mapMessageLog(response, bank))) } else { mapError(response) } @@ -399,9 +400,9 @@ open class FinTs4kMapper { finTsModel = request.clientData?.let { serializer.deserializeFromJson(it) } ) - open fun mapTransferMoneyResponse(response: net.dankito.banking.client.model.response.TransferMoneyResponse): Response = + open fun mapTransferMoneyResponse(response: net.dankito.banking.client.model.response.TransferMoneyResponse, bank: BankAccess? = null, account: BankAccount? = null): Response = if (response.successful) { - Response.success(TransferMoneyResponse(mapMessageLog(response))) + Response.success(TransferMoneyResponse(mapMessageLog(response, bank, account))) } else { mapError(response) } @@ -409,15 +410,26 @@ 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(response: FinTsClientResponse, bank: BankAccess? = null, account: BankAccount? = null) = + mapMessageLog(response.messageLog, bank) - open fun mapMessageLog(messageLog: List) = messageLog.map { mapMessageLogEntry(it) } + open fun mapMessageLog(messageLog: List, bank: BankAccess? = null, account: BankAccount? = null) = + 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 - ) + open fun mapMessageLogEntry(messageLogEntry: MessageLogEntry, bank: BankAccess? = null, account: BankAccount? = null): net.codinux.banking.client.model.MessageLogEntry { + // TODO: may map messageLogEntry.context.BankData to BankAccess + val fintsAccount = messageLogEntry.context.account + val effectiveAccount = account ?: bank?.accounts?.firstOrNull { it.identifier == fintsAccount?.accountIdentifier && it.subAccountNumber == fintsAccount?.subAccountAttribute } + + return net.codinux.banking.client.model.MessageLogEntry( + MessageLogEntryType.valueOf(messageLogEntry.type.name), + messageLogEntry.message, messageLogEntry.messageTrace, + messageLogEntry.error, messageLogEntry.time, + + bank = bank, + account = effectiveAccount + ) + } protected open fun mapError(response: net.dankito.banking.client.model.response.FinTsClientResponse): Response {