From 5ff2714512091b71080c009627883bc829332fc0 Mon Sep 17 00:00:00 2001 From: dankito Date: Mon, 26 Aug 2024 23:55:10 +0200 Subject: [PATCH] Implemented setting preferred TanMethodTypes and set it to NonVisualOrImageBase by default --- .../model/options/GetAccountDataOptions.kt | 33 +++++++++++++++++-- .../banking/client/model/tan/TanMethodType.kt | 17 ++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/options/GetAccountDataOptions.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/options/GetAccountDataOptions.kt index 4d0fed23..584176f7 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/options/GetAccountDataOptions.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/options/GetAccountDataOptions.kt @@ -3,16 +3,43 @@ package net.codinux.banking.client.model.options import kotlinx.datetime.LocalDate import net.codinux.banking.client.model.BankAccountIdentifier import net.codinux.banking.client.model.config.NoArgConstructor +import net.codinux.banking.client.model.tan.TanMethodType @NoArgConstructor open class GetAccountDataOptions( - val retrieveBalance: Boolean = true, val retrieveTransactions: RetrieveTransactions = RetrieveTransactions.OfLast90Days, val retrieveTransactionsFrom: LocalDate? = null, val retrieveTransactionsTo: LocalDate? = null, + + val retrieveBalance: Boolean = true, + + /** + * Account(s) may should be excluded from data retrieval, so this option enabled to set for which accounts data + * should be retrieved. + */ + val accounts: List = emptyList(), + + /** + * Specifies which [TanMethodType] should be preferred when having to choose between multiple available for user + * without requesting the user to choose one. + * + * By default we don't ask the user which TanMethod she prefers but choose one that could match best. If she really + * likes to use a different one, she can select another one in EnterTanDialog. + * + * By default we prefer non visual TanMethods (like AppTan and SMS) over image based TanMethods (like QR-code and + * photoTan) and exclude ChipTanUsb, which is not supported by application, and Flickercode, which is hard to + * implement and therefore most applications have not implemented. + * + * Console apps can only handle non visual TanMethods. + * But also graphical applications prefer non visual TanMethods as then they only have to display a text field to input + * TAN, and then image based TanMethods as then they additionally only have to display an image. + */ + val preferredTanMethods: List? = TanMethodType.NonVisualOrImageBased, + val abortIfTanIsRequired: Boolean = false, - // account(s) may should get excluded from data retrieval, so add option to set for which accounts data should be retrieved - val accounts: List = emptyList() + + // there's also the option preferredTanMedium, but can hardly find a use case for it as we + // cannot know the TanMedium name upfront. In most cases there's only one TanMedium (per TanMethod) anyway. ) { override fun toString(): String { return "retrieveBalance=$retrieveBalance, retrieveTransactions=$retrieveTransactions, abortIfTanIsRequired=$abortIfTanIsRequired" diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt index 725936b3..4fda176d 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanMethodType.kt @@ -20,4 +20,21 @@ enum class TanMethodType { photoTan, QrCode + ; + + + companion object { + + val NonVisual = listOf(TanMethodType.AppTan, TanMethodType.SmsTan, TanMethodType.ChipTanManuell, TanMethodType.EnterTan) + + val ImageBased = listOf(TanMethodType.QrCode, TanMethodType.ChipTanQrCode, TanMethodType.photoTan, TanMethodType.ChipTanPhotoTanMatrixCode) + + val NonVisualOrImageBased = buildList { + addAll(listOf(TanMethodType.AppTan, TanMethodType.SmsTan, TanMethodType.EnterTan)) + addAll(ImageBased) + addAll(listOf(TanMethodType.ChipTanManuell)) // this is quite inconvenient for user, so i added it at last + } + + } + } \ No newline at end of file