Added clientData
This commit is contained in:
parent
e915b4479f
commit
0b6490f501
|
@ -70,6 +70,15 @@ open class BankAccess(
|
||||||
|
|
||||||
var wrongCredentialsEntered: Boolean = false
|
var wrongCredentialsEntered: Boolean = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BankingClient specific data of this account that the client needs to fullfil its job.
|
||||||
|
*
|
||||||
|
* You should treat it as opaque data, that only makes sense to the BankingClient, and pass it back to the client if set.
|
||||||
|
*
|
||||||
|
* For fints4k e.g. contains the FinTS jobs the bank supports, FinTS specific data like KundensystemID and so on.
|
||||||
|
*/
|
||||||
|
var clientData: String? = null
|
||||||
|
|
||||||
|
|
||||||
@get:JsonIgnore
|
@get:JsonIgnore
|
||||||
open val displayName: String
|
open val displayName: String
|
||||||
|
|
|
@ -49,6 +49,9 @@ open class FinTs4kBankingClient(
|
||||||
if (response.finTsModel != null) {
|
if (response.finTsModel != null) {
|
||||||
finTsModel = response.finTsModel // so that basic account data doesn't have to be retrieved another time if user has multiple accounts
|
finTsModel = response.finTsModel // so that basic account data doesn't have to be retrieved another time if user has multiple accounts
|
||||||
}
|
}
|
||||||
|
if (response.serializedFinTsModel != null) {
|
||||||
|
bank.clientData = response.serializedFinTsModel
|
||||||
|
}
|
||||||
|
|
||||||
Triple(account, parameter, response)
|
Triple(account, parameter, response)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanGe
|
||||||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium
|
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium
|
||||||
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus
|
import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus
|
||||||
import net.codinux.banking.fints.model.*
|
import net.codinux.banking.fints.model.*
|
||||||
|
import net.codinux.banking.fints.serialization.FinTsModelSerializer
|
||||||
import net.codinux.banking.fints.transactions.swift.model.Holding
|
import net.codinux.banking.fints.transactions.swift.model.Holding
|
||||||
import net.dankito.banking.banklistcreator.prettifier.BankingGroupMapper
|
import net.dankito.banking.banklistcreator.prettifier.BankingGroupMapper
|
||||||
import net.dankito.banking.client.model.parameter.TransferMoneyParameter
|
import net.dankito.banking.client.model.parameter.TransferMoneyParameter
|
||||||
|
@ -40,6 +41,8 @@ open class FinTs4kMapper {
|
||||||
|
|
||||||
protected val fintsModelMapper = FinTsModelMapper()
|
protected val fintsModelMapper = FinTsModelMapper()
|
||||||
|
|
||||||
|
protected val serializer = FinTsModelSerializer()
|
||||||
|
|
||||||
protected val bankingGroupMapper = BankingGroupMapper()
|
protected val bankingGroupMapper = BankingGroupMapper()
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,11 +71,13 @@ open class FinTs4kMapper {
|
||||||
// val preferredTanMethods = listOf(mapTanMethodType(bank.selectedTanMethod.type)) // TODO: currently we aren't saving TanMethods in database, re-enable as soon as TanMethods get saved
|
// val preferredTanMethods = listOf(mapTanMethodType(bank.selectedTanMethod.type)) // TODO: currently we aren't saving TanMethods in database, re-enable as soon as TanMethods get saved
|
||||||
val preferredTanMethods = defaults.preferredTanMethods?.map { mapTanMethodType(it) }
|
val preferredTanMethods = defaults.preferredTanMethods?.map { mapTanMethodType(it) }
|
||||||
|
|
||||||
|
val actualFinTsModel = finTsModel ?: bank.clientData?.let { serializer.deserializeFromJson(it) }
|
||||||
|
|
||||||
return GetAccountDataParameter(bank.domesticBankCode, bank.loginName, bank.password!!, listOf(accountIdentifier), true,
|
return GetAccountDataParameter(bank.domesticBankCode, bank.loginName, bank.password!!, listOf(accountIdentifier), true,
|
||||||
retrieveTransactions, from,
|
retrieveTransactions, from,
|
||||||
preferredTanMethods = preferredTanMethods,
|
preferredTanMethods = preferredTanMethods,
|
||||||
preferredTanMedium = bank.selectedTanMediumIdentifier,
|
preferredTanMedium = bank.selectedTanMediumIdentifier,
|
||||||
finTsModel = finTsModel
|
finTsModel = actualFinTsModel
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +93,7 @@ open class FinTs4kMapper {
|
||||||
|
|
||||||
open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse, bank: BankInfo? = null): Response<GetAccountDataResponse> =
|
open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse, bank: BankInfo? = null): Response<GetAccountDataResponse> =
|
||||||
if (response.successful && response.customerAccount != null) {
|
if (response.successful && response.customerAccount != null) {
|
||||||
Response.success(GetAccountDataResponse(mapBank(response.customerAccount!!, bank)))
|
Response.success(GetAccountDataResponse(mapBank(response.customerAccount!!, bank, response.serializedFinTsModel)))
|
||||||
} else {
|
} else {
|
||||||
mapError(response)
|
mapError(response)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +143,7 @@ open class FinTs4kMapper {
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
protected open fun mapBank(bank: net.dankito.banking.client.model.CustomerAccount, info: BankInfo? = null) = BankAccess(
|
protected open fun mapBank(bank: net.dankito.banking.client.model.CustomerAccount, info: BankInfo? = null, clientData: String? = null) = BankAccess(
|
||||||
bank.bankCode, bank.loginName, bank.password,
|
bank.bankCode, bank.loginName, bank.password,
|
||||||
info?.name ?: bank.bankName, bank.bic, bank.customerName, bank.userId,
|
info?.name ?: bank.bankName, bank.bic, bank.customerName, bank.userId,
|
||||||
bank.accounts.map { mapAccount(it) }.sortedBy { it.type }
|
bank.accounts.map { mapAccount(it) }.sortedBy { it.type }
|
||||||
|
@ -150,7 +155,9 @@ open class FinTs4kMapper {
|
||||||
info?.bankingGroup ?: getBankingGroup(bank.bankName, bank.bic),
|
info?.bankingGroup ?: getBankingGroup(bank.bankName, bank.bic),
|
||||||
bank.finTsServerAddress,
|
bank.finTsServerAddress,
|
||||||
"de"
|
"de"
|
||||||
)
|
).apply {
|
||||||
|
this.clientData = clientData
|
||||||
|
}
|
||||||
|
|
||||||
protected open fun getBankingGroup(bankName: String, bic: String): BankingGroup? =
|
protected open fun getBankingGroup(bankName: String, bic: String): BankingGroup? =
|
||||||
bankingGroupMapper.getBankingGroup(bankName, bic)
|
bankingGroupMapper.getBankingGroup(bankName, bic)
|
||||||
|
|
Loading…
Reference in New Issue