Added optional method messageLogAdded() to BankingClientCallback and enabled passing FinTsClientConfiguration on to FinTsClient
This commit is contained in:
parent
1abf4bc389
commit
1a484e78b8
|
@ -1,5 +1,6 @@
|
|||
package net.codinux.banking.client
|
||||
|
||||
import net.codinux.banking.client.model.MessageLogEntry
|
||||
import net.codinux.banking.client.model.tan.EnterTanResult
|
||||
import net.codinux.banking.client.model.tan.TanChallenge
|
||||
|
||||
|
@ -7,4 +8,11 @@ interface BankingClientCallback {
|
|||
|
||||
fun enterTan(tanChallenge: TanChallenge, callback: (EnterTanResult) -> Unit)
|
||||
|
||||
/**
|
||||
* An optional method, for sure not available for all client implementations (currently only for FinTs4kBankingClient).
|
||||
*
|
||||
* Gets fired when a FinTS message get sent to bank server, a FinTS message is received from bank server or an error occurred.
|
||||
*/
|
||||
fun messageLogAdded(messageLogEntry: MessageLogEntry)
|
||||
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package net.codinux.banking.client
|
||||
|
||||
import net.codinux.banking.client.model.MessageLogEntry
|
||||
import net.codinux.banking.client.model.tan.EnterTanResult
|
||||
import net.codinux.banking.client.model.tan.TanChallenge
|
||||
|
||||
open class SimpleBankingClientCallback(
|
||||
protected val messageLogAdded: ((MessageLogEntry) -> Unit)? = null,
|
||||
protected val enterTan: ((tanChallenge: TanChallenge, callback: (EnterTanResult) -> Unit) -> Unit)? = null
|
||||
) : BankingClientCallback {
|
||||
|
||||
|
@ -15,4 +17,8 @@ open class SimpleBankingClientCallback(
|
|||
}
|
||||
}
|
||||
|
||||
override fun messageLogAdded(messageLogEntry: MessageLogEntry) {
|
||||
messageLogAdded?.invoke(messageLogEntry)
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package net.codinux.banking.client.fints4k
|
||||
|
||||
import net.codinux.banking.client.BankingClientCallback
|
||||
import net.codinux.banking.client.model.MessageLogEntryType
|
||||
import net.codinux.banking.fints.callback.FinTsClientCallback
|
||||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanGeneratorTanMedium
|
||||
import net.codinux.banking.fints.model.BankData
|
||||
|
@ -32,6 +33,12 @@ open class BridgeFintTsToBankingClientCallback(
|
|||
}
|
||||
|
||||
override fun messageLogAdded(messageLogEntry: MessageLogEntry) {
|
||||
val mapped = net.codinux.banking.client.model.MessageLogEntry(
|
||||
MessageLogEntryType.valueOf(messageLogEntry.type.name),
|
||||
messageLogEntry.message, messageLogEntry.messageTrace,
|
||||
messageLogEntry.error, messageLogEntry.time
|
||||
)
|
||||
|
||||
bankingClientCallback.messageLogAdded(mapped)
|
||||
}
|
||||
}
|
|
@ -7,14 +7,19 @@ import net.codinux.banking.client.model.request.GetAccountDataRequest
|
|||
import net.codinux.banking.client.model.response.GetAccountDataResponse
|
||||
import net.codinux.banking.client.model.response.Response
|
||||
import net.codinux.banking.fints.FinTsClient
|
||||
import net.codinux.banking.fints.config.FinTsClientConfiguration
|
||||
|
||||
open class FinTs4kBankingClient(
|
||||
config: FinTsClientConfiguration = FinTsClientConfiguration(),
|
||||
callback: BankingClientCallback
|
||||
) : BankingClient {
|
||||
|
||||
constructor(callback: BankingClientCallback) : this(FinTsClientConfiguration(), callback)
|
||||
|
||||
|
||||
private val mapper = FinTs4kMapper()
|
||||
|
||||
private val client = FinTsClient(BridgeFintTsToBankingClientCallback(callback, mapper))
|
||||
private val client = FinTsClient(config, BridgeFintTsToBankingClientCallback(callback, mapper))
|
||||
|
||||
|
||||
override suspend fun getAccountDataAsync(request: GetAccountDataRequest): Response<GetAccountDataResponse> {
|
||||
|
|
|
@ -3,11 +3,15 @@ package net.codinux.banking.client.fints4k
|
|||
import net.codinux.banking.client.BankingClientCallback
|
||||
import net.codinux.banking.client.BankingClientForCustomerBase
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.fints.config.FinTsClientConfiguration
|
||||
|
||||
open class FinTs4kBankingClientForCustomer(credentials: AccountCredentials, callback: BankingClientCallback)
|
||||
: BankingClientForCustomerBase(credentials, FinTs4kBankingClient(callback)) {
|
||||
open class FinTs4kBankingClientForCustomer(credentials: AccountCredentials, config: FinTsClientConfiguration = FinTsClientConfiguration(), callback: BankingClientCallback)
|
||||
: BankingClientForCustomerBase(credentials, FinTs4kBankingClient(config, callback)) {
|
||||
|
||||
constructor(bankCode: String, loginName: String, password: String, callback: BankingClientCallback)
|
||||
: this(AccountCredentials(bankCode, loginName, password), callback)
|
||||
: this(bankCode, loginName, password, FinTsClientConfiguration(), callback)
|
||||
|
||||
constructor(bankCode: String, loginName: String, password: String, config: FinTsClientConfiguration = FinTsClientConfiguration(), callback: BankingClientCallback)
|
||||
: this(AccountCredentials(bankCode, loginName, password), config, callback)
|
||||
|
||||
}
|
Loading…
Reference in New Issue