Implemented retrieving user's tan media automatically and storing it on CustomerData

This commit is contained in:
dankl 2019-12-29 17:51:52 +01:00 committed by dankito
parent 9af7c53272
commit be3dba4765
3 changed files with 13 additions and 0 deletions

View File

@ -143,6 +143,8 @@ open class FinTsClient @JvmOverloads constructor(
val synchronizeCustomerResponse = synchronizeCustomerSystemId(bank, customer) 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) // also check if retrieving account transactions of last 90 days without tan is supported (and thereby may retrieve first account transactions)
val transactionsOfLast90DaysResponse = val transactionsOfLast90DaysResponse =
tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, true) tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, true)
@ -335,6 +337,10 @@ open class FinTsClient @JvmOverloads constructor(
val tanMediaList = response.getFirstSegmentById<TanMediaList>(InstituteSegmentId.TanMediaList) val tanMediaList = response.getFirstSegmentById<TanMediaList>(InstituteSegmentId.TanMediaList)
tanMediaList?.let {
customer.tanMedia = it.tanMedia
}
return GetTanMediaListResponse(response, tanMediaList) return GetTanMediaListResponse(response, tanMediaList)
} }

View File

@ -2,6 +2,7 @@ package net.dankito.fints.model
import net.dankito.fints.messages.datenelemente.implementierte.* import net.dankito.fints.messages.datenelemente.implementierte.*
import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion import net.dankito.fints.messages.datenelemente.implementierte.signatur.Sicherheitsfunktion
import net.dankito.fints.messages.datenelemente.implementierte.tan.TanMedium
open class CustomerData( open class CustomerData(
@ -14,6 +15,7 @@ open class CustomerData(
var updVersion: Int = UPDVersion.VersionNotReceivedYet, var updVersion: Int = UPDVersion.VersionNotReceivedYet,
var supportedTanProcedures: List<TanProcedure> = listOf(), var supportedTanProcedures: List<TanProcedure> = listOf(),
var selectedTanProcedure: TanProcedure = TanProcedureNotSelected, var selectedTanProcedure: TanProcedure = TanProcedureNotSelected,
var tanMedia: List<TanMedium> = listOf(),
var selectedLanguage: Dialogsprache = Dialogsprache.Default, var selectedLanguage: Dialogsprache = Dialogsprache.Default,
var customerSystemId: String = KundensystemID.Anonymous, var customerSystemId: String = KundensystemID.Anonymous,
var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId, var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId,

View File

@ -138,6 +138,9 @@ class FinTsClientTest {
@Test @Test
fun getTanMediaList() { fun getTanMediaList() {
assertThat(Customer.tanMedia).isEmpty()
// when // when
val result = underTest.getTanMediaList(Bank, Customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien) val result = underTest.getTanMediaList(Bank, Customer, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien)
@ -148,6 +151,8 @@ class FinTsClientTest {
assertThat(result.tanMediaList).isNotNull() assertThat(result.tanMediaList).isNotNull()
assertThat(result.tanMediaList!!.usageOption).isEqualByComparingTo(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value assertThat(result.tanMediaList!!.usageOption).isEqualByComparingTo(TanEinsatzOption.KundeKannGenauEinMediumZuEinerZeitNutzen) // TODO: may adjust to your value
assertThat(result.tanMediaList!!.tanMedia).isNotEmpty() assertThat(result.tanMediaList!!.tanMedia).isNotEmpty()
assertThat(Customer.tanMedia).isNotEmpty()
} }
@Ignore // only works with banks that don't support HKTAB version 5 @Ignore // only works with banks that don't support HKTAB version 5