From e4aa38e11f04bc06cffcd1867a45f0f89558d235 Mon Sep 17 00:00:00 2001 From: dankito Date: Wed, 30 Sep 2020 02:24:13 +0200 Subject: [PATCH] Displaying now also response code to user. May she then can help us better (or she may even knows what to do with this information) --- .../dankito/banking/fints/response/BankResponse.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/BankResponse.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/BankResponse.kt index 79ef2609..0b979168 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/BankResponse.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/response/BankResponse.kt @@ -62,18 +62,26 @@ open class BankResponse( get() { val errorMessages = segmentFeedbacks .flatMap { it.feedbacks } - .mapNotNull { if (it.isError) it.message else null } + .mapNotNull { mapToMessageToShowToUser(it) } .toMutableList() messageFeedback?.let { messageFeedback -> if (messageFeedback.isError) { - errorMessages.addAll(0, messageFeedback.feedbacks.mapNotNull { if (it.isError) it.message else null }) + errorMessages.addAll(0, messageFeedback.feedbacks.mapNotNull { mapToMessageToShowToUser(it) }) } } return errorMessages } + protected open fun mapToMessageToShowToUser(feedback: Feedback): String? { + if (feedback.isError) { + return "${feedback.responseCode}: ${feedback.message}" + } + + return null + } + open var followUpResponse: BankResponse? = null