diff --git a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientCallback.kt b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientCallback.kt index e23c4c0e..e18fe881 100644 --- a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientCallback.kt +++ b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientCallback.kt @@ -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) + } \ No newline at end of file diff --git a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/SimpleBankingClientCallback.kt b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/SimpleBankingClientCallback.kt index e1fd00f4..b63955c8 100644 --- a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/SimpleBankingClientCallback.kt +++ b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/SimpleBankingClientCallback.kt @@ -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) + } + } \ No newline at end of file diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt index 397da3f9..af888fb3 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/BridgeFintTsToBankingClientCallback.kt @@ -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) } } \ No newline at end of file diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt index 10bb9328..a6a29432 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt @@ -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 { diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClientForCustomer.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClientForCustomer.kt index 0680e75d..e9256d28 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClientForCustomer.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClientForCustomer.kt @@ -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) } \ No newline at end of file