Little refactorings
This commit is contained in:
parent
051fc9a3e9
commit
a101a37db2
|
@ -1,14 +1,10 @@
|
||||||
import net.dankito.banking.fints.FinTsClient
|
import net.dankito.banking.fints.FinTsClient
|
||||||
import net.dankito.banking.fints.callback.FinTsClientCallback
|
import net.dankito.banking.fints.callback.FinTsClientCallback
|
||||||
import net.dankito.banking.fints.model.AccountData
|
import net.dankito.banking.fints.model.*
|
||||||
import net.dankito.banking.fints.model.AccountFeature
|
|
||||||
import net.dankito.banking.fints.model.BankData
|
|
||||||
import net.dankito.banking.fints.model.CustomerData
|
|
||||||
import net.dankito.banking.fints.response.client.AddAccountResponse
|
import net.dankito.banking.fints.response.client.AddAccountResponse
|
||||||
import net.dankito.banking.fints.response.client.FinTsClientResponse
|
import net.dankito.banking.fints.response.client.FinTsClientResponse
|
||||||
import net.dankito.banking.fints.response.client.GetTransactionsResponse
|
import net.dankito.banking.fints.response.client.GetTransactionsResponse
|
||||||
import net.dankito.banking.fints.webclient.IWebClient
|
import net.dankito.banking.fints.webclient.IWebClient
|
||||||
import net.dankito.utils.multiplatform.toDate
|
|
||||||
import kotlin.native.concurrent.TransferMode
|
import kotlin.native.concurrent.TransferMode
|
||||||
import kotlin.native.concurrent.Worker
|
import kotlin.native.concurrent.Worker
|
||||||
import kotlin.native.concurrent.freeze
|
import kotlin.native.concurrent.freeze
|
||||||
|
@ -31,14 +27,15 @@ open class FinTsClientForCustomerSwift(
|
||||||
protected val callback: FinTsClientCallback
|
protected val callback: FinTsClientCallback
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
protected val worker = Worker.start(name = "FinTsClient worker for $customer")
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
webClient.freeze()
|
webClient.freeze()
|
||||||
callback.freeze()
|
callback.freeze()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected val worker = Worker.start(name = "FinTsClient worker for $customer")
|
|
||||||
|
|
||||||
|
|
||||||
open fun addAccountAsync(callback: (AddAccountResponse) -> Unit) {
|
open fun addAccountAsync(callback: (AddAccountResponse) -> Unit) {
|
||||||
val future = worker.execute(TransferMode.SAFE, { createWorkerArgument() }) { arg ->
|
val future = worker.execute(TransferMode.SAFE, { createWorkerArgument() }) { arg ->
|
||||||
|
@ -61,13 +58,12 @@ open class FinTsClientForCustomerSwift(
|
||||||
FinTsClientWorkerResult(bank.freeze(), customer.freeze(), response.freeze())
|
FinTsClientWorkerResult(bank.freeze(), customer.freeze(), response.freeze())
|
||||||
}
|
}
|
||||||
|
|
||||||
future.consume { result ->
|
val result = future.result
|
||||||
map(bank, result.bank)
|
map(bank, result.bank)
|
||||||
map(customer, result.customer)
|
map(customer, result.customer)
|
||||||
|
|
||||||
callback(result.response)
|
callback(result.response)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
open fun getTransactionsAsync(parameter: GetTransactionsParameter, account: AccountData, callback: (GetTransactionsResponse) -> Unit) {
|
open fun getTransactionsAsync(parameter: GetTransactionsParameter, account: AccountData, callback: (GetTransactionsResponse) -> Unit) {
|
||||||
|
|
Loading…
Reference in New Issue