From 636963b3d432c8955c614dd70bc3664698168c42 Mon Sep 17 00:00:00 2001 From: dankito Date: Tue, 15 Oct 2024 13:29:25 +0200 Subject: [PATCH] Added and finTsModelOrDeserialized to --- .../kotlin/net/codinux/banking/fints/FinTsClient.kt | 6 +++--- .../client/model/parameter/FinTsClientParameter.kt | 12 ++++++++++-- .../model/parameter/GetAccountDataParameter.kt | 3 ++- .../client/model/parameter/TransferMoneyParameter.kt | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt index 9ce9cd61..27cc5ade 100644 --- a/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/codinux/banking/fints/FinTsClient.kt @@ -193,8 +193,8 @@ open class FinTsClient( * 04 FinTS_3.0_Messages_Geschaeftsvorfaelle.pdf */ open suspend fun getRequiredDataToSendUserJobs(param: FinTsClientParameter): net.dankito.banking.client.model.response.FinTsClientResponse { - if (param.finTsModel != null) { - return net.dankito.banking.client.model.response.FinTsClientResponse(null, null, emptyList(), param.finTsModel) + param.finTsModelOrDeserialized?.let { finTsModel -> + return net.dankito.banking.client.model.response.FinTsClientResponse(null, null, emptyList(), finTsModel) } val defaultValues = (param as? GetAccountDataParameter)?.defaultBankValues @@ -213,7 +213,7 @@ open class FinTsClient( } protected open suspend fun getAccountInfo(param: FinTsClientParameter, bank: BankData): GetAccountInfoResponse { - param.finTsModel?.let { + param.finTsModelOrDeserialized?.let { // TODO: implement // return GetAccountInfoResponse(it) } diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/FinTsClientParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/FinTsClientParameter.kt index 88f6e5df..81fdfdd9 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/FinTsClientParameter.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/FinTsClientParameter.kt @@ -2,6 +2,7 @@ package net.dankito.banking.client.model.parameter import net.codinux.banking.fints.model.BankData import net.codinux.banking.fints.model.TanMethodType +import net.codinux.banking.fints.serialization.FinTsModelSerializer import net.dankito.banking.client.model.CustomerCredentials @@ -15,5 +16,12 @@ open class FinTsClientParameter( open val tanMethodsNotSupportedByApplication: List? = null, open val preferredTanMedium: String? = null, // the ID of the medium open val abortIfTanIsRequired: Boolean = false, - open val finTsModel: BankData? = null -) : CustomerCredentials(bankCode, loginName, password) \ No newline at end of file + open val finTsModel: BankData? = null, + open val serializedFinTsModel: String? = null +) : CustomerCredentials(bankCode, loginName, password) { + + open val finTsModelOrDeserialized: BankData? by lazy { + finTsModel ?: serializedFinTsModel?.let { FinTsModelSerializer.deserializeFromJson(it) } + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt index 94cf3c49..3699bdc4 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/GetAccountDataParameter.kt @@ -25,8 +25,9 @@ open class GetAccountDataParameter( preferredTanMedium: String? = null, abortIfTanIsRequired: Boolean = false, finTsModel: BankData? = null, + serializedFinTsModel: String? = null, open val defaultBankValues: BankData? = null -) : FinTsClientParameter(bankCode, loginName, password, preferredTanMethods, tanMethodsNotSupportedByApplication, preferredTanMedium, abortIfTanIsRequired, finTsModel) { +) : FinTsClientParameter(bankCode, loginName, password, preferredTanMethods, tanMethodsNotSupportedByApplication, preferredTanMedium, abortIfTanIsRequired, finTsModel, serializedFinTsModel) { open val retrieveOnlyAccountInfo: Boolean get() = retrieveBalance == false && retrieveTransactions == RetrieveTransactions.No diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/TransferMoneyParameter.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/TransferMoneyParameter.kt index 87ad51ca..a645af03 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/TransferMoneyParameter.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/client/model/parameter/TransferMoneyParameter.kt @@ -38,7 +38,8 @@ open class TransferMoneyParameter( preferredTanMedium: String? = null, abortIfTanIsRequired: Boolean = false, finTsModel: BankData? = null, + serializedFinTsModel: String? = null, open val selectAccountToUseForTransfer: ((List) -> AccountData?)? = null // TODO: use BankAccount instead of AccountData -) : FinTsClientParameter(bankCode, loginName, password, preferredTanMethods, tanMethodsNotSupportedByApplication, preferredTanMedium, abortIfTanIsRequired, finTsModel) \ No newline at end of file +) : FinTsClientParameter(bankCode, loginName, password, preferredTanMethods, tanMethodsNotSupportedByApplication, preferredTanMedium, abortIfTanIsRequired, finTsModel, serializedFinTsModel) \ No newline at end of file