Set default values for (rare cases) changeTanProcedureTo and changeTanMediumTo; updated toString()

This commit is contained in:
dankl 2020-01-01 21:08:18 +01:00 committed by dankito
parent 0175296c66
commit 0660498ceb
1 changed files with 9 additions and 5 deletions

View File

@ -6,23 +6,23 @@ import net.dankito.fints.response.client.FinTsClientResponse
open class EnterTanResult protected constructor( open class EnterTanResult protected constructor(
val enteredTan: String?, val enteredTan: String?,
val changeTanProcedureTo: TanProcedure?, val changeTanProcedureTo: TanProcedure? = null,
val changeTanMediumTo: TanMedium?, val changeTanMediumTo: TanMedium? = null,
val changeTanMediumResultCallback: ((FinTsClientResponse) -> Unit)? = null val changeTanMediumResultCallback: ((FinTsClientResponse) -> Unit)? = null
) { ) {
companion object { companion object {
fun userEnteredTan(enteredTan: String): EnterTanResult { fun userEnteredTan(enteredTan: String): EnterTanResult {
return EnterTanResult(enteredTan, null, null) return EnterTanResult(enteredTan)
} }
fun userDidNotEnterTan(): EnterTanResult { fun userDidNotEnterTan(): EnterTanResult {
return EnterTanResult(null, null, null) return EnterTanResult(null)
} }
fun userAsksToChangeTanProcedure(changeTanProcedureTo: TanProcedure): EnterTanResult { fun userAsksToChangeTanProcedure(changeTanProcedureTo: TanProcedure): EnterTanResult {
return EnterTanResult(null, changeTanProcedureTo, null) return EnterTanResult(null, changeTanProcedureTo)
} }
fun userAsksToChangeTanMedium(changeTanMediumTo: TanMedium, changeTanMediumResultCallback: (FinTsClientResponse) -> Unit): EnterTanResult { fun userAsksToChangeTanMedium(changeTanMediumTo: TanMedium, changeTanMediumResultCallback: (FinTsClientResponse) -> Unit): EnterTanResult {
@ -32,6 +32,10 @@ open class EnterTanResult protected constructor(
} }
override fun toString(): String { override fun toString(): String {
if (changeTanProcedureTo != null) {
return "User asks to change TAN procedure to $changeTanProcedureTo"
}
if (changeTanMediumTo != null) { if (changeTanMediumTo != null) {
return "User asks to change TAN medium to $changeTanMediumTo" return "User asks to change TAN medium to $changeTanMediumTo"
} }