Extracted createNoTanMethodSelectedResponse()

This commit is contained in:
dankito 2021-11-01 15:56:25 +01:00
parent fed10e21c0
commit dee1fd7211
1 changed files with 16 additions and 14 deletions

View File

@ -156,15 +156,11 @@ open class FinTsJobExecutor(
getAnonymousBankInfo(bank) { anonymousBankInfoResponse -> getAnonymousBankInfo(bank) { anonymousBankInfoResponse ->
if (anonymousBankInfoResponse.successful == false) { if (anonymousBankInfoResponse.successful == false) {
callback(anonymousBankInfoResponse) callback(anonymousBankInfoResponse)
} } else if (bank.tanMethodSupportedByBank.isEmpty()) { // should only be a theoretical error
else if (bank.tanMethodSupportedByBank.isEmpty()) { // should only be a theoretical error callback(BankResponse(true, errorMessage = "Die TAN Verfahren der Bank konnten nicht ermittelt werden")) // TODO: translate
callback( } else {
BankResponse(true,
errorMessage = "Die TAN Verfahren der Bank konnten nicht ermittelt werden")
) // TODO: translate
}
else {
bank.tanMethodsAvailableForUser = bank.tanMethodSupportedByBank bank.tanMethodsAvailableForUser = bank.tanMethodSupportedByBank
getUsersTanMethod(bank) { didSelectTanMethod -> getUsersTanMethod(bank) { didSelectTanMethod ->
if (didSelectTanMethod) { if (didSelectTanMethod) {
val dialogContext = DialogContext(bank, product) val dialogContext = DialogContext(bank, product)
@ -174,9 +170,8 @@ open class FinTsJobExecutor(
callback(initDialogResponse) callback(initDialogResponse)
} }
} } else {
else { callback(createNoTanMethodSelectedResponse(bank))
callback(BankResponse(false))
} }
} }
} }
@ -653,15 +648,22 @@ open class FinTsJobExecutor(
} }
else { else {
getUsersTanMethod(bank) { getUsersTanMethod(bank) {
callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected)) callback(createNoTanMethodSelectedResponse(bank))
} }
} }
} }
else { else {
callback(BankResponse(bank.isTanMethodSelected, noTanMethodSelected = !!!bank.isTanMethodSelected)) callback(createNoTanMethodSelectedResponse(bank))
} }
} }
private fun createNoTanMethodSelectedResponse(bank: BankData): BankResponse {
val noTanMethodSelected = !!!bank.isTanMethodSelected
val errorMessage = if (noTanMethodSelected) "User did not select a TAN method" else null // TODO: translate
return BankResponse(true, noTanMethodSelected = noTanMethodSelected, errorMessage = errorMessage)
}
open fun getUsersTanMethod(bank: BankData, done: (Boolean) -> Unit) { open fun getUsersTanMethod(bank: BankData, done: (Boolean) -> Unit) {
if (bank.tanMethodsAvailableForUser.size == 1) { // user has only one TAN method -> set it and we're done if (bank.tanMethodsAvailableForUser.size == 1) { // user has only one TAN method -> set it and we're done
bank.selectedTanMethod = bank.tanMethodsAvailableForUser.first() bank.selectedTanMethod = bank.tanMethodsAvailableForUser.first()