Added available and selected TanMedia and TanMethods to CustomerAccount

This commit is contained in:
dankito 2024-08-27 02:25:31 +02:00
parent b65658910c
commit 5a2018fd97
3 changed files with 36 additions and 1 deletions

View File

@ -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<BankAccount> = 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<TanMethod> = 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<TanMedium> = 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"
}

View File

@ -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,

View File

@ -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) }
)