diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt index d77dd6ab..53a90768 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccount.kt @@ -7,7 +7,7 @@ import net.codinux.banking.client.model.config.NoArgConstructor open class BankAccount( val identifier: String, var accountHolderName: String, - val type: BankAccountType = BankAccountType.CheckingAccount, + val type: BankAccountType = BankAccountType.Other, val iban: String? = null, val subAccountNumber: String? = null, val productName: String? = null, diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccountViewInfo.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccountViewInfo.kt new file mode 100644 index 00000000..f0f93b9e --- /dev/null +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankAccountViewInfo.kt @@ -0,0 +1,18 @@ +package net.codinux.banking.client.model + +import net.codinux.banking.client.model.config.NoArgConstructor + +/** + * Contains only the basic info of a [BankAccount], just enough that a client application can display it to the user + * and the user knows exactly which [BankAccount] is meant / referred. + */ +@NoArgConstructor +open class BankAccountViewInfo( + val identifier: String, + val subAccountNumber: String? = null, + val type: BankAccountType = BankAccountType.Other, + val iban: String? = null, + val productName: String? = null, +) { + override fun toString() = "$type $productName $identifier" +} \ No newline at end of file diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccountViewInfo.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccountViewInfo.kt new file mode 100644 index 00000000..fa506dd2 --- /dev/null +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/CustomerAccountViewInfo.kt @@ -0,0 +1,16 @@ +package net.codinux.banking.client.model + +import net.codinux.banking.client.model.config.NoArgConstructor + +/** + * Contains only the basic info of a [CustomerAccount], just enough that a client application can display it to the user + * and the user knows exactly which [CustomerAccount] is meant / referred. + */ +@NoArgConstructor +open class CustomerAccountViewInfo( + val bankCode: String, + var loginName: String, + val bankName: String +) { + override fun toString() = "$bankCode $bankName $loginName" +} \ 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 2bd722af..1641c2da 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 @@ -1,7 +1,7 @@ package net.codinux.banking.client.model.tan -import net.codinux.banking.client.model.BankAccount -import net.codinux.banking.client.model.CustomerAccount +import net.codinux.banking.client.model.BankAccountViewInfo +import net.codinux.banking.client.model.CustomerAccountViewInfo import net.codinux.banking.client.model.config.NoArgConstructor @NoArgConstructor @@ -12,8 +12,8 @@ open class TanChallenge( val tanMethod: TanMethod, val tanImage: TanImage? = null, val flickerCode: FlickerCode? = null, - val customer: CustomerAccount, - val account: BankAccount? = null + val customer: CustomerAccountViewInfo, + val account: BankAccountViewInfo? = null // TODO: add availableTanMethods, selectedTanMedium, availableTanMedia ) { 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 03568e8c..f1922704 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 @@ -11,6 +11,7 @@ import net.codinux.banking.client.model.tan.TanChallenge import net.codinux.banking.client.model.tan.TanImage import net.codinux.banking.client.model.tan.TanMethod import net.codinux.banking.client.model.tan.TanMethodType +import net.dankito.banking.client.model.BankAccountIdentifierImpl import net.dankito.banking.client.model.parameter.GetAccountDataParameter import net.dankito.banking.client.model.parameter.RetrieveTransactions import net.dankito.banking.client.model.response.ErrorCode @@ -26,7 +27,7 @@ open class FinTs4kMapper { fun mapToGetAccountDataParameter(credentials: AccountCredentials, options: GetAccountDataOptions) = GetAccountDataParameter( credentials.bankCode, credentials.loginName, credentials.password, - null, + options.accounts.map { BankAccountIdentifierImpl(it.identifier, it.subAccountNumber, it.iban) }, options.retrieveBalance, RetrieveTransactions.valueOf(options.retrieveTransactions.name), options.retrieveTransactionsFrom, options.retrieveTransactionsTo, abortIfTanIsRequired = options.abortIfTanIsRequired @@ -42,15 +43,23 @@ open class FinTs4kMapper { } + fun mapToCustomerAccountViewInfo(bank: BankData): CustomerAccountViewInfo = CustomerAccountViewInfo( + bank.bankCode, bank.customerId, bank.bankName + ) + + fun mapToBankAccountViewInfo(account: AccountData): BankAccountViewInfo = BankAccountViewInfo( + account.accountIdentifier, account.subAccountAttribute, + mapAccountType(fintsModelMapper.map(account.accountType)), + account.iban, account.productName + ) + + private 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) } ) - fun mapCustomer(bank: BankData): CustomerAccount = - mapCustomer(fintsModelMapper.map(bank)) - private fun mapAccount(account: net.dankito.banking.client.model.BankAccount): BankAccount = BankAccount( account.identifier, account.accountHolderName, mapAccountType(account.type), account.iban, account.subAccountNumber, @@ -62,9 +71,6 @@ open class FinTs4kMapper { bookedTransactions = account.bookedTransactions.map { mapTransaction(it) }.toMutableList() ) - fun mapAccount(account: AccountData): BankAccount = - mapAccount(fintsModelMapper.map(account)) - private fun mapAccountType(type: net.dankito.banking.client.model.BankAccountType): BankAccountType = BankAccountType.valueOf(type.name) @@ -103,8 +109,8 @@ open class FinTs4kMapper { val type = mapTanChallengeType(challenge) val action = mapActionRequiringTan(challenge.forAction) val tanMethod = mapTanMethod(challenge.tanMethod) - val customer = mapCustomer(challenge.bank) - val account = challenge.account?.let { mapAccount(it) } + val customer = mapToCustomerAccountViewInfo(challenge.bank) + val account = challenge.account?.let { mapToBankAccountViewInfo(it) } val tanImage = if (challenge is ImageTanChallenge) mapTanImage(challenge.image) else null val flickerCode = if (challenge is FlickerCodeTanChallenge) mapFlickerCode(challenge.flickerCode) else null