Extracted getBalanceAfterDialogInit(), moved initDialog() to closeDialog()

This commit is contained in:
dankl 2019-10-13 18:11:38 +02:00 committed by dankito
parent 1daaeeb8d8
commit 46fef1695d
1 changed files with 27 additions and 21 deletions

View File

@ -53,22 +53,6 @@ open class FinTsClient(
} }
open fun initDialog(bank: BankData, customer: CustomerData, dialogData: DialogData): Response {
val requestBody = messageBuilder.createInitDialogMessage(bank, customer, product, dialogData)
val response = getAndHandleResponseForMessage(requestBody, bank)
if (response.successful) {
updateBankData(bank, response)
updateCustomerData(customer, response)
response.messageHeader?.let { header -> dialogData.dialogId = header.dialogId }
}
return response
}
open fun synchronizeCustomerSystemId(bank: BankData, customer: CustomerData): Response { open fun synchronizeCustomerSystemId(bank: BankData, customer: CustomerData): Response {
val dialogData = DialogData() val dialogData = DialogData()
@ -104,11 +88,7 @@ open class FinTsClient(
var balance: BigDecimal? = null var balance: BigDecimal? = null
if (parameter.alsoRetrieveBalance) { if (parameter.alsoRetrieveBalance) {
dialogData.increaseMessageNumber() val balanceResponse = getBalanceAfterDialogInit(bank, customer, dialogData)
val balanceRequest = messageBuilder.createGetBalanceMessage(bank, customer, product, dialogData)
val balanceResponse = getAndHandleResponseForMessage(balanceRequest, bank)
if (balanceResponse.successful == false) { if (balanceResponse.successful == false) {
return GetTransactionsResponse(balanceResponse) return GetTransactionsResponse(balanceResponse)
@ -136,6 +116,16 @@ open class FinTsClient(
return GetTransactionsResponse(response) return GetTransactionsResponse(response)
} }
protected open fun getBalanceAfterDialogInit(bank: BankData, customer: CustomerData,
dialogData: DialogData): Response {
dialogData.increaseMessageNumber()
val balanceRequest = messageBuilder.createGetBalanceMessage(bank, customer, product, dialogData)
return getAndHandleResponseForMessage(balanceRequest, bank)
}
open fun doBankTransfer(bankTransferData: BankTransferData, bank: BankData, open fun doBankTransfer(bankTransferData: BankTransferData, bank: BankData,
customer: CustomerData): Response { customer: CustomerData): Response {
@ -161,6 +151,22 @@ open class FinTsClient(
} }
protected open fun initDialog(bank: BankData, customer: CustomerData, dialogData: DialogData): Response {
val requestBody = messageBuilder.createInitDialogMessage(bank, customer, product, dialogData)
val response = getAndHandleResponseForMessage(requestBody, bank)
if (response.successful) {
updateBankData(bank, response)
updateCustomerData(customer, response)
response.messageHeader?.let { header -> dialogData.dialogId = header.dialogId }
}
return response
}
protected open fun closeDialog(bank: BankData, customer: CustomerData, dialogData: DialogData) { protected open fun closeDialog(bank: BankData, customer: CustomerData, dialogData: DialogData) {
dialogData.increaseMessageNumber() dialogData.increaseMessageNumber()