diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/EnterTanResult.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/EnterTanResult.kt index 07f999b5..4156d996 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/EnterTanResult.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/EnterTanResult.kt @@ -5,7 +5,7 @@ import net.codinux.banking.client.model.config.NoArgConstructor @NoArgConstructor open class EnterTanResult( val enteredTan: String?, -// val changeTanMethodTo: TanMethod? = null, + val changeTanMethodTo: TanMethod? = null, // val changeTanMediumTo: TanMedium? = null, // val changeTanMediumResultCallback: ((BankingClientResponse) -> Unit)? = null ) \ 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 af888fb3..4ce5cf0d 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 @@ -22,6 +22,8 @@ open class BridgeFintTsToBankingClientCallback( bankingClientCallback.enterTan(mapper.mapTanChallenge(tanChallenge)) { enterTanResult -> if (enterTanResult.enteredTan != null) { tanChallenge.userEnteredTan(enterTanResult.enteredTan!!) + } else if (enterTanResult.changeTanMethodTo != null) { + tanChallenge.userAsksToChangeTanMethod(mapper.mapTanMethod(enterTanResult.changeTanMethodTo!!)) } else { tanChallenge.userDidNotEnterTan() } diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt index cbe63316..becdf1c3 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt @@ -22,6 +22,7 @@ import net.dankito.banking.client.model.parameter.GetAccountDataParameter import net.dankito.banking.client.model.parameter.RetrieveTransactions import net.dankito.banking.client.model.response.ErrorCode import net.codinux.banking.fints.mapper.FinTsModelMapper +import net.codinux.banking.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion import net.codinux.banking.fints.model.* import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.MobilePhoneTanMedium @@ -74,9 +75,16 @@ open class FinTs4kMapper { open fun mapBankAccountIdentifier(account: BankAccountIdentifier): BankAccountIdentifierImpl = BankAccountIdentifierImpl(account.identifier, account.subAccountNumber, account.iban) + open fun mapTanMethod(method: TanMethod) = net.codinux.banking.fints.model.TanMethod( // TODO: get instance from FinTsData, don't create manually + method.displayName, Sicherheitsfunktion.entries.first { it.code == method.identifier }, mapTanMethodType(method.type), null, method.maxTanInputLength, mapAllowedTanFormat(method.allowedTanFormat) + ) + protected open fun mapTanMethodType(type: TanMethodType): net.codinux.banking.fints.model.TanMethodType = net.codinux.banking.fints.model.TanMethodType.valueOf(type.name) + protected open fun mapAllowedTanFormat(allowedTanFormat: AllowedTanFormat?): net.codinux.banking.fints.messages.datenelemente.implementierte.tan.AllowedTanFormat = + allowedTanFormat?.let { net.codinux.banking.fints.messages.datenelemente.implementierte.tan.AllowedTanFormat.valueOf(it.name) } ?: net.codinux.banking.fints.messages.datenelemente.implementierte.tan.AllowedTanFormat.Alphanumeric + open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse, bank: BankInfo? = null): Response = if (response.successful && response.customerAccount != null) { @@ -242,7 +250,7 @@ open class FinTs4kMapper { protected open fun mapActionRequiringTan(action: net.codinux.banking.fints.model.ActionRequiringTan): ActionRequiringTan = ActionRequiringTan.valueOf(action.name) - protected open fun mapTanMethod(method: net.codinux.banking.fints.model.TanMethod): TanMethod = TanMethod( + open fun mapTanMethod(method: net.codinux.banking.fints.model.TanMethod): TanMethod = TanMethod( method.displayName, mapTanMethodType(method.type), method.securityFunction.code, method.maxTanInputLength, mapAllowedTanFormat(method.allowedTanFormat) )