Generified checking if retrieving user's TAN procedures was successful

This commit is contained in:
dankito 2020-09-02 13:15:09 +02:00
parent 3ca7c2a3cf
commit e2199c8494
1 changed files with 8 additions and 6 deletions

View File

@ -1,6 +1,7 @@
package net.dankito.banking.fints.response.client package net.dankito.banking.fints.response.client
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.Response
import net.dankito.banking.fints.response.ResponseParser
open class GetUserTanProceduresResponse(bankResponse: Response) open class GetUserTanProceduresResponse(bankResponse: Response)
@ -9,18 +10,19 @@ open class GetUserTanProceduresResponse(bankResponse: Response)
/** /**
* comdirect sends "9955::Unzulässiges TAN-Verfahren." even though '999' is a valid TAN procedure * comdirect sends "9955::Unzulässiges TAN-Verfahren." even though '999' is a valid TAN procedure
* for init dialog if user's TAN procedures are not known yet * for init dialog if user's TAN procedures are not known yet and it contains a '3920:' feedback with user's TAN procedures
* -> check if the only error is '9955', then it's still a success. * -> if it contains a '3920:' feedback with user's TAN procedures, then it's still a success.
*/ */
override val successful: Boolean override val successful: Boolean
get() = noTanProcedureSelected == false && couldCreateMessage && didReceiveResponse get() = noTanProcedureSelected == false && couldCreateMessage && didReceiveResponse
&& tanRequiredButUserDidNotEnterOne == false && tanRequiredButUserDidNotEnterOne == false
&& (responseContainsErrors == false || containsOnlyInvalidTanProcedureError()) && (responseContainsErrors == false || containsUsersTanProceduresFeedback())
protected open fun containsOnlyInvalidTanProcedureError(): Boolean { protected open fun containsUsersTanProceduresFeedback(): Boolean {
val errorFeedbacks = segmentFeedbacks.flatMap { it.feedbacks }.filter { it.isError } val usersSupportedTanProceduresFeedback = segmentFeedbacks.flatMap { it.feedbacks }
.firstOrNull { it.responseCode == ResponseParser.SupportedTanProceduresForUserResponseCode }
return errorFeedbacks.size == 1 && errorFeedbacks.first().responseCode == 9955 return usersSupportedTanProceduresFeedback != null
} }
} }