From cb45c181ae7fd32579bceb02de0ebaa5afb7cc7e Mon Sep 17 00:00:00 2001 From: dankito Date: Thu, 5 Sep 2024 23:00:17 +0200 Subject: [PATCH] Renamed UserAccount to User --- .../codinux/banking/client/BankingClient.kt | 4 +++- .../client/BankingClientForUserBase.kt | 4 ++-- .../banking/client/BankingClientExtensions.kt | 4 ++-- .../banking/client/model/BankViewInfo.kt | 20 +++++++++++++++++++ .../client/model/{UserAccount.kt => User.kt} | 2 +- .../client/model/UserAccountViewInfo.kt | 17 ---------------- .../model/response/GetAccountDataResponse.kt | 4 ++-- .../banking/client/model/tan/TanChallenge.kt | 8 ++++---- .../client/fints4k/FinTs4kBankingClient.kt | 4 ++-- .../banking/client/fints4k/FinTs4kMapper.kt | 6 +++--- 10 files changed, 39 insertions(+), 34 deletions(-) create mode 100644 BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankViewInfo.kt rename BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/{UserAccount.kt => User.kt} (99%) delete mode 100644 BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccountViewInfo.kt diff --git a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt index 79a4ea5d..e81c07aa 100644 --- a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt +++ b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClient.kt @@ -38,8 +38,10 @@ interface BankingClient { * Convenience wrapper around [getAccountDataAsync]. * Updates account's transactions beginning from [BankAccount.lastTransactionsRetrievalTime]. * This may requires TAN if [BankAccount.lastTransactionsRetrievalTime] is older than 90 days. + * + * Optionally specify which [accounts] should be updated. If not specified all accounts will be updated. */ - suspend fun updateAccountTransactionsAsync(user: UserAccount, accounts: List? = null): Response> + suspend fun updateAccountTransactionsAsync(user: User, accounts: List? = null): Response> suspend fun transferMoneyAsync(bankCode: String, loginName: String, password: String, recipientName: String, diff --git a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUserBase.kt b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUserBase.kt index 1bfab7bf..7a9eecc9 100644 --- a/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUserBase.kt +++ b/BankingClient/src/commonMain/kotlin/net/codinux/banking/client/BankingClientForUserBase.kt @@ -3,7 +3,7 @@ package net.codinux.banking.client import net.codinux.banking.client.model.AccountCredentials import net.codinux.banking.client.model.Amount import net.codinux.banking.client.model.BankAccount -import net.codinux.banking.client.model.UserAccount +import net.codinux.banking.client.model.User import net.codinux.banking.client.model.options.GetAccountDataOptions import net.codinux.banking.client.model.request.GetAccountDataRequest import net.codinux.banking.client.model.request.TransferMoneyRequest @@ -16,7 +16,7 @@ abstract class BankingClientForUserBase( protected val client: BankingClient ) : BankingClientForUser { - private lateinit var user: UserAccount + private lateinit var user: User override suspend fun getAccountDataAsync(options: GetAccountDataOptions) = client.getAccountDataAsync(GetAccountDataRequest(credentials, options)).also { diff --git a/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt b/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt index a652aa45..c64f60eb 100644 --- a/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt +++ b/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt @@ -3,7 +3,7 @@ package net.codinux.banking.client import kotlinx.coroutines.runBlocking import net.codinux.banking.client.model.Amount import net.codinux.banking.client.model.BankAccount -import net.codinux.banking.client.model.UserAccount +import net.codinux.banking.client.model.User import net.codinux.banking.client.model.options.GetAccountDataOptions import net.codinux.banking.client.model.request.GetAccountDataRequest import net.codinux.banking.client.model.request.TransferMoneyRequest @@ -19,7 +19,7 @@ fun BankingClient.getAccountData(request: GetAccountDataRequest) = runBlocking { getAccountDataAsync(request) } -fun BankingClient.updateAccountTransactions(user: UserAccount, accounts: List? = null) = runBlocking { +fun BankingClient.updateAccountTransactions(user: User, accounts: List? = null) = runBlocking { updateAccountTransactionsAsync(user, accounts) } diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankViewInfo.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankViewInfo.kt new file mode 100644 index 00000000..b52e1af2 --- /dev/null +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/BankViewInfo.kt @@ -0,0 +1,20 @@ +package net.codinux.banking.client.model + +import net.codinux.banking.client.model.config.NoArgConstructor + +/** + * Contains only the basic info of a bank, just enough that a client application can display it to the user + * and the user knows exactly which bank is meant / referred to. + * + * As e.g. when adding a new account, client application has no data about the bank locally, so it can use this + * information to display it to the user. + */ +@NoArgConstructor +open class BankViewInfo( + val bankCode: String, + var loginName: String, + val bankName: String, + val bankingGroup: BankingGroup? = null +) { + override fun toString() = "$bankCode $bankName $loginName" +} \ No newline at end of file diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccount.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/User.kt similarity index 99% rename from BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccount.kt rename to BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/User.kt index fb5b7afe..8d4eecec 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccount.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/User.kt @@ -7,7 +7,7 @@ import net.codinux.banking.client.model.tan.TanMethod @Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor -open class UserAccount( +open class User( val bankCode: String, var loginName: String, /** diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccountViewInfo.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccountViewInfo.kt deleted file mode 100644 index aed6574a..00000000 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/UserAccountViewInfo.kt +++ /dev/null @@ -1,17 +0,0 @@ -package net.codinux.banking.client.model - -import net.codinux.banking.client.model.config.NoArgConstructor - -/** - * Contains only the basic info of a [UserAccount], just enough that a client application can display it to the user - * and the user knows exactly which [UserAccount] is meant / referred. - */ -@NoArgConstructor -open class UserAccountViewInfo( - val bankCode: String, - var loginName: String, - val bankName: String, - val bankingGroup: BankingGroup? = null -) { - override fun toString() = "$bankCode $bankName $loginName" -} \ No newline at end of file diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt index 54e74102..96623869 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/response/GetAccountDataResponse.kt @@ -1,14 +1,14 @@ package net.codinux.banking.client.model.response import net.codinux.banking.client.model.AccountTransaction -import net.codinux.banking.client.model.UserAccount +import net.codinux.banking.client.model.User import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor @Suppress("RUNTIME_ANNOTATION_NOT_SUPPORTED") @NoArgConstructor open class GetAccountDataResponse( - val user: UserAccount + val user: User ) { @get:JsonIgnore 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 152102b2..1f9f336a 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,8 +1,8 @@ package net.codinux.banking.client.model.tan import net.codinux.banking.client.model.BankAccountViewInfo -import net.codinux.banking.client.model.UserAccount -import net.codinux.banking.client.model.UserAccountViewInfo +import net.codinux.banking.client.model.User +import net.codinux.banking.client.model.BankViewInfo import net.codinux.banking.client.model.config.JsonIgnore import net.codinux.banking.client.model.config.NoArgConstructor @@ -24,7 +24,7 @@ open class TanChallenge( * When adding an account, frontend has no UserAccount object in BankingClientCallback to know which TanMethods are * available for User. * Also on other calls to bank server, bank server may returned an updated list of available TanMethods, so that - * [UserAccount] may contains an outdated list of available TanMethods. + * [User] may contains an outdated list of available TanMethods. * * Therefore i added list with up to date TanMethods here to ensure EnterTanDialog can display user's up to date TanMethods. */ @@ -41,7 +41,7 @@ open class TanChallenge( open val tanImage: TanImage? = null, open val flickerCode: FlickerCode? = null, - open val user: UserAccountViewInfo, + open val user: BankViewInfo, open val account: BankAccountViewInfo? = null ) { diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt index fe0bf535..94634174 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt @@ -4,7 +4,7 @@ import net.codinux.banking.client.BankingClient import net.codinux.banking.client.BankingClientCallback import net.codinux.banking.client.model.BankAccount import net.codinux.banking.client.model.BankAccountFeatures -import net.codinux.banking.client.model.UserAccount +import net.codinux.banking.client.model.User import net.codinux.banking.client.model.options.GetAccountDataOptions import net.codinux.banking.client.model.request.GetAccountDataRequest import net.codinux.banking.client.model.request.TransferMoneyRequestForUser @@ -32,7 +32,7 @@ open class FinTs4kBankingClient( return mapper.map(response) } - override suspend fun updateAccountTransactionsAsync(user: UserAccount, accounts: List?): Response> { + override suspend fun updateAccountTransactionsAsync(user: User, accounts: List?): Response> { val accountsToRequest = (accounts ?: user.accounts).filter { it.supportsAnyFeature(BankAccountFeatures.RetrieveBalance, BankAccountFeatures.RetrieveBalance) } if (accountsToRequest.isNotEmpty()) { 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 ae35155a..0e26e9d9 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 @@ -47,7 +47,7 @@ open class FinTs4kMapper { abortIfTanIsRequired = options.abortIfTanIsRequired ) - open fun mapToUpdateAccountTransactionsParameter(user: UserAccount, account: BankAccount, finTsModel: BankData?): GetAccountDataParameter { + open fun mapToUpdateAccountTransactionsParameter(user: User, account: BankAccount, finTsModel: BankData?): GetAccountDataParameter { val accountIdentifier = BankAccountIdentifierImpl(account.identifier, account.subAccountNumber, account.iban) val from = account.lastTransactionsRetrievalTime?.toLocalDateTime(TimeZone.EuropeBerlin)?.date // TODO: in case lastTransactionsUpdateTime is not set, this would retrieve all transactions (and require a TAN im most cases) val retrieveTransactions = if (from != null) RetrieveTransactions.AccordingToRetrieveFromAndTo else RetrieveTransactions.OfLast90Days @@ -106,7 +106,7 @@ open class FinTs4kMapper { } - open fun mapToUserAccountViewInfo(bank: BankData): UserAccountViewInfo = UserAccountViewInfo( + open fun mapToUserAccountViewInfo(bank: BankData): BankViewInfo = BankViewInfo( bank.bankCode, bank.customerId, bank.bankName, getBankingGroup(bank.bankName, bank.bic) ) @@ -117,7 +117,7 @@ open class FinTs4kMapper { ) - protected open fun mapUser(user: net.dankito.banking.client.model.CustomerAccount) = UserAccount( + protected open fun mapUser(user: net.dankito.banking.client.model.CustomerAccount) = User( user.bankCode, user.loginName, user.password, user.bankName, user.bic, user.customerName, user.userId, user.accounts.map { mapAccount(it) },