Implemented automatically fetching account transactions after a successful cash transfer
This commit is contained in:
parent
614074b9b9
commit
a8eb748f57
|
@ -297,14 +297,18 @@ open class BankingPresenter(
|
||||||
clientsForAccounts.keys.forEach { account ->
|
clientsForAccounts.keys.forEach { account ->
|
||||||
account.bankAccounts.forEach { bankAccount ->
|
account.bankAccounts.forEach { bankAccount ->
|
||||||
if (bankAccount.supportsRetrievingAccountTransactions) {
|
if (bankAccount.supportsRetrievingAccountTransactions) {
|
||||||
val fromDate = bankAccount.lastRetrievedTransactionsTimestamp?.let { Date(it.time - OneDayMillis) } // one day before last received transactions
|
updateBankAccountTransactionsAsync(bankAccount, abortIfTanIsRequired, callback)
|
||||||
|
|
||||||
fetchAccountTransactionsAsync(bankAccount, fromDate, abortIfTanIsRequired, callback)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun updateBankAccountTransactionsAsync(bankAccount: BankAccount, abortIfTanIsRequired: Boolean, callback: (GetTransactionsResponse) -> Unit) {
|
||||||
|
val fromDate = bankAccount.lastRetrievedTransactionsTimestamp?.let { Date(it.time - OneDayMillis) } // one day before last received transactions
|
||||||
|
|
||||||
|
fetchAccountTransactionsAsync(bankAccount, fromDate, abortIfTanIsRequired, callback)
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun retrievedAccountTransactions(bankAccount: BankAccount, startDate: Date, response: GetTransactionsResponse) {
|
protected open fun retrievedAccountTransactions(bankAccount: BankAccount, startDate: Date, response: GetTransactionsResponse) {
|
||||||
if (response.isSuccessful) {
|
if (response.isSuccessful) {
|
||||||
bankAccount.lastRetrievedTransactionsTimestamp = startDate
|
bankAccount.lastRetrievedTransactionsTimestamp = startDate
|
||||||
|
@ -361,7 +365,13 @@ open class BankingPresenter(
|
||||||
|
|
||||||
open fun transferMoneyAsync(bankAccount: BankAccount, data: TransferMoneyData, callback: (BankingClientResponse) -> Unit) {
|
open fun transferMoneyAsync(bankAccount: BankAccount, data: TransferMoneyData, callback: (BankingClientResponse) -> Unit) {
|
||||||
getClientForAccount(bankAccount.account)?.let { client ->
|
getClientForAccount(bankAccount.account)?.let { client ->
|
||||||
client.transferMoneyAsync(data, bankAccount, callback)
|
client.transferMoneyAsync(data, bankAccount) { response ->
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
updateBankAccountTransactionsAsync(bankAccount, true) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(response)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue