Renamed SupportedJob to JobParameters

This commit is contained in:
dankl 2019-10-20 16:46:53 +02:00 committed by dankito
parent d6cf9388c0
commit fdb8545d6b
8 changed files with 24 additions and 24 deletions

View File

@ -591,8 +591,8 @@ open class FinTsClient @JvmOverloads constructor(
return bank.supportedTanProcedures.firstOrNull { it.securityFunction == securityFunction } return bank.supportedTanProcedures.firstOrNull { it.securityFunction == securityFunction }
} }
protected open fun setAllowedJobsForAccount(account: AccountData, supportedJobs: List<SupportedJob>) { protected open fun setAllowedJobsForAccount(account: AccountData, supportedJobs: List<JobParameters>) {
val allowedJobsForAccount = mutableListOf<SupportedJob>() val allowedJobsForAccount = mutableListOf<JobParameters>()
for (job in supportedJobs) { for (job in supportedJobs) {
if (isJobSupported(account, job)) { if (isJobSupported(account, job)) {
@ -643,9 +643,9 @@ open class FinTsClient @JvmOverloads constructor(
} }
} }
protected open fun isJobSupported(account: AccountData, job: SupportedJob): Boolean { protected open fun isJobSupported(account: AccountData, supportedJob: JobParameters): Boolean {
for (allowedJobName in account.allowedJobNames) { for (allowedJobName in account.allowedJobNames) {
if (allowedJobName == job.jobName) { if (allowedJobName == supportedJob.jobName) {
return true return true
} }
} }

View File

@ -1,7 +1,7 @@
package net.dankito.fints.model package net.dankito.fints.model
import net.dankito.fints.response.segments.AccountType import net.dankito.fints.response.segments.AccountType
import net.dankito.fints.response.segments.SupportedJob import net.dankito.fints.response.segments.JobParameters
open class AccountData( open class AccountData(
@ -17,7 +17,7 @@ open class AccountData(
val productName: String?, val productName: String?,
val accountLimit: String?, val accountLimit: String?,
val allowedJobNames: List<String>, val allowedJobNames: List<String>,
var allowedJobs: List<SupportedJob> = listOf() var allowedJobs: List<JobParameters> = listOf()
) { ) {
override fun toString(): String { override fun toString(): String {

View File

@ -3,7 +3,7 @@ package net.dankito.fints.model
import net.dankito.fints.messages.datenelemente.implementierte.BPDVersion import net.dankito.fints.messages.datenelemente.implementierte.BPDVersion
import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache import net.dankito.fints.messages.datenelemente.implementierte.Dialogsprache
import net.dankito.fints.messages.datenelemente.implementierte.HbciVersion import net.dankito.fints.messages.datenelemente.implementierte.HbciVersion
import net.dankito.fints.response.segments.SupportedJob import net.dankito.fints.response.segments.JobParameters
open class BankData( open class BankData(
@ -23,7 +23,7 @@ open class BankData(
var supportedHbciVersions: List<HbciVersion> = listOf(), var supportedHbciVersions: List<HbciVersion> = listOf(),
var supportedTanProcedures: List<TanProcedure> = listOf(), var supportedTanProcedures: List<TanProcedure> = listOf(),
var supportedLanguages: List<Dialogsprache> = listOf(), var supportedLanguages: List<Dialogsprache> = listOf(),
var supportedJobs: List<SupportedJob> = listOf() var supportedJobs: List<JobParameters> = listOf()
) { ) {

View File

@ -67,13 +67,13 @@ open class Response constructor(
/** /**
* Returns an empty list of response didn't contain any allowed jobs. * Returns an empty list of response didn't contain any job parameters.
* *
* Returns all jobs bank supports otherwise. This does not necessarily mean that they are also allowed for * Returns all jobs bank supports otherwise. This does not necessarily mean that they are also allowed for
* customer / account, see [net.dankito.fints.model.AccountData.allowedJobNames]. * customer / account, see [net.dankito.fints.model.AccountData.allowedJobNames].
*/ */
open val supportedJobs: List<SupportedJob> open val supportedJobs: List<JobParameters>
get() = receivedSegments.mapNotNull { it as? SupportedJob } get() = receivedSegments.mapNotNull { it as? JobParameters }
open val supportedTanProceduresForUser: List<Sicherheitsfunktion> open val supportedTanProceduresForUser: List<Sicherheitsfunktion>
get() = segmentFeedbacks.flatMap { it.feedbacks } get() = segmentFeedbacks.flatMap { it.feedbacks }

View File

@ -32,7 +32,7 @@ open class ResponseParser @JvmOverloads constructor(
val EncryptionDataSegmentHeaderPattern = Pattern.compile("${MessageSegmentId.EncryptionData.id}:\\d{1,3}:\\d{1,3}\\+") val EncryptionDataSegmentHeaderPattern = Pattern.compile("${MessageSegmentId.EncryptionData.id}:\\d{1,3}:\\d{1,3}\\+")
val AllowedJobSegmentPattern = Pattern.compile("HI[A-Z]{3}S") val JobParametersSegmentPattern = Pattern.compile("HI[A-Z]{3}S")
val FeedbackParametersSeparator = "; " val FeedbackParametersSeparator = "; "
@ -96,8 +96,8 @@ open class ResponseParser @JvmOverloads constructor(
InstituteSegmentId.AccountTransactionsMt940.id -> parseMt940AccountTransactions(segment, dataElementGroups) InstituteSegmentId.AccountTransactionsMt940.id -> parseMt940AccountTransactions(segment, dataElementGroups)
else -> { else -> {
if (AllowedJobSegmentPattern.matcher(segmentId).matches()) { if (JobParametersSegmentPattern.matcher(segmentId).matches()) {
return parseAllowedJob(segment, segmentId, dataElementGroups) return parseJobParameters(segment, segmentId, dataElementGroups)
} }
UnparsedSegment(segment) UnparsedSegment(segment)
@ -267,7 +267,7 @@ open class ResponseParser @JvmOverloads constructor(
} }
protected open fun parseAllowedJob(segment: String, segmentId: String, dataElementGroups: List<String>): SupportedJob { protected open fun parseJobParameters(segment: String, segmentId: String, dataElementGroups: List<String>): JobParameters {
var jobName = segmentId.substring(0, 5) // cut off last 'S' (which stands for 'parameter') var jobName = segmentId.substring(0, 5) // cut off last 'S' (which stands for 'parameter')
jobName = jobName.replaceFirst("HI", "HK") jobName = jobName.replaceFirst("HI", "HK")
@ -277,14 +277,14 @@ open class ResponseParser @JvmOverloads constructor(
// Bei aelteren Version fehlt das Datenelement 'Sicherheitsklasse'. Ist fuer PIN/TAN eh zu ignorieren // Bei aelteren Version fehlt das Datenelement 'Sicherheitsklasse'. Ist fuer PIN/TAN eh zu ignorieren
val securityClass = if (dataElementGroups.size > 3) parseNullableInt(dataElementGroups[3]) else null val securityClass = if (dataElementGroups.size > 3) parseNullableInt(dataElementGroups[3]) else null
return SupportedJob(jobName, maxCountJobs, minimumCountSignatures, securityClass, segment) return JobParameters(jobName, maxCountJobs, minimumCountSignatures, securityClass, segment)
} }
protected open fun parseTanInfo(segment: String, segmentId: String, dataElementGroups: List<String>): TanInfo { protected open fun parseTanInfo(segment: String, segmentId: String, dataElementGroups: List<String>): TanInfo {
val allowedJob = parseAllowedJob(segment, segmentId, dataElementGroups) val jobParameters = parseJobParameters(segment, segmentId, dataElementGroups)
return TanInfo(allowedJob, parseTwoStepTanProcedureParameters(dataElementGroups[4])) return TanInfo(jobParameters, parseTwoStepTanProcedureParameters(dataElementGroups[4]))
} }
protected open fun parseTwoStepTanProcedureParameters(tanProcedures: String): TwoStepTanProcedureParameters { protected open fun parseTwoStepTanProcedureParameters(tanProcedures: String): TwoStepTanProcedureParameters {

View File

@ -1,7 +1,7 @@
package net.dankito.fints.response.segments package net.dankito.fints.response.segments
open class SupportedJob( open class JobParameters(
val jobName: String, val jobName: String,
val maxCountJobs: Int, val maxCountJobs: Int,
val minimumCountSignatures: Int, val minimumCountSignatures: Int,

View File

@ -10,10 +10,10 @@ open class TanInfo(
segmentString: String segmentString: String
) )
: SupportedJob(jobName, maxCountJobs, minimumCountSignatures, securityClass, segmentString) { : JobParameters(jobName, maxCountJobs, minimumCountSignatures, securityClass, segmentString) {
constructor(supportedJob: SupportedJob, tanProcedureParameters: TwoStepTanProcedureParameters) constructor(parameters: JobParameters, tanProcedureParameters: TwoStepTanProcedureParameters)
: this(supportedJob.jobName, supportedJob.maxCountJobs, supportedJob.minimumCountSignatures, : this(parameters.jobName, parameters.maxCountJobs, parameters.minimumCountSignatures,
supportedJob.securityClass, tanProcedureParameters, supportedJob.segmentString) parameters.securityClass, tanProcedureParameters, parameters.segmentString)
} }

View File

@ -552,7 +552,7 @@ class ResponseParserTest : FinTsTestBase() {
assertThat(result.receivedSegments).hasSize(92) assertThat(result.receivedSegments).hasSize(92)
for (segment in result.receivedSegments) { for (segment in result.receivedSegments) {
assertThat(segment is SupportedJob).describedAs("$segment should be of type AllowedJob").isTrue() assertThat(segment is JobParameters).describedAs("$segment should be of type JobParameters").isTrue()
} }
} }