Moved DialogContext.increaseMessageNumber() to a central place
This commit is contained in:
parent
f21227c5fa
commit
57911d835e
|
@ -91,7 +91,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: Response) {
|
protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: Response) {
|
||||||
dialogContext.increaseMessageNumber() // TODO: move to MessageBuilder
|
|
||||||
|
|
||||||
val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(dialogContext)
|
val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(dialogContext)
|
||||||
|
|
||||||
|
@ -273,10 +272,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
balanceResponse.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
|
balanceResponse.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
|
||||||
balance = it.balance
|
balance = it.balance
|
||||||
}
|
}
|
||||||
|
|
||||||
if (balanceResponse.didReceiveResponse) {
|
|
||||||
dialogContext.increaseMessageNumber() // TODO: move to MessageBuilder
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,8 +330,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
|
|
||||||
protected open fun getBalanceAfterDialogInit(account: AccountData, dialogContext: DialogContext): Response {
|
protected open fun getBalanceAfterDialogInit(account: AccountData, dialogContext: DialogContext): Response {
|
||||||
|
|
||||||
dialogContext.increaseMessageNumber() // TODO: move to MessageBuilder
|
|
||||||
|
|
||||||
val message = messageBuilder.createGetBalanceMessage(account, dialogContext)
|
val message = messageBuilder.createGetBalanceMessage(account, dialogContext)
|
||||||
|
|
||||||
return getAndHandleResponseForMessage(message, dialogContext)
|
return getAndHandleResponseForMessage(message, dialogContext)
|
||||||
|
@ -426,8 +419,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dialogContext.increaseMessageNumber() // TODO: move to MessageBuilder
|
|
||||||
|
|
||||||
val message = createMessage(dialogContext)
|
val message = createMessage(dialogContext)
|
||||||
|
|
||||||
val response = if (messageMayRequiresTan) getAndHandleResponseForMessageThatMayRequiresTan(message, dialogContext)
|
val response = if (messageMayRequiresTan) getAndHandleResponseForMessageThatMayRequiresTan(message, dialogContext)
|
||||||
|
@ -474,7 +465,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun closeDialog(dialogContext: DialogContext) {
|
protected open fun closeDialog(dialogContext: DialogContext) {
|
||||||
dialogContext.increaseMessageNumber() // TODO: move to MessageBuilder
|
|
||||||
|
|
||||||
val dialogEndRequestBody = messageBuilder.createDialogEndMessage(dialogContext)
|
val dialogEndRequestBody = messageBuilder.createDialogEndMessage(dialogContext)
|
||||||
|
|
||||||
|
@ -674,9 +664,6 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
|
|
||||||
protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, dialogContext: DialogContext): Response {
|
protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, dialogContext: DialogContext): Response {
|
||||||
|
|
||||||
|
|
||||||
dialogContext.increaseMessageNumber() // TODO: move to MessageBuilder
|
|
||||||
|
|
||||||
val message = messageBuilder.createSendEnteredTanMessage(enteredTan, tanResponse, dialogContext)
|
val message = messageBuilder.createSendEnteredTanMessage(enteredTan, tanResponse, dialogContext)
|
||||||
|
|
||||||
// TODO: shouldn't we use MessageBuilderResult here as well?
|
// TODO: shouldn't we use MessageBuilderResult here as well?
|
||||||
|
|
|
@ -304,6 +304,8 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg
|
||||||
|
|
||||||
open fun createMessage(dialogContext: DialogContext, payloadSegments: List<Segment>): String {
|
open fun createMessage(dialogContext: DialogContext, payloadSegments: List<Segment>): String {
|
||||||
|
|
||||||
|
dialogContext.increaseMessageNumber()
|
||||||
|
|
||||||
val formattedPayload = formatPayload(payloadSegments)
|
val formattedPayload = formatPayload(payloadSegments)
|
||||||
|
|
||||||
val messageSize = formattedPayload.length + MessageHeaderLength + MessageEndingLength + AddedSeparatorsLength
|
val messageSize = formattedPayload.length + MessageHeaderLength + MessageEndingLength + AddedSeparatorsLength
|
||||||
|
|
|
@ -10,7 +10,6 @@ open class DialogContext(
|
||||||
product: ProductData,
|
product: ProductData,
|
||||||
var currentMessage: MessageBuilderResult? = null,
|
var currentMessage: MessageBuilderResult? = null,
|
||||||
var dialogId: String = InitialDialogId,
|
var dialogId: String = InitialDialogId,
|
||||||
var messageNumber: Int = InitialMessageNumber,
|
|
||||||
var response: Response? = null,
|
var response: Response? = null,
|
||||||
var previousMessageInDialog: MessageBuilderResult? = null
|
var previousMessageInDialog: MessageBuilderResult? = null
|
||||||
) : MessageBaseData(bank, customer, product) {
|
) : MessageBaseData(bank, customer, product) {
|
||||||
|
@ -18,11 +17,13 @@ open class DialogContext(
|
||||||
companion object {
|
companion object {
|
||||||
const val InitialDialogId = "0"
|
const val InitialDialogId = "0"
|
||||||
|
|
||||||
const val InitialMessageNumber = 1
|
const val InitialMessageNumber = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open var messageNumber: Int = InitialMessageNumber
|
||||||
|
protected set
|
||||||
|
|
||||||
fun increaseMessageNumber() {
|
open fun increaseMessageNumber() {
|
||||||
messageNumber++
|
messageNumber++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue