diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 54f26f34..ac043885 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -7,6 +7,7 @@ import net.dankito.fints.model.* import net.dankito.fints.response.InstituteSegmentId import net.dankito.fints.response.Response import net.dankito.fints.response.ResponseParser +import net.dankito.fints.response.client.GetTransactionsResponse import net.dankito.fints.response.segments.* import net.dankito.fints.util.IBase64Service import net.dankito.utils.web.client.IWebClient @@ -89,14 +90,14 @@ open class FinTsClient( open fun getTransactions(parameter: GetTransactionsParameter, bank: BankData, - customer: CustomerData): Response { + customer: CustomerData): GetTransactionsResponse { val dialogData = DialogData() val initDialogResponse = initDialog(bank, customer, dialogData) if (initDialogResponse.successful == false) { - return initDialogResponse + return GetTransactionsResponse(initDialogResponse) } @@ -110,7 +111,7 @@ open class FinTsClient( val balanceResponse = getAndHandleResponseForMessage(balanceRequest, bank) if (balanceResponse.successful == false) { - return balanceResponse + return GetTransactionsResponse(balanceResponse) } balanceResponse.getFirstSegmentById(InstituteSegmentId.Balance)?.let { @@ -127,7 +128,12 @@ open class FinTsClient( closeDialog(bank, customer, dialogData) - return response + + response.getFirstSegmentById(InstituteSegmentId.AccountTransactionsMt940)?.let { transactions -> + return GetTransactionsResponse(response, transactions.bookedTransactions, transactions.unbookedTransactions, balance) + } + + return GetTransactionsResponse(response) } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt index 7f8d0088..1e74eb05 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/Response.kt @@ -24,13 +24,10 @@ open class Response constructor( get() = didReceiveResponse && responseContainsErrors == false open val isStrongAuthenticationRequired: Boolean - get() { - getFirstSegmentById(InstituteSegmentId.Tan)?.let { tanResponse -> - return tanResponse.isStrongAuthenticationRequired - } + get() = tanResponse?.isStrongAuthenticationRequired == true - return false - } + open val tanResponse: TanResponse? + get() = getFirstSegmentById(InstituteSegmentId.Tan) open val messageHeader: ReceivedMessageHeader? diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/client/ClientResponseBase.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/client/ClientResponseBase.kt new file mode 100644 index 00000000..b83e0752 --- /dev/null +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/client/ClientResponseBase.kt @@ -0,0 +1,26 @@ +package net.dankito.fints.response.client + +import net.dankito.fints.response.Response +import net.dankito.fints.response.segments.TanResponse + + +open class ClientResponseBase( + + val successful: Boolean, + + val isStrongAuthenticationRequired: Boolean, + val tanRequired: TanResponse? = null, + + val errorsToShowToUser: List = listOf(), + + /** + * When a serious error occurred during web request or response parsing. + */ + val exception: Exception? = null +) { + + + constructor(response: Response) : this(response.successful, response.isStrongAuthenticationRequired, + response.tanResponse, response.errorsToShowToUser, response.exception) + +} \ No newline at end of file diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/response/client/GetTransactionsResponse.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/client/GetTransactionsResponse.kt new file mode 100644 index 00000000..6d7471f9 --- /dev/null +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/response/client/GetTransactionsResponse.kt @@ -0,0 +1,14 @@ +package net.dankito.fints.response.client + +import net.dankito.fints.model.AccountTransaction +import net.dankito.fints.response.Response +import java.math.BigDecimal + + +open class GetTransactionsResponse( + response: Response, + val bookedTransactions: List = listOf(), + val unbookedTransactions: List = listOf(), + val balance: BigDecimal? = null +) + : ClientResponseBase(response) \ No newline at end of file diff --git a/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt b/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt index ebc62718..8ad97a5c 100644 --- a/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt +++ b/fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest.kt @@ -69,6 +69,7 @@ class FinTsClientTest { // then assertThat(result.successful).isTrue() + assertThat(result.bookedTransactions).isNotEmpty() }