Added convenience constructors for when retrieving data was successful
This commit is contained in:
parent
ec3cdb1c39
commit
79ebb35bc7
|
@ -13,6 +13,10 @@ open class GetTransactionsResponse(
|
||||||
|
|
||||||
constructor(account: TypedBankAccount, errorToShowToUser: String) : this(errorToShowToUser, listOf(RetrievedAccountData(account, false, null, listOf(), listOf())))
|
constructor(account: TypedBankAccount, errorToShowToUser: String) : this(errorToShowToUser, listOf(RetrievedAccountData(account, false, null, listOf(), listOf())))
|
||||||
|
|
||||||
|
constructor(retrievedData: RetrievedAccountData) : this(listOf(retrievedData))
|
||||||
|
|
||||||
|
constructor(retrievedData: List<RetrievedAccountData>) : this(null, retrievedData)
|
||||||
|
|
||||||
|
|
||||||
override val isSuccessful: Boolean
|
override val isSuccessful: Boolean
|
||||||
get() = errorToShowToUser == null && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false }
|
get() = errorToShowToUser == null && retrievedData.isNotEmpty() && retrievedData.none { it.successfullyRetrievedData == false }
|
||||||
|
|
|
@ -161,7 +161,7 @@ open class BankingPresenter(
|
||||||
persistAccountOffUiThread(account)
|
persistAccountOffUiThread(account)
|
||||||
|
|
||||||
response.retrievedData.forEach { retrievedData ->
|
response.retrievedData.forEach { retrievedData ->
|
||||||
retrievedAccountTransactions(GetTransactionsResponse(null, listOf(retrievedData)), startDate, false)
|
retrievedAccountTransactions(GetTransactionsResponse(retrievedData), startDate, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
findIconForBankAsync(account)
|
findIconForBankAsync(account)
|
||||||
|
@ -353,7 +353,7 @@ open class BankingPresenter(
|
||||||
asyncRunner.runAsync { // don't block retrieving next chunk by blocked saving to db / json
|
asyncRunner.runAsync { // don't block retrieving next chunk by blocked saving to db / json
|
||||||
updateAccountTransactions(bankAccount, accountTransactionsChunk)
|
updateAccountTransactions(bankAccount, accountTransactionsChunk)
|
||||||
|
|
||||||
callRetrievedAccountTransactionsResponseListener(GetTransactionsResponse(null, listOf(RetrievedAccountData(bankAccount, true, null, accountTransactionsChunk, listOf()))))
|
callRetrievedAccountTransactionsResponseListener(GetTransactionsResponse(RetrievedAccountData(bankAccount, true, null, accountTransactionsChunk, listOf())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ open class fints4kBankingClient(
|
||||||
override fun getTransactionsAsync(bankAccount: TypedBankAccount, parameter: GetTransactionsParameter, callback: (GetTransactionsResponse) -> Unit) {
|
override fun getTransactionsAsync(bankAccount: TypedBankAccount, parameter: GetTransactionsParameter, callback: (GetTransactionsResponse) -> Unit) {
|
||||||
findAccountForBankAccount(bankAccount) { account, errorMessage ->
|
findAccountForBankAccount(bankAccount) { account, errorMessage ->
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
callback(GetTransactionsResponse(errorMessage))
|
callback(GetTransactionsResponse(bankAccount, errorMessage ?: ""))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val mappedParameter = GetTransactionsParameter(parameter.alsoRetrieveBalance, parameter.fromDate,
|
val mappedParameter = GetTransactionsParameter(parameter.alsoRetrieveBalance, parameter.fromDate,
|
||||||
|
|
|
@ -178,8 +178,8 @@ open class hbci4jBankingClient(
|
||||||
return GetTransactionsResponse(account,"Could not fetch account transactions of bank account $account: $result")
|
return GetTransactionsResponse(account,"Could not fetch account transactions of bank account $account: $result")
|
||||||
}
|
}
|
||||||
|
|
||||||
return GetTransactionsResponse(null, listOf(RetrievedAccountData(account, true, balance.toBigDecimal(),
|
return GetTransactionsResponse(RetrievedAccountData(account, true, balance.toBigDecimal(),
|
||||||
accountTransactionMapper.mapAccountTransactions(account, result), listOf())))
|
accountTransactionMapper.mapAccountTransactions(account, result), listOf()))
|
||||||
}
|
}
|
||||||
catch(e: Exception) {
|
catch(e: Exception) {
|
||||||
log.error("Could not get accounting details for bank ${credentials.bankCode}", e)
|
log.error("Could not get accounting details for bank ${credentials.bankCode}", e)
|
||||||
|
|
Loading…
Reference in New Issue