From be3dba476530093d42cd00be2a71e1800c140994 Mon Sep 17 00:00:00 2001 From: dankl Date: Sun, 29 Dec 2019 17:51:52 +0100 Subject: [PATCH] Implemented retrieving user's tan media automatically and storing it on CustomerData --- .../src/main/kotlin/net/dankito/fints/FinTsClient.kt | 6 ++++++ .../src/main/kotlin/net/dankito/fints/model/CustomerData.kt | 2 ++ .../src/test/kotlin/net/dankito/fints/FinTsClientTest.kt | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index e4b00087..1176b066 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -143,6 +143,8 @@ open class FinTsClient @JvmOverloads constructor( val synchronizeCustomerResponse = synchronizeCustomerSystemId(bank, customer) + getTanMediaList(bank, customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien) + // also check if retrieving account transactions of last 90 days without tan is supported (and thereby may retrieve first account transactions) val transactionsOfLast90DaysResponse = tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, true) @@ -335,6 +337,10 @@ open class FinTsClient @JvmOverloads constructor( val tanMediaList = response.getFirstSegmentById(InstituteSegmentId.TanMediaList) + tanMediaList?.let { + customer.tanMedia = it.tanMedia + } + return GetTanMediaListResponse(response, tanMediaList) } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt index 95f83a34..4d994705 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/model/CustomerData.kt @@ -2,6 +2,7 @@ package net.dankito.fints.model import net.dankito.fints.messages.datenelemente.implementierte.* import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion +import net.dankito.fints.messages.datenelemente.implementierte.tan.TanMedium open class CustomerData( @@ -14,6 +15,7 @@ open class CustomerData( var updVersion: Int = UPDVersion.VersionNotReceivedYet, var supportedTanProcedures: List = listOf(), var selectedTanProcedure: TanProcedure = TanProcedureNotSelected, + var tanMedia: List = listOf(), var selectedLanguage: Dialogsprache = Dialogsprache.Default, var customerSystemId: String = KundensystemID.Anonymous, var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId, diff --git a/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt b/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt index 7e6d2c92..8f8519f4 100644 --- a/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt +++ b/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt @@ -138,6 +138,9 @@ class FinTsClientTest { @Test fun getTanMediaList() { + assertThat(Customer.tanMedia).isEmpty() + + // when val result = underTest.getTanMediaList(Bank, Customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien) @@ -148,6 +151,8 @@ class FinTsClientTest { assertThat(result.tanMediaList).isNotNull() assertThat(result.tanMediaList!!.usageOption).isEqualByComparingTo(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value assertThat(result.tanMediaList!!.tanMedia).isNotEmpty() + + assertThat(Customer.tanMedia).isNotEmpty() } @Ignore // only works with banks that don't support HKTAB version 5