Added parameter alsoRetrieveBalance

This commit is contained in:
dankl 2019-10-13 17:36:26 +02:00 committed by dankito
parent 5ebbf0d383
commit 362b09a246
3 changed files with 16 additions and 6 deletions

View File

@ -14,6 +14,7 @@ import net.dankito.utils.web.client.OkHttpWebClient
import net.dankito.utils.web.client.RequestParameters import net.dankito.utils.web.client.RequestParameters
import net.dankito.utils.web.client.WebClientResponse import net.dankito.utils.web.client.WebClientResponse
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
import java.math.BigDecimal
open class FinTsClient( open class FinTsClient(
@ -99,6 +100,9 @@ open class FinTsClient(
} }
var balance: BigDecimal? = null
if (parameter.alsoRetrieveBalance) {
dialogData.increaseMessageNumber() dialogData.increaseMessageNumber()
val balanceRequest = messageBuilder.createGetBalanceMessage(bank, customer, product, dialogData) val balanceRequest = messageBuilder.createGetBalanceMessage(bank, customer, product, dialogData)
@ -109,6 +113,11 @@ open class FinTsClient(
return balanceResponse return balanceResponse
} }
balanceResponse.getFirstSegmentById<BalanceSegment>(InstituteSegmentId.Balance)?.let {
balance = it.balance
}
}
dialogData.increaseMessageNumber() dialogData.increaseMessageNumber()

View File

@ -4,6 +4,7 @@ import java.util.*
open class GetTransactionsParameter( open class GetTransactionsParameter(
val alsoRetrieveBalance: Boolean = true,
val fromDate: Date? = null, val fromDate: Date? = null,
val toDate: Date? = null, val toDate: Date? = null,
val maxAmount: Int? = null, val maxAmount: Int? = null,

View File

@ -65,7 +65,7 @@ class FinTsClientTest {
val ninetyDaysAgo = Date(Date().time - ninetyDaysAgoMilliseconds) val ninetyDaysAgo = Date(Date().time - ninetyDaysAgoMilliseconds)
// when // when
val result = underTest.getTransactions(GetTransactionsParameter(ninetyDaysAgo), Bank, Customer) val result = underTest.getTransactions(GetTransactionsParameter(fromDate = ninetyDaysAgo), Bank, Customer)
// then // then
assertThat(result.successful).isTrue() assertThat(result.successful).isTrue()