Renamed ClientResponseBase to FinTsClientResponse, gave getAnonymousBankInfo() a specific return parameter and extracted closeAnonymousDialog()

This commit is contained in:
dankl 2019-10-13 18:18:18 +02:00 committed by dankito
parent 46fef1695d
commit 637cbe8b07
3 changed files with 22 additions and 10 deletions

View File

@ -7,6 +7,7 @@ import net.dankito.fints.model.*
import net.dankito.fints.response.InstituteSegmentId import net.dankito.fints.response.InstituteSegmentId
import net.dankito.fints.response.Response import net.dankito.fints.response.Response
import net.dankito.fints.response.ResponseParser import net.dankito.fints.response.ResponseParser
import net.dankito.fints.response.client.FinTsClientResponse
import net.dankito.fints.response.client.GetTransactionsResponse import net.dankito.fints.response.client.GetTransactionsResponse
import net.dankito.fints.response.segments.* import net.dankito.fints.response.segments.*
import net.dankito.fints.util.IBase64Service import net.dankito.fints.util.IBase64Service
@ -31,7 +32,13 @@ open class FinTsClient(
} }
open fun getAnonymousBankInfo(bank: BankData): Response { /**
* Retrieves information about bank (e.g. supported HBCI versions, FinTS server address,
* supported jobs, ...).
*
* On success [bank] parameter is updated afterwards.
*/
open fun getAnonymousBankInfo(bank: BankData): FinTsClientResponse {
val dialogData = DialogData() val dialogData = DialogData()
val requestBody = messageBuilder.createAnonymousDialogInitMessage(bank, product, dialogData) val requestBody = messageBuilder.createAnonymousDialogInitMessage(bank, product, dialogData)
@ -41,7 +48,15 @@ open class FinTsClient(
if (response.successful) { if (response.successful) {
updateBankData(bank, response) updateBankData(bank, response)
closeAnonymousDialog(dialogData, response, bank)
}
return FinTsClientResponse(response)
}
protected open fun closeAnonymousDialog(dialogData: DialogData, response: Response, bank: BankData) {
dialogData.increaseMessageNumber() dialogData.increaseMessageNumber()
response.messageHeader?.let { header -> dialogData.dialogId = header.dialogId } response.messageHeader?.let { header -> dialogData.dialogId = header.dialogId }
val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(bank, dialogData) val dialogEndRequestBody = messageBuilder.createAnonymousDialogEndMessage(bank, dialogData)
@ -49,9 +64,6 @@ open class FinTsClient(
getResponseForMessage(dialogEndRequestBody, bank) getResponseForMessage(dialogEndRequestBody, bank)
} }
return response
}
open fun synchronizeCustomerSystemId(bank: BankData, customer: CustomerData): Response { open fun synchronizeCustomerSystemId(bank: BankData, customer: CustomerData): Response {

View File

@ -4,7 +4,7 @@ import net.dankito.fints.response.Response
import net.dankito.fints.response.segments.TanResponse import net.dankito.fints.response.segments.TanResponse
open class ClientResponseBase( open class FinTsClientResponse(
val successful: Boolean, val successful: Boolean,

View File

@ -11,4 +11,4 @@ open class GetTransactionsResponse(
val unbookedTransactions: List<Any> = listOf(), val unbookedTransactions: List<Any> = listOf(),
val balance: BigDecimal? = null val balance: BigDecimal? = null
) )
: ClientResponseBase(response) : FinTsClientResponse(response)