Implemented parsing SepaAccountInfo
This commit is contained in:
parent
def4e1f74e
commit
9672136a77
|
@ -485,11 +485,19 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
response.getFirstSegmentById<CommunicationInfo>(InstituteSegmentId.CommunicationInfo)?.let { communicationInfo ->
|
||||
// TODO: set default language, also for user
|
||||
|
||||
communicationInfo.parameters.firstOrNull { it.type == Kommunikationsdienst.Https }?.address?.let { address ->
|
||||
bank.finTs3ServerAddress = if (address.startsWith("https://", true)) address else "https://$address"
|
||||
}
|
||||
}
|
||||
|
||||
response.getFirstSegmentById<SepaAccountInfo>(InstituteSegmentId.SepaAccountInfo)?.let { sepaAccountInfo ->
|
||||
sepaAccountInfo.account.bic?.let {
|
||||
bank.bic = it // TODO: really set BIC on bank then?
|
||||
}
|
||||
}
|
||||
|
||||
if (response.supportedJobs.isNotEmpty()) {
|
||||
bank.supportedJobs = response.supportedJobs
|
||||
}
|
||||
|
@ -537,6 +545,13 @@ open class FinTsClient @JvmOverloads constructor(
|
|||
// TODO: may also make use of other info
|
||||
}
|
||||
|
||||
response.getFirstSegmentById<SepaAccountInfo>(InstituteSegmentId.SepaAccountInfo)?.let { sepaAccountInfo ->
|
||||
// TODO: may also make use of other info
|
||||
sepaAccountInfo.account.iban?.let {
|
||||
customer.iban = it
|
||||
}
|
||||
}
|
||||
|
||||
response.getFirstSegmentById<UserParameters>(InstituteSegmentId.UserParameters)?.let { userParameters ->
|
||||
customer.updVersion = userParameters.updVersion
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ enum class InstituteSegmentId(override val id: String) : ISegmentId {
|
|||
|
||||
AccountInfo("HIUPD"),
|
||||
|
||||
SepaAccountInfo("HISPA"),
|
||||
|
||||
TanInfo("HITANS"),
|
||||
|
||||
Tan("HITAN"),
|
||||
|
|
|
@ -87,6 +87,7 @@ open class ResponseParser @JvmOverloads constructor(
|
|||
|
||||
InstituteSegmentId.UserParameters.id -> parseUserParameters(segment, dataElementGroups)
|
||||
InstituteSegmentId.AccountInfo.id -> parseAccountInfo(segment, dataElementGroups)
|
||||
InstituteSegmentId.SepaAccountInfo.id -> parseSepaAccountInfo(segment, dataElementGroups)
|
||||
|
||||
InstituteSegmentId.TanInfo.id -> parseTanInfo(segment, segmentId, dataElementGroups)
|
||||
InstituteSegmentId.Tan.id -> parseTanResponse(segment, dataElementGroups)
|
||||
|
@ -249,6 +250,22 @@ open class ResponseParser @JvmOverloads constructor(
|
|||
return null
|
||||
}
|
||||
|
||||
protected open fun parseSepaAccountInfo(segment: String, dataElementGroups: List<String>): SepaAccountInfo {
|
||||
val accountDataElements = getDataElements(dataElementGroups[1])
|
||||
|
||||
return SepaAccountInfo(
|
||||
KontoverbindungZvInternational(
|
||||
parseBoolean(accountDataElements[0]),
|
||||
parseStringToNullIfEmpty(accountDataElements[1]),
|
||||
parseStringToNullIfEmpty(accountDataElements[2]),
|
||||
parseString(accountDataElements[3]),
|
||||
parseStringToNullIfEmpty(accountDataElements[4]),
|
||||
parseBankDetails(accountDataElements[5], accountDataElements[6])
|
||||
),
|
||||
segment
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
protected open fun parseAllowedJob(segment: String, segmentId: String, dataElementGroups: List<String>): SupportedJob {
|
||||
var jobName = segmentId.substring(0, 5) // cut off last 'S' (which stands for 'parameter')
|
||||
|
@ -404,7 +421,11 @@ open class ResponseParser @JvmOverloads constructor(
|
|||
protected open fun parseBankDetails(dataElementsGroup: String): Kreditinstitutskennung {
|
||||
val detailsStrings = getDataElements(dataElementsGroup)
|
||||
|
||||
return Kreditinstitutskennung(parseInt(detailsStrings[0]), parseString(detailsStrings[1]))
|
||||
return parseBankDetails(detailsStrings[0], detailsStrings[1])
|
||||
}
|
||||
|
||||
protected open fun parseBankDetails(countryCodeDE: String, bankCodeDE: String): Kreditinstitutskennung {
|
||||
return Kreditinstitutskennung(parseInt(countryCodeDE), parseString(bankCodeDE))
|
||||
}
|
||||
|
||||
protected open fun parseLanguages(dataElementsGroup: String): List<Dialogsprache> {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package net.dankito.fints.response.segments
|
||||
|
||||
import net.dankito.fints.messages.datenelementgruppen.implementierte.Kreditinstitutskennung
|
||||
|
||||
|
||||
open class KontoverbindungZvInternational(
|
||||
val isSepaAccount: Boolean,
|
||||
val iban: String?,
|
||||
val bic: String?,
|
||||
val accountIdentifier: String,
|
||||
val subAccountAttribute: String? = null,
|
||||
val bankInfo: Kreditinstitutskennung
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
package net.dankito.fints.response.segments
|
||||
|
||||
|
||||
open class SepaAccountInfo(
|
||||
val account: KontoverbindungZvInternational,
|
||||
segmentString: String
|
||||
)
|
||||
: ReceivedSegment(segmentString)
|
|
@ -14,9 +14,9 @@ abstract class FinTsTestBase {
|
|||
companion object {
|
||||
const val BankCode = "12345678"
|
||||
|
||||
val BankCountryCode = Laenderkennzeichen.Germany
|
||||
const val BankCountryCode = Laenderkennzeichen.Germany
|
||||
|
||||
val BankFinTsServerAddress = "banking.supi-dupi-bank.de/fints30"
|
||||
const val BankFinTsServerAddress = "banking.supi-dupi-bank.de/fints30"
|
||||
|
||||
val Bank = BankData(BankCode, BankCountryCode, "")
|
||||
|
||||
|
@ -24,6 +24,10 @@ abstract class FinTsTestBase {
|
|||
|
||||
const val Pin = "12345"
|
||||
|
||||
const val Iban = "DE11$BankCode$CustomerId"
|
||||
|
||||
const val Bic = "ABCDDEMM123"
|
||||
|
||||
val Language = Dialogsprache.German
|
||||
|
||||
val SecurityFunction = Sicherheitsfunktion.PIN_TAN_911
|
||||
|
|
|
@ -426,6 +426,27 @@ class ResponseParserTest : FinTsTestBase() {
|
|||
?: run { Assert.fail("No segment of type AccountInfo found in ${result.receivedSegments}") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseSepaAccountInfo() {
|
||||
|
||||
// when
|
||||
val result = underTest.parse("HISPA:5:1:3+J:$Iban:$Bic:$CustomerId::280:$BankCode")
|
||||
|
||||
// then
|
||||
assertSuccessfullyParsedSegment(result, InstituteSegmentId.SepaAccountInfo, 5, 1, 3)
|
||||
|
||||
result.getFirstSegmentById<SepaAccountInfo>(InstituteSegmentId.SepaAccountInfo)?.let { segment ->
|
||||
assertThat(segment.account.isSepaAccount).isTrue()
|
||||
assertThat(segment.account.iban).isEqualTo(Iban)
|
||||
assertThat(segment.account.bic).isEqualTo(Bic)
|
||||
assertThat(segment.account.accountIdentifier).isEqualTo(CustomerId)
|
||||
assertThat(segment.account.subAccountAttribute).isNull()
|
||||
assertThat(segment.account.bankInfo.bankCountryCode).isEqualTo(BankCountryCode)
|
||||
assertThat(segment.account.bankInfo.bankCode).isEqualTo(BankCode)
|
||||
}
|
||||
?: run { Assert.fail("No segment of type SepaAccountInfo found in ${result.receivedSegments}") }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun parseSupportedJobs() {
|
||||
|
||||
|
|
Loading…
Reference in New Issue