Renamed Response to BankResponse

This commit is contained in:
dankito 2020-09-20 16:12:45 +02:00
parent c576673efb
commit 7a64177d47
11 changed files with 77 additions and 77 deletions

View File

@ -13,7 +13,7 @@ import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.*
import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId import net.dankito.banking.fints.messages.segmente.id.CustomerSegmentId
import net.dankito.banking.fints.model.* import net.dankito.banking.fints.model.*
import net.dankito.banking.fints.response.InstituteSegmentId import net.dankito.banking.fints.response.InstituteSegmentId
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
import net.dankito.banking.fints.response.ResponseParser import net.dankito.banking.fints.response.ResponseParser
import net.dankito.banking.fints.response.client.* import net.dankito.banking.fints.response.client.*
import net.dankito.banking.fints.response.segments.* import net.dankito.banking.fints.response.segments.*
@ -86,7 +86,7 @@ open class FinTsClient(
} }
} }
protected open fun getAnonymousBankInfoInternal(bank: BankData, callback: (Response) -> Unit) { protected open fun getAnonymousBankInfoInternal(bank: BankData, callback: (BankResponse) -> Unit) {
val dialogContext = DialogContext(bank, product) val dialogContext = DialogContext(bank, product)
val message = messageBuilder.createAnonymousDialogInitMessage(dialogContext) val message = messageBuilder.createAnonymousDialogInitMessage(dialogContext)
@ -102,7 +102,7 @@ open class FinTsClient(
} }
} }
protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: Response) { protected open fun closeAnonymousDialog(dialogContext: DialogContext, response: BankResponse) {
// bank already closed dialog -> there's no need to send dialog end message // bank already closed dialog -> there's no need to send dialog end message
if (areWeThatGentleToCloseDialogs == false || dialogContext.didBankCloseDialog) { if (areWeThatGentleToCloseDialogs == false || dialogContext.didBankCloseDialog) {
@ -121,7 +121,7 @@ open class FinTsClient(
} }
} }
protected open fun getUsersTanProceduresInternal(bank: BankData, callback: (Response) -> Unit) { protected open fun getUsersTanProceduresInternal(bank: BankData, callback: (BankResponse) -> Unit) {
// just to ensure settings are in its initial state and that bank sends us bank parameter (BPD), // just to ensure settings are in its initial state and that bank sends us bank parameter (BPD),
// user parameter (UPD) and allowed tan procedures for user (therefore the resetSelectedTanProcedure()) // user parameter (UPD) and allowed tan procedures for user (therefore the resetSelectedTanProcedure())
bank.resetBpdVersion() bank.resetBpdVersion()
@ -146,7 +146,7 @@ open class FinTsClient(
} }
} }
protected open fun handleGetUsersTanProceduresResponse(response: Response, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun handleGetUsersTanProceduresResponse(response: BankResponse, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
val getUsersTanProceduresResponse = GetUserTanProceduresResponse(response) val getUsersTanProceduresResponse = GetUserTanProceduresResponse(response)
if (getUsersTanProceduresResponse.successful) { // TODO: really update data only on complete successfully response? as it may contain useful information anyway // TODO: extract method for this code part if (getUsersTanProceduresResponse.successful) { // TODO: really update data only on complete successfully response? as it may contain useful information anyway // TODO: extract method for this code part
@ -163,20 +163,20 @@ open class FinTsClient(
} }
} }
protected open fun bankDoesNotSupportRetrievingUsersTanProcedures(response: Response): Boolean { protected open fun bankDoesNotSupportRetrievingUsersTanProcedures(response: BankResponse): Boolean {
return response.successful == false && return response.successful == false &&
response.segmentFeedbacks.flatMap { it.feedbacks }.firstOrNull { it.responseCode == 9200 && response.segmentFeedbacks.flatMap { it.feedbacks }.firstOrNull { it.responseCode == 9200 &&
it.message == "Gewähltes Zwei-Schritt-Verfahren nicht unterstützt." } != null it.message == "Gewähltes Zwei-Schritt-Verfahren nicht unterstützt." } != null
} }
// TODO: this is only a quick fix. Find a better and general solution // TODO: this is only a quick fix. Find a better and general solution
protected open fun getBankAndCustomerInfoForNewUserViaAnonymousDialog(bank: BankData, callback: (Response) -> Unit) { protected open fun getBankAndCustomerInfoForNewUserViaAnonymousDialog(bank: BankData, callback: (BankResponse) -> Unit) {
getAnonymousBankInfoInternal(bank) { anonymousBankInfoResponse -> getAnonymousBankInfoInternal(bank) { anonymousBankInfoResponse ->
if (anonymousBankInfoResponse.successful == false) { if (anonymousBankInfoResponse.successful == false) {
callback(anonymousBankInfoResponse) callback(anonymousBankInfoResponse)
} }
else if (bank.tanProceduresSupportedByBank.isEmpty()) { // should only be a theoretical error else if (bank.tanProceduresSupportedByBank.isEmpty()) { // should only be a theoretical error
callback(Response(true, callback(BankResponse(true,
errorMessage = "Die TAN Verfahren der Bank konnten nicht ermittelt werden")) // TODO: translate errorMessage = "Die TAN Verfahren der Bank konnten nicht ermittelt werden")) // TODO: translate
} }
else { else {
@ -195,7 +195,7 @@ open class FinTsClient(
} }
protected open fun getAccounts(bank: BankData, callback: (Response) -> Unit) { protected open fun getAccounts(bank: BankData, callback: (BankResponse) -> Unit) {
val dialogContext = DialogContext(bank, product) val dialogContext = DialogContext(bank, product)
@ -292,7 +292,7 @@ open class FinTsClient(
} }
} }
protected open fun addAccountGetAccountBalancesAndTransactions(bank: BankData, newUserInfoResponse: Response, protected open fun addAccountGetAccountBalancesAndTransactions(bank: BankData, newUserInfoResponse: BankResponse,
didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean, didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean,
callback: (AddAccountResponse) -> Unit) { callback: (AddAccountResponse) -> Unit) {
// TODO: or add a default RetrievedAccountData instance for each account? // TODO: or add a default RetrievedAccountData instance for each account?
@ -320,7 +320,7 @@ open class FinTsClient(
} }
} }
protected open fun addAccountAfterRetrievingTransactions(bank: BankData, newUserInfoResponse: Response, protected open fun addAccountAfterRetrievingTransactions(bank: BankData, newUserInfoResponse: BankResponse,
didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean, didOverwriteUserUnselectedTanProcedure: Boolean, originalAreWeThatGentleToCloseDialogs: Boolean,
retrievedAccountData: List<RetrievedAccountData>, retrievedAccountData: List<RetrievedAccountData>,
callback: (AddAccountResponse) -> Unit) { callback: (AddAccountResponse) -> Unit) {
@ -374,7 +374,7 @@ open class FinTsClient(
} }
protected open fun getTransactionsAfterInitAndGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext, protected open fun getTransactionsAfterInitAndGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext,
balanceResponse: Response, callback: (GetTransactionsResponse) -> Unit) { balanceResponse: BankResponse, callback: (GetTransactionsResponse) -> Unit) {
val balance: Money? = balanceResponse.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let { val balance: Money? = balanceResponse.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
Money(it.balance, it.currency) Money(it.balance, it.currency)
} }
@ -409,7 +409,7 @@ open class FinTsClient(
} }
} }
protected open fun mayGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun mayGetBalance(parameter: GetTransactionsParameter, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
if (parameter.alsoRetrieveBalance && parameter.account.supportsFeature(AccountFeature.RetrieveBalance)) { if (parameter.alsoRetrieveBalance && parameter.account.supportsFeature(AccountFeature.RetrieveBalance)) {
val message = messageBuilder.createGetBalanceMessage(parameter.account, dialogContext) val message = messageBuilder.createGetBalanceMessage(parameter.account, dialogContext)
@ -439,7 +439,7 @@ open class FinTsClient(
} }
} }
private fun handleGetTanMediaListResponse(response: Response, bank: BankData, callback: (GetTanMediaListResponse) -> Unit) { private fun handleGetTanMediaListResponse(response: BankResponse, bank: BankData, callback: (GetTanMediaListResponse) -> Unit) {
// TAN media list (= TAN generator list) is only returned for users with chipTAN TAN procedures // TAN media list (= TAN generator list) is only returned for users with chipTAN TAN procedures
val tanMediaList = if (response.successful == false) null val tanMediaList = if (response.successful == false) null
else response.getFirstSegmentById<TanMediaList>(InstituteSegmentId.TanMediaList) else response.getFirstSegmentById<TanMediaList>(InstituteSegmentId.TanMediaList)
@ -458,13 +458,13 @@ open class FinTsClient(
} }
} }
protected open fun changeTanMediumInternal(newActiveTanMedium: TanGeneratorTanMedium, bank: BankData, callback: (Response) -> Unit) { protected open fun changeTanMediumInternal(newActiveTanMedium: TanGeneratorTanMedium, bank: BankData, callback: (BankResponse) -> Unit) {
if (bank.changeTanMediumParameters?.enteringAtcAndTanRequired == true) { if (bank.changeTanMediumParameters?.enteringAtcAndTanRequired == true) {
this.callback.enterTanGeneratorAtc(bank, newActiveTanMedium) { enteredAtc -> this.callback.enterTanGeneratorAtc(bank, newActiveTanMedium) { enteredAtc ->
if (enteredAtc.hasAtcBeenEntered == false) { if (enteredAtc.hasAtcBeenEntered == false) {
val message = "Bank requires to enter ATC and TAN in order to change TAN medium." // TODO: translate val message = "Bank requires to enter ATC and TAN in order to change TAN medium." // TODO: translate
callback(Response(false, errorMessage = message)) callback(BankResponse(false, errorMessage = message))
} }
else { else {
sendChangeTanMediumMessage(bank, newActiveTanMedium, enteredAtc, callback) sendChangeTanMediumMessage(bank, newActiveTanMedium, enteredAtc, callback)
@ -477,7 +477,7 @@ open class FinTsClient(
} }
protected open fun sendChangeTanMediumMessage(bank: BankData, newActiveTanMedium: TanGeneratorTanMedium, enteredAtc: EnterTanGeneratorAtcResult?, protected open fun sendChangeTanMediumMessage(bank: BankData, newActiveTanMedium: TanGeneratorTanMedium, enteredAtc: EnterTanGeneratorAtcResult?,
callback: (Response) -> Unit) { callback: (BankResponse) -> Unit) {
sendMessageAndHandleResponse(bank, false, null, { dialogContext -> sendMessageAndHandleResponse(bank, false, null, { dialogContext ->
messageBuilder.createChangeTanMediumMessage(newActiveTanMedium, dialogContext, enteredAtc?.tan, enteredAtc?.atc) messageBuilder.createChangeTanMediumMessage(newActiveTanMedium, dialogContext, enteredAtc?.tan, enteredAtc?.atc)
@ -498,7 +498,7 @@ open class FinTsClient(
protected open fun sendMessageAndHandleResponse(bank: BankData, messageMayRequiresTan: Boolean = true, segmentForNonStrongCustomerAuthenticationTwoStepTanProcess: CustomerSegmentId? = null, protected open fun sendMessageAndHandleResponse(bank: BankData, messageMayRequiresTan: Boolean = true, segmentForNonStrongCustomerAuthenticationTwoStepTanProcess: CustomerSegmentId? = null,
createMessage: (DialogContext) -> MessageBuilderResult, callback: (Response) -> Unit) { createMessage: (DialogContext) -> MessageBuilderResult, callback: (BankResponse) -> Unit) {
val dialogContext = DialogContext(bank, product) val dialogContext = DialogContext(bank, product)
@ -514,7 +514,7 @@ open class FinTsClient(
} }
} }
private fun sendMessageAndHandleResponseAfterDialogInitialization(dialogContext: DialogContext, initDialogResponse: Response, createMessage: (DialogContext) -> MessageBuilderResult, callback: (Response) -> Unit) { private fun sendMessageAndHandleResponseAfterDialogInitialization(dialogContext: DialogContext, initDialogResponse: BankResponse, createMessage: (DialogContext) -> MessageBuilderResult, callback: (BankResponse) -> Unit) {
if (initDialogResponse.successful == false) { if (initDialogResponse.successful == false) {
callback(initDialogResponse) callback(initDialogResponse)
@ -530,7 +530,7 @@ open class FinTsClient(
} }
} }
protected open fun initDialog(dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun initDialog(dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
// we first need to retrieve supported tan procedures and jobs before we can do anything // we first need to retrieve supported tan procedures and jobs before we can do anything
ensureBasicBankDataRetrieved(dialogContext.bank) { retrieveBasicBankDataResponse -> ensureBasicBankDataRetrieved(dialogContext.bank) { retrieveBasicBankDataResponse ->
@ -551,7 +551,7 @@ open class FinTsClient(
} }
} }
protected open fun initDialogAfterSuccessfulChecks(dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun initDialogAfterSuccessfulChecks(dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
val message = messageBuilder.createInitDialogMessage(dialogContext) val message = messageBuilder.createInitDialogMessage(dialogContext)
@ -567,7 +567,7 @@ open class FinTsClient(
} }
protected open fun initInitDialogMessageWithoutStrongCustomerAuthenticationAfterSuccessfulChecks(dialogContext: DialogContext, segmentIdForTwoStepTanProcess: CustomerSegmentId?, protected open fun initInitDialogMessageWithoutStrongCustomerAuthenticationAfterSuccessfulChecks(dialogContext: DialogContext, segmentIdForTwoStepTanProcess: CustomerSegmentId?,
callback: (Response) -> Unit) { callback: (BankResponse) -> Unit) {
val message = messageBuilder.createInitDialogMessageWithoutStrongCustomerAuthentication(dialogContext, segmentIdForTwoStepTanProcess) val message = messageBuilder.createInitDialogMessageWithoutStrongCustomerAuthentication(dialogContext, segmentIdForTwoStepTanProcess)
@ -594,45 +594,45 @@ open class FinTsClient(
} }
protected open fun ensureBasicBankDataRetrieved(bank: BankData, callback: (Response) -> Unit) { protected open fun ensureBasicBankDataRetrieved(bank: BankData, callback: (BankResponse) -> Unit) {
if (bank.tanProceduresSupportedByBank.isEmpty() || bank.supportedJobs.isEmpty()) { if (bank.tanProceduresSupportedByBank.isEmpty() || bank.supportedJobs.isEmpty()) {
getUsersTanProceduresInternal(bank) { getBankInfoResponse -> getUsersTanProceduresInternal(bank) { getBankInfoResponse ->
if (getBankInfoResponse.successful == false || bank.tanProceduresSupportedByBank.isEmpty() if (getBankInfoResponse.successful == false || bank.tanProceduresSupportedByBank.isEmpty()
|| bank.supportedJobs.isEmpty()) { || bank.supportedJobs.isEmpty()) {
callback(Response(false, errorMessage = callback(BankResponse(false, errorMessage =
"Could not retrieve basic bank data like supported tan procedures or supported jobs")) // TODO: translate // TODO: add as messageToShowToUser "Could not retrieve basic bank data like supported tan procedures or supported jobs")) // TODO: translate // TODO: add as messageToShowToUser
} }
else { else {
callback(Response(true)) callback(BankResponse(true))
} }
} }
} }
else { else {
callback(Response(true)) callback(BankResponse(true))
} }
} }
protected open fun ensureTanProcedureIsSelected(bank: BankData, callback: (Response) -> Unit) { protected open fun ensureTanProcedureIsSelected(bank: BankData, callback: (BankResponse) -> Unit) {
if (bank.isTanProcedureSelected == false) { if (bank.isTanProcedureSelected == false) {
if (bank.tanProceduresAvailableForUser.isEmpty()) { if (bank.tanProceduresAvailableForUser.isEmpty()) {
getUsersTanProceduresInternal(bank) { getUsersTanProceduresInternal(bank) {
if (bank.tanProceduresAvailableForUser.isEmpty()) { // could not retrieve supported tan procedures for user if (bank.tanProceduresAvailableForUser.isEmpty()) { // could not retrieve supported tan procedures for user
callback(Response(false, noTanProcedureSelected = true)) callback(BankResponse(false, noTanProcedureSelected = true))
} }
else { else {
getUsersTanProcedure(bank) getUsersTanProcedure(bank)
callback(Response(bank.isTanProcedureSelected, noTanProcedureSelected = !!!bank.isTanProcedureSelected)) callback(BankResponse(bank.isTanProcedureSelected, noTanProcedureSelected = !!!bank.isTanProcedureSelected))
} }
} }
} }
else { else {
getUsersTanProcedure(bank) getUsersTanProcedure(bank)
callback(Response(bank.isTanProcedureSelected, noTanProcedureSelected = !!!bank.isTanProcedureSelected)) callback(BankResponse(bank.isTanProcedureSelected, noTanProcedureSelected = !!!bank.isTanProcedureSelected))
} }
} }
else { else {
callback(Response(bank.isTanProcedureSelected, noTanProcedureSelected = !!!bank.isTanProcedureSelected)) callback(BankResponse(bank.isTanProcedureSelected, noTanProcedureSelected = !!!bank.isTanProcedureSelected))
} }
} }
@ -658,9 +658,9 @@ open class FinTsClient(
} }
protected open fun getAndHandleResponseForMessage(message: MessageBuilderResult, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun getAndHandleResponseForMessage(message: MessageBuilderResult, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
if (message.createdMessage == null) { if (message.createdMessage == null) {
callback(Response(false, messageCreationError = message)) callback(BankResponse(false, messageCreationError = message))
} }
else { else {
getAndHandleResponseForMessage(message.createdMessage, dialogContext) { response -> getAndHandleResponseForMessage(message.createdMessage, dialogContext) { response ->
@ -697,7 +697,7 @@ open class FinTsClient(
} }
} }
protected open fun getAndHandleResponseForMessage(requestBody: String, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun getAndHandleResponseForMessage(requestBody: String, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
addMessageLog(requestBody, MessageLogEntryType.Sent, dialogContext) addMessageLog(requestBody, MessageLogEntryType.Sent, dialogContext)
getResponseForMessage(requestBody, dialogContext.bank.finTs3ServerAddress) { webResponse -> getResponseForMessage(requestBody, dialogContext.bank.finTs3ServerAddress) { webResponse ->
@ -728,7 +728,7 @@ open class FinTsClient(
} }
} }
protected open fun handleResponse(webResponse: WebClientResponse, dialogContext: DialogContext): Response { protected open fun handleResponse(webResponse: WebClientResponse, dialogContext: DialogContext): BankResponse {
val responseBody = webResponse.body val responseBody = webResponse.body
if (webResponse.successful && responseBody != null) { if (webResponse.successful && responseBody != null) {
@ -742,7 +742,7 @@ open class FinTsClient(
} catch (e: Exception) { } catch (e: Exception) {
log.error(e) { "Could not decode responseBody:\r\n'$responseBody'" } log.error(e) { "Could not decode responseBody:\r\n'$responseBody'" }
return Response(false, errorMessage = e.getInnerExceptionMessage()) return BankResponse(false, errorMessage = e.getInnerExceptionMessage())
} }
} }
else { else {
@ -750,7 +750,7 @@ open class FinTsClient(
log.error(webResponse.error) { "Request to $bank (${bank.finTs3ServerAddress}) failed" } log.error(webResponse.error) { "Request to $bank (${bank.finTs3ServerAddress}) failed" }
} }
return Response(false, errorMessage = webResponse.error?.getInnerExceptionMessage()) return BankResponse(false, errorMessage = webResponse.error?.getInnerExceptionMessage())
} }
protected open fun decodeBase64Response(responseBody: String): String { protected open fun decodeBase64Response(responseBody: String): String {
@ -758,8 +758,8 @@ open class FinTsClient(
} }
protected open fun getFollowUpMessageForContinuationId(response: Response, continuationId: String, message: MessageBuilderResult, protected open fun getFollowUpMessageForContinuationId(response: BankResponse, continuationId: String, message: MessageBuilderResult,
dialogContext: DialogContext, callback: (Response?) -> Unit) { dialogContext: DialogContext, callback: (BankResponse?) -> Unit) {
messageBuilder.rebuildMessageWithContinuationId(message, continuationId, dialogContext)?.let { followUpMessage -> messageBuilder.rebuildMessageWithContinuationId(message, continuationId, dialogContext)?.let { followUpMessage ->
getAndHandleResponseForMessage(followUpMessage, dialogContext, callback) getAndHandleResponseForMessage(followUpMessage, dialogContext, callback)
@ -817,7 +817,7 @@ open class FinTsClient(
} }
protected open fun handleMayRequiresTan(response: Response, dialogContext: DialogContext, callback: (Response) -> Unit) { // TODO: use response from DialogContext protected open fun handleMayRequiresTan(response: BankResponse, dialogContext: DialogContext, callback: (BankResponse) -> Unit) { // TODO: use response from DialogContext
if (response.isStrongAuthenticationRequired) { if (response.isStrongAuthenticationRequired) {
if (dialogContext.abortIfTanIsRequired) { if (dialogContext.abortIfTanIsRequired) {
@ -845,7 +845,7 @@ open class FinTsClient(
callback(response) callback(response)
} }
protected open fun handleEnteringTanRequired(tanResponse: TanResponse, response: Response, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun handleEnteringTanRequired(tanResponse: TanResponse, response: BankResponse, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
val bank = dialogContext.bank // TODO: copy required data to TanChallenge val bank = dialogContext.bank // TODO: copy required data to TanChallenge
val tanChallenge = createTanChallenge(tanResponse, bank) val tanChallenge = createTanChallenge(tanResponse, bank)
@ -873,8 +873,8 @@ open class FinTsClient(
} }
} }
protected open fun handleEnterTanResult(enteredTanResult: EnterTanResult, tanResponse: TanResponse, response: Response, protected open fun handleEnterTanResult(enteredTanResult: EnterTanResult, tanResponse: TanResponse, response: BankResponse,
dialogContext: DialogContext, callback: (Response) -> Unit) { dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
if (enteredTanResult.changeTanProcedureTo != null) { if (enteredTanResult.changeTanProcedureTo != null) {
handleUserAsksToChangeTanProcedureAndResendLastMessage(enteredTanResult.changeTanProcedureTo, dialogContext, callback) handleUserAsksToChangeTanProcedureAndResendLastMessage(enteredTanResult.changeTanProcedureTo, dialogContext, callback)
@ -895,14 +895,14 @@ open class FinTsClient(
} }
} }
protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
val message = messageBuilder.createSendEnteredTanMessage(enteredTan, tanResponse, dialogContext) val message = messageBuilder.createSendEnteredTanMessage(enteredTan, tanResponse, dialogContext)
getAndHandleResponseForMessage(message, dialogContext, callback) getAndHandleResponseForMessage(message, dialogContext, callback)
} }
protected open fun handleUserAsksToChangeTanProcedureAndResendLastMessage(changeTanProcedureTo: TanProcedure, dialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun handleUserAsksToChangeTanProcedureAndResendLastMessage(changeTanProcedureTo: TanProcedure, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
dialogContext.bank.selectedTanProcedure = changeTanProcedureTo dialogContext.bank.selectedTanProcedure = changeTanProcedureTo
@ -917,7 +917,7 @@ open class FinTsClient(
protected open fun handleUserAsksToChangeTanMediumAndResendLastMessage(changeTanMediumTo: TanGeneratorTanMedium, protected open fun handleUserAsksToChangeTanMediumAndResendLastMessage(changeTanMediumTo: TanGeneratorTanMedium,
dialogContext: DialogContext, dialogContext: DialogContext,
changeTanMediumResultCallback: ((FinTsClientResponse) -> Unit)?, changeTanMediumResultCallback: ((FinTsClientResponse) -> Unit)?,
callback: (Response) -> Unit) { callback: (BankResponse) -> Unit) {
val lastCreatedMessage = dialogContext.currentMessage val lastCreatedMessage = dialogContext.currentMessage
@ -937,7 +937,7 @@ open class FinTsClient(
} }
protected open fun resendMessageInNewDialog(lastCreatedMessage: MessageBuilderResult?, previousDialogContext: DialogContext, callback: (Response) -> Unit) { protected open fun resendMessageInNewDialog(lastCreatedMessage: MessageBuilderResult?, previousDialogContext: DialogContext, callback: (BankResponse) -> Unit) {
if (lastCreatedMessage != null) { // do not use previousDialogContext.currentMessage as this may is previous dialog's dialog close message if (lastCreatedMessage != null) { // do not use previousDialogContext.currentMessage as this may is previous dialog's dialog close message
val newDialogContext = DialogContext(previousDialogContext.bank, previousDialogContext.product, chunkedResponseHandler = previousDialogContext.chunkedResponseHandler) val newDialogContext = DialogContext(previousDialogContext.bank, previousDialogContext.product, chunkedResponseHandler = previousDialogContext.chunkedResponseHandler)
@ -959,12 +959,12 @@ open class FinTsClient(
} }
else { else {
val errorMessage = "There's no last action (like retrieve account transactions, transfer money, ...) to re-send with new TAN procedure. Probably an internal programming error." // TODO: translate val errorMessage = "There's no last action (like retrieve account transactions, transfer money, ...) to re-send with new TAN procedure. Probably an internal programming error." // TODO: translate
callback(Response(false, errorMessage = errorMessage)) // should never come to this callback(BankResponse(false, errorMessage = errorMessage)) // should never come to this
} }
} }
protected open fun updateBankData(bank: BankData, response: Response) { protected open fun updateBankData(bank: BankData, response: BankResponse) {
response.getFirstSegmentById<BankParameters>(InstituteSegmentId.BankParameters)?.let { bankParameters -> response.getFirstSegmentById<BankParameters>(InstituteSegmentId.BankParameters)?.let { bankParameters ->
bank.bpdVersion = bankParameters.bpdVersion bank.bpdVersion = bankParameters.bpdVersion
bank.bankName = adjustBankName(bankParameters.bankName) bank.bankName = adjustBankName(bankParameters.bankName)
@ -1010,7 +1010,7 @@ open class FinTsClient(
return bankName.replace("DB24-Filiale", "Deutsche Bank") // set a better name for Deutsche Bank's self title 'DB24-Filiale' return bankName.replace("DB24-Filiale", "Deutsche Bank") // set a better name for Deutsche Bank's self title 'DB24-Filiale'
} }
protected open fun updateCustomerData(bank: BankData, response: Response) { protected open fun updateCustomerData(bank: BankData, response: BankResponse) {
response.getFirstSegmentById<BankParameters>(InstituteSegmentId.BankParameters)?.let { bankParameters -> response.getFirstSegmentById<BankParameters>(InstituteSegmentId.BankParameters)?.let { bankParameters ->
// TODO: ask user if there is more than one supported language? But it seems that almost all banks only support German. // TODO: ask user if there is more than one supported language? But it seems that almost all banks only support German.
if (bank.selectedLanguage == Dialogsprache.Default && bankParameters.supportedLanguages.isNotEmpty()) { if (bank.selectedLanguage == Dialogsprache.Default && bankParameters.supportedLanguages.isNotEmpty()) {

View File

@ -2,7 +2,7 @@ package net.dankito.banking.fints.model
import net.dankito.banking.fints.messages.MessageBuilderResult import net.dankito.banking.fints.messages.MessageBuilderResult
import net.dankito.banking.fints.messages.datenelemente.implementierte.signatur.VersionDesSicherheitsverfahrens import net.dankito.banking.fints.messages.datenelemente.implementierte.signatur.VersionDesSicherheitsverfahrens
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
open class DialogContext( open class DialogContext(
@ -11,11 +11,11 @@ open class DialogContext(
var abortIfTanIsRequired: Boolean = false, var abortIfTanIsRequired: Boolean = false,
var currentMessage: MessageBuilderResult? = null, var currentMessage: MessageBuilderResult? = null,
var dialogId: String = InitialDialogId, var dialogId: String = InitialDialogId,
var response: Response? = null, var response: BankResponse? = null,
var didBankCloseDialog: Boolean = false, var didBankCloseDialog: Boolean = false,
versionOfSecurityProcedure: VersionDesSicherheitsverfahrens = VersionDesSicherheitsverfahrens.Version_2, versionOfSecurityProcedure: VersionDesSicherheitsverfahrens = VersionDesSicherheitsverfahrens.Version_2,
var previousMessageInDialog: MessageBuilderResult? = null, // for PinTan almost always the case except for getting a user's TAN procedures var previousMessageInDialog: MessageBuilderResult? = null, // for PinTan almost always the case except for getting a user's TAN procedures
var chunkedResponseHandler: ((Response) -> Unit)? = null var chunkedResponseHandler: ((BankResponse) -> Unit)? = null
) : MessageBaseData(bank, product, versionOfSecurityProcedure) { ) : MessageBaseData(bank, product, versionOfSecurityProcedure) {
companion object { companion object {

View File

@ -8,7 +8,7 @@ import net.dankito.banking.fints.messages.segmente.id.MessageSegmentId
import net.dankito.banking.fints.response.segments.* import net.dankito.banking.fints.response.segments.*
open class Response( open class BankResponse(
val didReceiveResponse: Boolean, val didReceiveResponse: Boolean,
val receivedResponse: String? = null, val receivedResponse: String? = null,
val receivedSegments: List<ReceivedSegment> = listOf(), val receivedSegments: List<ReceivedSegment> = listOf(),
@ -75,7 +75,7 @@ open class Response(
} }
open var followUpResponse: Response? = null open var followUpResponse: BankResponse? = null
open var hasFollowUpMessageButCouldNotReceiveIt: Boolean? = false open var hasFollowUpMessageButCouldNotReceiveIt: Boolean? = false

View File

@ -40,7 +40,7 @@ open class ResponseParser(
} }
open fun parse(response: String): Response { open fun parse(response: String): BankResponse {
try { try {
val segments = splitIntoPartsAndUnmask(response, Separators.SegmentSeparatorChar).toMutableList() val segments = splitIntoPartsAndUnmask(response, Separators.SegmentSeparatorChar).toMutableList()
@ -48,11 +48,11 @@ open class ResponseParser(
val parsedSegments = segments.mapNotNull { parseSegment(it) } val parsedSegments = segments.mapNotNull { parseSegment(it) }
return Response(true, response, parsedSegments) return BankResponse(true, response, parsedSegments)
} catch (e: Exception) { } catch (e: Exception) {
log.error(e) { "Could not parse response '$response'" } log.error(e) { "Could not parse response '$response'" }
return Response(true, response, errorMessage = e.getInnerExceptionMessage()) return BankResponse(true, response, errorMessage = e.getInnerExceptionMessage())
} }
} }

View File

@ -1,11 +1,11 @@
package net.dankito.banking.fints.response.client package net.dankito.banking.fints.response.client
import net.dankito.banking.fints.model.* import net.dankito.banking.fints.model.*
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
open class AddAccountResponse( open class AddAccountResponse(
response: Response, response: BankResponse,
open val bank: BankData, open val bank: BankData,
retrievedData: List<RetrievedAccountData> = listOf() retrievedData: List<RetrievedAccountData> = listOf()
) : GetTransactionsResponse(response, retrievedData) { ) : GetTransactionsResponse(response, retrievedData) {

View File

@ -1,6 +1,6 @@
package net.dankito.banking.fints.response.client package net.dankito.banking.fints.response.client
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
import net.dankito.banking.fints.response.segments.TanResponse import net.dankito.banking.fints.response.segments.TanResponse
@ -31,7 +31,7 @@ open class FinTsClientResponse(
) { ) {
constructor(response: Response) : this(response.successful, response.noTanProcedureSelected, constructor(response: BankResponse) : this(response.successful, response.noTanProcedureSelected,
response.isStrongAuthenticationRequired, response.tanResponse, response.errorsToShowToUser, response.isStrongAuthenticationRequired, response.tanResponse, response.errorsToShowToUser,
response.errorMessage, response.tanRequiredButUserDidNotEnterOne, response.tanRequiredButWeWereToldToAbortIfSo, response.errorMessage, response.tanRequiredButUserDidNotEnterOne, response.tanRequiredButWeWereToldToAbortIfSo,
response.messageCreationError?.isJobAllowed ?: true, response.messageCreationError?.isJobAllowed ?: true,

View File

@ -1,11 +1,11 @@
package net.dankito.banking.fints.response.client package net.dankito.banking.fints.response.client
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
import net.dankito.banking.fints.response.segments.TanMediaList import net.dankito.banking.fints.response.segments.TanMediaList
open class GetTanMediaListResponse( open class GetTanMediaListResponse(
response: Response, response: BankResponse,
val tanMediaList: TanMediaList? val tanMediaList: TanMediaList?
) )
: FinTsClientResponse(response) : FinTsClientResponse(response)

View File

@ -1,11 +1,11 @@
package net.dankito.banking.fints.response.client package net.dankito.banking.fints.response.client
import net.dankito.banking.fints.model.RetrievedAccountData import net.dankito.banking.fints.model.RetrievedAccountData
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
open class GetTransactionsResponse( open class GetTransactionsResponse(
response: Response, response: BankResponse,
open val retrievedData: List<RetrievedAccountData> = listOf(), open val retrievedData: List<RetrievedAccountData> = listOf(),
/** /**
* This value is only set if [GetTransactionsParameter.maxCountEntries] was set to tell caller if maxCountEntries parameter has been evaluated or not * This value is only set if [GetTransactionsParameter.maxCountEntries] was set to tell caller if maxCountEntries parameter has been evaluated or not

View File

@ -1,11 +1,11 @@
package net.dankito.banking.fints.response.client package net.dankito.banking.fints.response.client
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
import net.dankito.banking.fints.response.ResponseParser import net.dankito.banking.fints.response.ResponseParser
open class GetUserTanProceduresResponse(bankResponse: Response) open class GetUserTanProceduresResponse(bankResponse: BankResponse)
: Response(bankResponse.didReceiveResponse, bankResponse.receivedResponse, bankResponse.receivedSegments, : BankResponse(bankResponse.didReceiveResponse, bankResponse.receivedResponse, bankResponse.receivedSegments,
bankResponse.errorMessage, bankResponse.noTanProcedureSelected, bankResponse.messageCreationError) { bankResponse.errorMessage, bankResponse.noTanProcedureSelected, bankResponse.messageCreationError) {
/** /**

View File

@ -1084,7 +1084,7 @@ class ResponseParserTest : FinTsTestBase() {
} }
private fun assertSuccessfullyParsedSegment(result: Response, segmentId: ISegmentId, segmentNumber: Int, private fun assertSuccessfullyParsedSegment(result: BankResponse, segmentId: ISegmentId, segmentNumber: Int,
segmentVersion: Int, referenceSegmentNumber: Int? = null) { segmentVersion: Int, referenceSegmentNumber: Int? = null) {
assertCouldParseResponse(result) assertCouldParseResponse(result)
@ -1092,7 +1092,7 @@ class ResponseParserTest : FinTsTestBase() {
assertCouldParseSegment(result, segmentId, segmentNumber, segmentVersion, referenceSegmentNumber) assertCouldParseSegment(result, segmentId, segmentNumber, segmentVersion, referenceSegmentNumber)
} }
private fun assertCouldParseResponse(result: Response) { private fun assertCouldParseResponse(result: BankResponse) {
expect(result.successful).isTrue() expect(result.successful).isTrue()
expect(result.responseContainsErrors).isFalse() expect(result.responseContainsErrors).isFalse()
expect(result.errorMessage).toBe(null) expect(result.errorMessage).toBe(null)
@ -1100,7 +1100,7 @@ class ResponseParserTest : FinTsTestBase() {
expect(result.receivedResponse).notToBeNull() expect(result.receivedResponse).notToBeNull()
} }
private fun assertCouldParseSegment(result: Response, segmentId: ISegmentId, segmentNumber: Int, private fun assertCouldParseSegment(result: BankResponse, segmentId: ISegmentId, segmentNumber: Int,
segmentVersion: Int, referenceSegmentNumber: Int? = null) { segmentVersion: Int, referenceSegmentNumber: Int? = null) {
val segment = result.getFirstSegmentById<ReceivedSegment>(segmentId) val segment = result.getFirstSegmentById<ReceivedSegment>(segmentId)

View File

@ -13,7 +13,7 @@ import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.Bezei
import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.SmsAbbuchungskontoErforderlich import net.dankito.banking.fints.messages.datenelemente.implementierte.tan.SmsAbbuchungskontoErforderlich
import net.dankito.banking.fints.model.* import net.dankito.banking.fints.model.*
import net.dankito.banking.bankfinder.BankInfo import net.dankito.banking.bankfinder.BankInfo
import net.dankito.banking.fints.response.Response import net.dankito.banking.fints.response.BankResponse
import net.dankito.banking.fints.response.segments.SepaAccountInfoParameters import net.dankito.banking.fints.response.segments.SepaAccountInfoParameters
import net.dankito.banking.fints.response.segments.TanInfo import net.dankito.banking.fints.response.segments.TanInfo
import net.dankito.banking.fints.response.segments.TanProcedureParameters import net.dankito.banking.fints.response.segments.TanProcedureParameters
@ -51,11 +51,11 @@ class BanksFinTsDetailsRetriever {
private val finTsClient = object : FinTsClient(NoOpFinTsClientCallback(), KtorWebClient(), PureKotlinBase64Service()) { private val finTsClient = object : FinTsClient(NoOpFinTsClientCallback(), KtorWebClient(), PureKotlinBase64Service()) {
fun getAndHandleResponseForMessagePublic(message: MessageBuilderResult, dialogContext: DialogContext, callback: (Response) -> Unit) { fun getAndHandleResponseForMessagePublic(message: MessageBuilderResult, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {
getAndHandleResponseForMessage(message, dialogContext, callback) getAndHandleResponseForMessage(message, dialogContext, callback)
} }
fun updateBankDataPublic(bank: BankData, response: Response) { fun updateBankDataPublic(bank: BankData, response: BankResponse) {
super.updateBankData(bank, response) super.updateBankData(bank, response)
} }
@ -125,11 +125,11 @@ class BanksFinTsDetailsRetriever {
} }
private fun getAnonymousBankInfo(bank: BankData): Response { private fun getAnonymousBankInfo(bank: BankData): BankResponse {
val dialogContext = DialogContext(bank, product) val dialogContext = DialogContext(bank, product)
val requestBody = messageBuilder.createAnonymousDialogInitMessage(dialogContext) val requestBody = messageBuilder.createAnonymousDialogInitMessage(dialogContext)
val anonymousBankInfoResponse = AtomicReference<Response>() val anonymousBankInfoResponse = AtomicReference<BankResponse>()
val countDownLatch = CountDownLatch(1) val countDownLatch = CountDownLatch(1)
finTsClient.getAndHandleResponseForMessagePublic(requestBody, dialogContext) { finTsClient.getAndHandleResponseForMessagePublic(requestBody, dialogContext) {