Fixed filtering out accounts for which no transactions have been retrieved (otherwise .first() throws an exception)
This commit is contained in:
parent
1b3ec8f7c1
commit
9c63394922
|
@ -44,10 +44,14 @@ open class DtoMapper {
|
||||||
throw InternalServerErrorException("Could not fetch account transactions. Either TAN hasn't been entered or developers made a mistake.")
|
throw InternalServerErrorException("Could not fetch account transactions. Either TAN hasn't been entered or developers made a mistake.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetAccountsTransactionsResponseDto(accountsTransactions.map { map(it) })
|
return GetAccountsTransactionsResponseDto(accountsTransactions.mapNotNull { map(it) }) // TODO: is this correct removing accounts from result for which no transactions have been retrieved?
|
||||||
|
}
|
||||||
|
|
||||||
|
open fun map(accountTransactions: GetTransactionsResponse): GetAccountTransactionsResponseDto? {
|
||||||
|
if (accountTransactions.retrievedData.isEmpty()) {
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun map(accountTransactions: GetTransactionsResponse): GetAccountTransactionsResponseDto {
|
|
||||||
val retrievedData = accountTransactions.retrievedData.first()
|
val retrievedData = accountTransactions.retrievedData.first()
|
||||||
val balance = mapNullable(retrievedData.balance)
|
val balance = mapNullable(retrievedData.balance)
|
||||||
val bookedTransactions = map(retrievedData.bookedTransactions)
|
val bookedTransactions = map(retrievedData.bookedTransactions)
|
||||||
|
|
Loading…
Reference in New Issue