Made fields and methods open
This commit is contained in:
parent
1a484e78b8
commit
ea6c4000f9
|
@ -17,9 +17,9 @@ open class FinTs4kBankingClient(
|
|||
constructor(callback: BankingClientCallback) : this(FinTsClientConfiguration(), callback)
|
||||
|
||||
|
||||
private val mapper = FinTs4kMapper()
|
||||
protected val mapper = FinTs4kMapper()
|
||||
|
||||
private val client = FinTsClient(config, BridgeFintTsToBankingClientCallback(callback, mapper))
|
||||
protected val client = FinTsClient(config, BridgeFintTsToBankingClientCallback(callback, mapper))
|
||||
|
||||
|
||||
override suspend fun getAccountDataAsync(request: GetAccountDataRequest): Response<GetAccountDataResponse> {
|
||||
|
|
|
@ -22,10 +22,10 @@ import kotlin.io.encoding.ExperimentalEncodingApi
|
|||
|
||||
open class FinTs4kMapper {
|
||||
|
||||
private val fintsModelMapper = FinTsModelMapper()
|
||||
protected val fintsModelMapper = FinTsModelMapper()
|
||||
|
||||
|
||||
fun mapToGetAccountDataParameter(credentials: AccountCredentials, options: GetAccountDataOptions) = GetAccountDataParameter(
|
||||
open fun mapToGetAccountDataParameter(credentials: AccountCredentials, options: GetAccountDataOptions) = GetAccountDataParameter(
|
||||
credentials.bankCode, credentials.loginName, credentials.password,
|
||||
options.accounts.map { BankAccountIdentifierImpl(it.identifier, it.subAccountNumber, it.iban) },
|
||||
options.retrieveBalance,
|
||||
|
@ -34,7 +34,7 @@ open class FinTs4kMapper {
|
|||
)
|
||||
|
||||
|
||||
fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<GetAccountDataResponse> {
|
||||
open fun map(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<GetAccountDataResponse> {
|
||||
return if (response.successful && response.customerAccount != null) {
|
||||
Response.success(GetAccountDataResponse(mapCustomer(response.customerAccount!!)))
|
||||
} else {
|
||||
|
@ -43,25 +43,25 @@ open class FinTs4kMapper {
|
|||
}
|
||||
|
||||
|
||||
fun mapToCustomerAccountViewInfo(bank: BankData): CustomerAccountViewInfo = CustomerAccountViewInfo(
|
||||
open fun mapToCustomerAccountViewInfo(bank: BankData): CustomerAccountViewInfo = CustomerAccountViewInfo(
|
||||
bank.bankCode, bank.customerId, bank.bankName
|
||||
)
|
||||
|
||||
fun mapToBankAccountViewInfo(account: AccountData): BankAccountViewInfo = BankAccountViewInfo(
|
||||
open fun mapToBankAccountViewInfo(account: AccountData): BankAccountViewInfo = BankAccountViewInfo(
|
||||
account.accountIdentifier, account.subAccountAttribute,
|
||||
mapAccountType(fintsModelMapper.map(account.accountType)),
|
||||
account.iban, account.productName
|
||||
)
|
||||
|
||||
|
||||
private fun mapCustomer(customer: net.dankito.banking.client.model.CustomerAccount): CustomerAccount = CustomerAccount(
|
||||
protected open fun mapCustomer(customer: net.dankito.banking.client.model.CustomerAccount): CustomerAccount = CustomerAccount(
|
||||
customer.bankCode, customer.loginName, customer.password,
|
||||
customer.bankName, customer.bic, customer.customerName, customer.userId,
|
||||
customer.accounts.map { mapAccount(it) }
|
||||
)
|
||||
|
||||
|
||||
private fun mapAccount(account: net.dankito.banking.client.model.BankAccount): BankAccount = BankAccount(
|
||||
protected open fun mapAccount(account: net.dankito.banking.client.model.BankAccount): BankAccount = BankAccount(
|
||||
account.identifier, account.accountHolderName, mapAccountType(account.type), account.iban, account.subAccountNumber,
|
||||
account.productName, account.currency, account.accountLimit, account.isAccountTypeSupportedByApplication,
|
||||
mapFeatures(account),
|
||||
|
@ -71,10 +71,10 @@ open class FinTs4kMapper {
|
|||
bookedTransactions = account.bookedTransactions.map { mapTransaction(it) }.toMutableList()
|
||||
)
|
||||
|
||||
private fun mapAccountType(type: net.dankito.banking.client.model.BankAccountType): BankAccountType =
|
||||
protected open fun mapAccountType(type: net.dankito.banking.client.model.BankAccountType): BankAccountType =
|
||||
BankAccountType.valueOf(type.name)
|
||||
|
||||
private fun mapFeatures(account: net.dankito.banking.client.model.BankAccount): Set<BankAccountFeatures> = buildSet {
|
||||
protected open fun mapFeatures(account: net.dankito.banking.client.model.BankAccount): Set<BankAccountFeatures> = buildSet {
|
||||
if (account.supportsRetrievingBalance) {
|
||||
add(BankAccountFeatures.RetrieveBalance)
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ open class FinTs4kMapper {
|
|||
}
|
||||
|
||||
|
||||
private fun mapTransaction(transaction: net.dankito.banking.client.model.AccountTransaction): AccountTransaction = AccountTransaction(
|
||||
protected open fun mapTransaction(transaction: net.dankito.banking.client.model.AccountTransaction): AccountTransaction = AccountTransaction(
|
||||
mapAmount(transaction.amount), transaction.amount.currency.code, transaction.unparsedReference,
|
||||
transaction.bookingDate, transaction.valueDate,
|
||||
transaction.otherPartyName, transaction.otherPartyBankCode, transaction.otherPartyAccountId,
|
||||
|
@ -100,12 +100,12 @@ open class FinTs4kMapper {
|
|||
// TODO: map other properties
|
||||
)
|
||||
|
||||
private fun mapNullableAmount(amount: Money?) = amount?.let { mapAmount(it) }
|
||||
protected open fun mapNullableAmount(amount: Money?) = amount?.let { mapAmount(it) }
|
||||
|
||||
private fun mapAmount(amount: Money) = Amount.fromString(amount.amount.string.replace(',', '.'))
|
||||
protected open fun mapAmount(amount: Money) = Amount.fromString(amount.amount.string.replace(',', '.'))
|
||||
|
||||
|
||||
fun mapTanChallenge(challenge: net.codinux.banking.fints.model.TanChallenge): TanChallenge {
|
||||
open fun mapTanChallenge(challenge: net.codinux.banking.fints.model.TanChallenge): TanChallenge {
|
||||
val type = mapTanChallengeType(challenge)
|
||||
val action = mapActionRequiringTan(challenge.forAction)
|
||||
val tanMethod = mapTanMethod(challenge.tanMethod)
|
||||
|
@ -118,38 +118,38 @@ open class FinTs4kMapper {
|
|||
return TanChallenge(type, action, challenge.messageToShowToUser, tanMethod, tanImage, flickerCode, customer, account)
|
||||
}
|
||||
|
||||
private fun mapTanChallengeType(challenge: net.codinux.banking.fints.model.TanChallenge): TanChallengeType = when {
|
||||
protected open fun mapTanChallengeType(challenge: net.codinux.banking.fints.model.TanChallenge): TanChallengeType = when {
|
||||
challenge is ImageTanChallenge -> TanChallengeType.Image
|
||||
challenge is FlickerCodeTanChallenge -> TanChallengeType.Flickercode
|
||||
else -> TanChallengeType.EnterTan
|
||||
}
|
||||
|
||||
private fun mapActionRequiringTan(action: net.codinux.banking.fints.model.ActionRequiringTan): ActionRequiringTan =
|
||||
protected open fun mapActionRequiringTan(action: net.codinux.banking.fints.model.ActionRequiringTan): ActionRequiringTan =
|
||||
ActionRequiringTan.valueOf(action.name)
|
||||
|
||||
private fun mapTanMethod(method: net.codinux.banking.fints.model.TanMethod): TanMethod = TanMethod(
|
||||
protected open fun mapTanMethod(method: net.codinux.banking.fints.model.TanMethod): TanMethod = TanMethod(
|
||||
method.displayName, mapTanMethodType(method.type), method.securityFunction.code, method.maxTanInputLength, mapAllowedTanFormat(method.allowedTanFormat)
|
||||
)
|
||||
|
||||
private fun mapTanMethodType(type: net.codinux.banking.fints.model.TanMethodType): TanMethodType =
|
||||
protected open fun mapTanMethodType(type: net.codinux.banking.fints.model.TanMethodType): TanMethodType =
|
||||
TanMethodType.valueOf(type.name)
|
||||
|
||||
private fun mapAllowedTanFormat(allowedTanFormat: net.codinux.banking.fints.messages.datenelemente.implementierte.tan.AllowedTanFormat?): AllowedTanFormat =
|
||||
protected open fun mapAllowedTanFormat(allowedTanFormat: net.codinux.banking.fints.messages.datenelemente.implementierte.tan.AllowedTanFormat?): AllowedTanFormat =
|
||||
allowedTanFormat?.let { AllowedTanFormat.valueOf(it.name) } ?: AllowedTanFormat.Alphanumeric
|
||||
|
||||
private fun mapTanImage(image: net.codinux.banking.fints.tan.TanImage): TanImage =
|
||||
protected open fun mapTanImage(image: net.codinux.banking.fints.tan.TanImage): TanImage =
|
||||
TanImage(image.mimeType, mapToBase64(image.imageBytes), mapException(image.decodingError))
|
||||
|
||||
@OptIn(ExperimentalEncodingApi::class)
|
||||
private fun mapToBase64(bytes: ByteArray): String {
|
||||
protected open fun mapToBase64(bytes: ByteArray): String {
|
||||
return Base64.Default.encode(bytes)
|
||||
}
|
||||
|
||||
private fun mapFlickerCode(flickerCode: net.codinux.banking.fints.tan.FlickerCode): FlickerCode =
|
||||
protected open fun mapFlickerCode(flickerCode: net.codinux.banking.fints.tan.FlickerCode): FlickerCode =
|
||||
FlickerCode(flickerCode.challengeHHD_UC, flickerCode.parsedDataSet, mapException(flickerCode.decodingError))
|
||||
|
||||
|
||||
private fun <T> mapError(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<T> {
|
||||
protected open fun <T> mapError(response: net.dankito.banking.client.model.response.GetAccountDataResponse): Response<T> {
|
||||
return if (response.error != null) {
|
||||
Response.error(ErrorType.valueOf(response.error!!.name), if (response.error == ErrorCode.BankReturnedError) null else response.errorMessage,
|
||||
if (response.error == ErrorCode.BankReturnedError && response.errorMessage !== null) listOf(response.errorMessage!!) else emptyList())
|
||||
|
@ -158,7 +158,7 @@ open class FinTs4kMapper {
|
|||
}
|
||||
}
|
||||
|
||||
private fun mapException(exception: Exception?): String? =
|
||||
protected open fun mapException(exception: Exception?): String? =
|
||||
exception?.stackTraceToString()
|
||||
|
||||
}
|
Loading…
Reference in New Issue