Implemented if bank already closed dialog no close dialog message gets send anymore to bank

This commit is contained in:
dankito 2020-05-16 19:14:36 +02:00
parent 231bf41cb3
commit 124b3ca9f6
3 changed files with 13 additions and 0 deletions

View File

@ -99,6 +99,10 @@ open class FinTsClient @JvmOverloads constructor(
protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: Response) { protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: Response) {
if (dialogContext.didBankCloseDialog) { // bank already closed dialog -> there's no need to send dialog end message
return
}
val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(dialogContext) val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(dialogContext)
getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext) // TODO: really handle close dialog response? getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext) // TODO: really handle close dialog response?
@ -482,6 +486,10 @@ open class FinTsClient @JvmOverloads constructor(
protected open fun closeDialog(dialogContext: DialogContext) { protected open fun closeDialog(dialogContext: DialogContext) {
if (dialogContext.didBankCloseDialog) { // bank already closed dialog -> there's no need to send dialog end message
return
}
val dialogEndRequestBody = messageBuilder.createDialogEndMessage(dialogContext) val dialogEndRequestBody = messageBuilder.createDialogEndMessage(dialogContext)
getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext) // TODO: really handle close dialog response? getAndHandleResponseForMessage(dialogEndRequestBody, dialogContext) // TODO: really handle close dialog response?
@ -561,6 +569,7 @@ open class FinTsClient @JvmOverloads constructor(
dialogContext.response = response dialogContext.response = response
response.messageHeader?.let { header -> dialogContext.dialogId = header.dialogId } response.messageHeader?.let { header -> dialogContext.dialogId = header.dialogId }
dialogContext.didBankCloseDialog = response.didBankCloseDialog
return response return response
} }

View File

@ -11,6 +11,7 @@ open class DialogContext(
var currentMessage: MessageBuilderResult? = null, var currentMessage: MessageBuilderResult? = null,
var dialogId: String = InitialDialogId, var dialogId: String = InitialDialogId,
var response: Response? = null, var response: Response? = null,
var didBankCloseDialog: Boolean = false,
var previousMessageInDialog: MessageBuilderResult? = null var previousMessageInDialog: MessageBuilderResult? = null
) : MessageBaseData(bank, customer, product) { ) : MessageBaseData(bank, customer, product) {

View File

@ -46,6 +46,9 @@ open class Response(
open val messageFeedback: MessageFeedback? open val messageFeedback: MessageFeedback?
get() = getFirstSegmentById(InstituteSegmentId.MessageFeedback) get() = getFirstSegmentById(InstituteSegmentId.MessageFeedback)
open val didBankCloseDialog: Boolean
get() = messageFeedback?.feedbacks?.firstOrNull { it.responseCode == 9800 } != null
open val segmentFeedbacks: List<SegmentFeedback> open val segmentFeedbacks: List<SegmentFeedback>
get() = getSegmentsById(InstituteSegmentId.SegmentFeedback) get() = getSegmentsById(InstituteSegmentId.SegmentFeedback)