From ef1c927d27b704effc399ac4987b044193920d16 Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 20 Dec 2020 16:44:10 +0100 Subject: [PATCH] Implemented mapping DecoupledTanMethodParameters --- .../net/dankito/banking/fints/FinTsClient.kt | 17 ++++++++++++++++- .../fints/model/DecoupledTanMethodParameters.kt | 16 ++++++++++++++++ .../dankito/banking/fints/model/TanMethod.kt | 3 ++- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/DecoupledTanMethodParameters.kt diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt index 6599d3a8..0f3a0569 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt @@ -1132,7 +1132,8 @@ open class FinTsClient( return TanMethod(methodName, parameters.securityFunction, mapToTanMethodType(parameters) ?: TanMethodType.EnterTan, mapHhdVersion(parameters), parameters.maxTanInputLength, parameters.allowedTanFormat, - parameters.nameOfTanMediumRequired == BezeichnungDesTanMediumsErforderlich.BezeichnungDesTanMediumsMussAngegebenWerden) + parameters.nameOfTanMediumRequired == BezeichnungDesTanMediumsErforderlich.BezeichnungDesTanMediumsMussAngegebenWerden, + mapDecoupledTanMethodParameters(parameters)) } protected open fun mapToTanMethodType(parameters: TanMethodParameters): TanMethodType? { @@ -1212,6 +1213,20 @@ open class FinTsClient( return false } + protected open fun mapDecoupledTanMethodParameters(parameters: TanMethodParameters): DecoupledTanMethodParameters? { + parameters.manualConfirmationAllowedForDecoupled?.let { manualConfirmationAllowed -> + return DecoupledTanMethodParameters( + manualConfirmationAllowed, + parameters.periodicStateRequestsAllowedForDecoupled ?: false, // this and the following values are all set when manualConfirmationAllowedForDecoupled is set + parameters.maxNumberOfStateRequestsForDecoupled ?: 0, + parameters.initialDelayInSecondsForStateRequestsForDecoupled ?: Int.MAX_VALUE, + parameters.delayInSecondsForNextStateRequestsForDecoupled ?: Int.MAX_VALUE + ) + } + + return null + } + protected open fun isJobSupported(bank: BankData, segmentId: ISegmentId): Boolean { return bank.supportedJobs.map { it.jobName }.contains(segmentId.id) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/DecoupledTanMethodParameters.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/DecoupledTanMethodParameters.kt new file mode 100644 index 00000000..ba3d9267 --- /dev/null +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/DecoupledTanMethodParameters.kt @@ -0,0 +1,16 @@ +package net.dankito.banking.fints.model + + +open class DecoupledTanMethodParameters( + open val manualConfirmationAllowed: Boolean, + open val periodicStateRequestsAllowed: Boolean, + open val maxNumberOfStateRequests: Int, + open val initialDelayInSecondsForStateRequests: Int, + open val delayInSecondsForNextStateRequests: Int +) { + + override fun toString(): String { + return "DecoupledTanMethodParameters(manualConfirmationAllowed=$manualConfirmationAllowed, periodicStateRequestsAllowed=$periodicStateRequestsAllowed, maxNumberOfStateRequests=$maxNumberOfStateRequests, initialDelayInSecondsForStateRequests=$initialDelayInSecondsForStateRequests, delayInSecondsForNextStateRequests=$delayInSecondsForNextStateRequests)" + } + +} \ No newline at end of file diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanMethod.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanMethod.kt index 75e68b64..1924d547 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanMethod.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/model/TanMethod.kt @@ -11,7 +11,8 @@ open class TanMethod( open val hhdVersion: HHDVersion? = null, open val maxTanInputLength: Int? = null, open val allowedTanFormat: AllowedTanFormat? = null, - open val nameOfTanMediumRequired: Boolean = false + open val nameOfTanMediumRequired: Boolean = false, + open val decoupledParameters: DecoupledTanMethodParameters? = null ) {