Implemented calling getTanMediaList() only if retrieving TAN media is supported

This commit is contained in:
dankito 2020-10-04 21:07:51 +02:00
parent 63ec9e074a
commit 24dfe34c1f
1 changed files with 34 additions and 19 deletions

View File

@ -11,6 +11,7 @@ import net.dankito.banking.fints.messages.datenelemente.implementierte.signatur.
import net.dankito.banking.fints.messages.datenelemente.implementierte.signatur.VersionDesSicherheitsverfahrens
import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.*
import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId
import net.dankito.banking.fints.messages.segmente.id.ISegmentId
import net.dankito.banking.fints.model.*
import net.dankito.banking.fints.response.InstituteSegmentId
import net.dankito.banking.fints.response.BankResponse
@ -271,7 +272,19 @@ open class FinTsClient(
/* Second dialog: some banks require that in order to initialize a dialog with strong customer authorization TAN media is required */
if (isJobSupported(bank, CustomerSegmentId.TanMediaList)) {
getTanMediaList(bank, TanMedienArtVersion.Alle, TanMediumKlasse.AlleMedien) {
addAccountGetAccountsAndTransactions(parameter, bank, didOverwriteUserUnselectedTanMethod, callback)
}
}
else {
addAccountGetAccountsAndTransactions(parameter, bank, didOverwriteUserUnselectedTanMethod, callback)
}
}
}
protected open fun addAccountGetAccountsAndTransactions(parameter: AddAccountParameter, bank: BankData, didOverwriteUserUnselectedTanMethod: Boolean,
callback: (AddAccountResponse) -> Unit) {
/* Third dialog: Now we can initialize our first dialog with strong customer authorization. Use it to get UPD and customer's accounts */
@ -292,8 +305,6 @@ open class FinTsClient(
}
}
}
}
}
protected open fun addAccountGetAccountBalancesAndTransactions(bank: BankData, getAccountsResponse: BankResponse,
didOverwriteUserUnselectedTanMethod: Boolean,
@ -1239,6 +1250,10 @@ open class FinTsClient(
}
protected open fun isJobSupported(bank: BankData, segmentId: ISegmentId): Boolean {
return bank.supportedJobs.map { it.jobName }.contains(segmentId.id)
}
protected open fun isJobSupported(account: AccountData, supportedJob: JobParameters): Boolean {
for (allowedJobName in account.allowedJobNames) {
if (allowedJobName == supportedJob.jobName) {