Added bank and account to MessageLogEntry
This commit is contained in:
parent
c443656c03
commit
67ea188182
|
@ -8,5 +8,8 @@ open class MessageLogEntry(
|
||||||
open val message: String,
|
open val message: String,
|
||||||
open val messageTrace: String? = null,
|
open val messageTrace: String? = null,
|
||||||
open val error: Throwable? = 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
|
||||||
)
|
)
|
|
@ -66,7 +66,7 @@ open class FinTs4kBankingClient(
|
||||||
override suspend fun transferMoneyAsync(request: TransferMoneyRequestForUser): Response<TransferMoneyResponse> {
|
override suspend fun transferMoneyAsync(request: TransferMoneyRequestForUser): Response<TransferMoneyResponse> {
|
||||||
val response = client.transferMoneyAsync(mapper.mapToTransferMoneyParameter(request))
|
val response = client.transferMoneyAsync(mapper.mapToTransferMoneyParameter(request))
|
||||||
|
|
||||||
return mapper.mapTransferMoneyResponse(response)
|
return mapper.mapTransferMoneyResponse(response, request.bank, request.account)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -96,7 +96,8 @@ open class FinTs4kMapper {
|
||||||
|
|
||||||
open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse, bank: BankInfo? = null): Response<GetAccountDataResponse> =
|
open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse, bank: BankInfo? = null): Response<GetAccountDataResponse> =
|
||||||
if (response.successful && response.customerAccount != null) {
|
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 {
|
} else {
|
||||||
mapError(response)
|
mapError(response)
|
||||||
}
|
}
|
||||||
|
@ -399,9 +400,9 @@ open class FinTs4kMapper {
|
||||||
finTsModel = request.clientData?.let { serializer.deserializeFromJson(it) }
|
finTsModel = request.clientData?.let { serializer.deserializeFromJson(it) }
|
||||||
)
|
)
|
||||||
|
|
||||||
open fun mapTransferMoneyResponse(response: net.dankito.banking.client.model.response.TransferMoneyResponse): Response<TransferMoneyResponse> =
|
open fun mapTransferMoneyResponse(response: net.dankito.banking.client.model.response.TransferMoneyResponse, bank: BankAccess? = null, account: BankAccount? = null): Response<TransferMoneyResponse> =
|
||||||
if (response.successful) {
|
if (response.successful) {
|
||||||
Response.success(TransferMoneyResponse(mapMessageLog(response)))
|
Response.success(TransferMoneyResponse(mapMessageLog(response, bank, account)))
|
||||||
} else {
|
} else {
|
||||||
mapError(response)
|
mapError(response)
|
||||||
}
|
}
|
||||||
|
@ -409,15 +410,26 @@ open class FinTs4kMapper {
|
||||||
open fun mapToMoney(amount: Amount, currency: String): Money = Money(amount.toString(), currency)
|
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<MessageLogEntry>) = messageLog.map { mapMessageLogEntry(it) }
|
open fun mapMessageLog(messageLog: List<MessageLogEntry>, bank: BankAccess? = null, account: BankAccount? = null) =
|
||||||
|
messageLog.map { mapMessageLogEntry(it) }
|
||||||
|
|
||||||
open fun mapMessageLogEntry(messageLogEntry: MessageLogEntry) = net.codinux.banking.client.model.MessageLogEntry(
|
open fun mapMessageLogEntry(messageLogEntry: MessageLogEntry, bank: BankAccess? = null, account: BankAccount? = null): net.codinux.banking.client.model.MessageLogEntry {
|
||||||
MessageLogEntryType.valueOf(messageLogEntry.type.name),
|
// TODO: may map messageLogEntry.context.BankData to BankAccess
|
||||||
messageLogEntry.message, messageLogEntry.messageTrace,
|
val fintsAccount = messageLogEntry.context.account
|
||||||
messageLogEntry.error, messageLogEntry.time
|
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 <T> mapError(response: net.dankito.banking.client.model.response.FinTsClientResponse): Response<T> {
|
protected open fun <T> mapError(response: net.dankito.banking.client.model.response.FinTsClientResponse): Response<T> {
|
||||||
|
|
Loading…
Reference in New Issue