diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccount.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccount.kt index a8cc62b6..2c4fa674 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccount.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccount.kt @@ -1,7 +1,11 @@ package net.codinux.banking.client.model +import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor +import net.codinux.banking.client.model.tan.TanMedium +import net.codinux.banking.client.model.tan.TanMethod +@Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class CustomerAccount( val bankCode: String, @@ -19,6 +23,24 @@ open class CustomerAccount( val accounts: List = emptyList(), + /** + * Identifier of selected TanMethod. + * + * As [tanMethods] also contains selected TanMethod, we didn't want to duplicate this object. Use + * [selectedTanMethod] to get selected TanMethod or iterate over [tanMethods] and filter selected one by this id. + */ + val selectedTanMethodId: String? = null, + val tanMethods: List = listOf(), + + /** + * Identifier of selected TanMedium. + * + * As [tanMedia] also contains selected TanMedium, we didn't want to duplicate this object. Use [selectedTanMedium] + * to get selected TanMedium or iterate over [tanMedia] and filter selected one by this medium name. + */ + val selectedTanMediumName: String? = null, + val tanMedia: List = listOf(), + var bankingGroup: BankingGroup? = null, var iconUrl: String? = null, ) { @@ -29,6 +51,15 @@ open class CustomerAccount( var displayIndex: Int = 0 + @get:JsonIgnore + val selectedTanMethod: TanMethod + get() = tanMethods.first { it.identifier == selectedTanMethodId } + + @get:JsonIgnore + val selectedTanMedium: TanMedium? + get() = tanMedia.firstOrNull { it.mediumName == selectedTanMediumName } + + override fun toString() = "$bankName $loginName, ${accounts.size} accounts" } \ No newline at end of file diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt index f296af7e..8d13b3d4 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/tan/TanChallenge.kt @@ -6,6 +6,7 @@ import net.codinux.banking.client.model.CustomerAccountViewInfo import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor +@Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class TanChallenge( val type: TanChallengeType, 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 40a10bb4..0063f2e0 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 @@ -65,7 +65,10 @@ open class FinTs4kMapper { protected open fun mapCustomer(customer: net.dankito.banking.client.model.CustomerAccount): CustomerAccount = CustomerAccount( customer.bankCode, customer.loginName, customer.password, customer.bankName, customer.bic, customer.customerName, customer.userId, - customer.accounts.map { mapAccount(it) } + customer.accounts.map { mapAccount(it) }, + + customer.selectedTanMethod?.securityFunction?.code, customer.tanMethods.map { mapTanMethod(it) }, + customer.selectedTanMedium?.mediumName, customer.tanMedia.map { mapTanMedium(it) } )