Implemented parsing allowed job names
This commit is contained in:
parent
94ccfd2e09
commit
45b2dca90a
|
@ -167,11 +167,29 @@ open class ResponseParser @JvmOverloads constructor(
|
|||
val productName = if (dataElementGroups.size > 8) parseStringToNullIfEmpty(dataElementGroups[8]) else null
|
||||
val limit = if (dataElementGroups.size > 9) parseStringToNullIfEmpty(dataElementGroups[9]) else null // TODO: parse limit
|
||||
|
||||
// TODO: parse allowed jobs
|
||||
// TODO: parse extension
|
||||
val allowedJobNames = if (dataElementGroups.size > 10) parseAllowedJobNames(dataElementGroups.subList(10, dataElementGroups.size - 1)) else listOf()
|
||||
val extension = if (dataElementGroups.size > 11) parseStringToNullIfEmpty(dataElementGroups[dataElementGroups.size - 1]) else null
|
||||
|
||||
return AccountInfo(accountNumber, subAccountAttribute, bankCountryCode, bankCode, iban, customerId, accountType,
|
||||
currency, accountHolderName1, accountHolderName2, productName, limit, null, segment)
|
||||
currency, accountHolderName1, accountHolderName2, productName, limit, allowedJobNames, extension, segment)
|
||||
}
|
||||
|
||||
protected open fun parseAllowedJobNames(dataElementGroups: List<String>): List<String> {
|
||||
|
||||
return dataElementGroups.mapNotNull { parseAllowedJobName(it) }
|
||||
}
|
||||
|
||||
protected open fun parseAllowedJobName(dataElementGroup: String): String? {
|
||||
val dataElements = getDataElements(dataElementGroup)
|
||||
|
||||
if (dataElements.size > 0) {
|
||||
val jobName = parseString(dataElements[0])
|
||||
if (jobName.startsWith("HK")) { // filter out jobs not standardized by Deutsche Kreditwirtschaft (Verbandseigene Geschaeftsvorfaelle)
|
||||
return jobName
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ open class AccountInfo(
|
|||
val accountHolderName2: String?,
|
||||
val productName: String?,
|
||||
val accountLimit: String?, // TODO: parse
|
||||
val allowedJobNames: List<String>,
|
||||
val extension: String?, // TODO: parse
|
||||
|
||||
segmentString: String
|
||||
|
|
|
@ -210,6 +210,9 @@ class ResponseParserTest : FinTsTestBase() {
|
|||
assertThat(segment.accountHolderName1).isEqualTo("Hans Dampf")
|
||||
assertThat(segment.accountHolderName2).isNull()
|
||||
assertThat(segment.productName).isEqualTo("Sichteinlagen")
|
||||
assertThat(segment.accountLimit).isNull()
|
||||
assertThat(segment.allowedJobNames).hasSize(44)
|
||||
assertThat(segment.extension).isNotNull()
|
||||
}
|
||||
?: run { Assert.fail("No segment of type AccountInfo found in ${result.receivedSegments}") }
|
||||
}
|
||||
|
@ -236,6 +239,7 @@ class ResponseParserTest : FinTsTestBase() {
|
|||
assertThat(segment.accountHolderName2).isNull()
|
||||
assertThat(segment.productName).isNull()
|
||||
assertThat(segment.accountLimit).isNull()
|
||||
assertThat(segment.allowedJobNames).isEmpty()
|
||||
assertThat(segment.extension).isNull()
|
||||
}
|
||||
?: run { Assert.fail("No segment of type AccountInfo found in ${result.receivedSegments}") }
|
||||
|
|
Loading…
Reference in New Issue