Added GetAccountDataRequest so that user can specify credentials and GetAccountDataOptions in one object / request body
This commit is contained in:
parent
7706ab5c99
commit
8613bdb06c
|
@ -1,19 +1,14 @@
|
|||
package net.codinux.banking.client
|
||||
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
import net.codinux.banking.client.model.response.GetAccountDataResponse
|
||||
import net.codinux.banking.client.model.response.Response
|
||||
|
||||
interface BankingClient {
|
||||
|
||||
suspend fun getAccountDataAsync(bankCode: String, loginName: String, password: String) =
|
||||
getAccountDataAsync(AccountCredentials(bankCode, loginName, password))
|
||||
getAccountDataAsync(GetAccountDataRequest(bankCode, loginName, password))
|
||||
|
||||
// for languages not supporting default parameters (Java, Swift, JS, ...)
|
||||
suspend fun getAccountDataAsync(credentials: AccountCredentials) =
|
||||
getAccountDataAsync(credentials, GetAccountDataOptions())
|
||||
|
||||
suspend fun getAccountDataAsync(credentials: AccountCredentials, options: GetAccountDataOptions): Response<GetAccountDataResponse>
|
||||
suspend fun getAccountDataAsync(request: GetAccountDataRequest): Response<GetAccountDataResponse>
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package net.codinux.banking.client
|
|||
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
|
||||
abstract class BankingClientForCustomerBase(
|
||||
protected val credentials: AccountCredentials,
|
||||
|
@ -9,6 +10,6 @@ abstract class BankingClientForCustomerBase(
|
|||
) : BankingClientForCustomer {
|
||||
|
||||
override suspend fun getAccountDataAsync(options: GetAccountDataOptions) =
|
||||
client.getAccountDataAsync(credentials, options)
|
||||
client.getAccountDataAsync(GetAccountDataRequest(credentials, options))
|
||||
|
||||
}
|
|
@ -1,19 +1,14 @@
|
|||
package net.codinux.banking.client
|
||||
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
import net.codinux.banking.client.model.response.GetAccountDataResponse
|
||||
import net.codinux.banking.client.model.response.Response
|
||||
|
||||
interface BlockingBankingClient {
|
||||
|
||||
suspend fun getAccountData(bankCode: String, loginName: String, password: String) =
|
||||
getAccountData(AccountCredentials(bankCode, loginName, password))
|
||||
getAccountData(GetAccountDataRequest(bankCode, loginName, password))
|
||||
|
||||
// for languages not supporting default parameters (Java, Swift, JS, ...)
|
||||
fun getAccountData(credentials: AccountCredentials) =
|
||||
getAccountData(credentials, GetAccountDataOptions())
|
||||
|
||||
fun getAccountData(credentials: AccountCredentials, options: GetAccountDataOptions): Response<GetAccountDataResponse>
|
||||
fun getAccountData(request: GetAccountDataRequest): Response<GetAccountDataResponse>
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@ package net.codinux.banking.client
|
|||
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
|
||||
abstract class BlockingBankingClientForCustomerBase(
|
||||
protected val credentials: AccountCredentials,
|
||||
|
@ -9,6 +10,6 @@ abstract class BlockingBankingClientForCustomerBase(
|
|||
) : BlockingBankingClientForCustomer {
|
||||
|
||||
override fun getAccountData(options: GetAccountDataOptions) =
|
||||
client.getAccountData(credentials, options)
|
||||
client.getAccountData(GetAccountDataRequest(credentials, options))
|
||||
|
||||
}
|
|
@ -1,15 +1,15 @@
|
|||
package net.codinux.banking.client
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
|
||||
fun BankingClient.getAccountData(credentials: AccountCredentials) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(credentials)
|
||||
fun BankingClient.getAccountData(bankCode: String, loginName: String, password: String) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(bankCode, loginName, password)
|
||||
}
|
||||
|
||||
fun BankingClient.getAccountData(credentials: AccountCredentials, options: GetAccountDataOptions) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(credentials, options)
|
||||
fun BankingClient.getAccountData(request: GetAccountDataRequest) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(request)
|
||||
}
|
||||
|
||||
fun BankingClientForCustomer.getAccountData() = runBlocking {
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package net.codinux.banking.client
|
||||
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
|
||||
fun BankingClient.getAccountData(credentials: AccountCredentials) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(credentials)
|
||||
fun BankingClient.getAccountData(bankCode: String, loginName: String, password: String) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(bankCode, loginName, password)
|
||||
}
|
||||
|
||||
fun BankingClient.getAccountData(credentials: AccountCredentials, options: GetAccountDataOptions) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(credentials, options)
|
||||
fun BankingClient.getAccountData(request: GetAccountDataRequest) = runBlocking {
|
||||
this@getAccountData.getAccountDataAsync(request)
|
||||
}
|
||||
|
||||
fun BankingClientForCustomer.getAccountData() = runBlocking {
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
package net.codinux.banking.client.model.options
|
||||
|
||||
import kotlinx.datetime.LocalDate
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
|
||||
@NoArgConstructor
|
||||
open class GetAccountDataOptions(
|
||||
val retrieveBalance: Boolean = true,
|
||||
val retrieveTransactions: RetrieveTransactions = RetrieveTransactions.OfLast90Days,
|
||||
val retrieveTransactionsFrom: LocalDate? = null,
|
||||
val retrieveTransactionsTo: LocalDate? = null,
|
||||
val abortIfTanIsRequired: Boolean = false
|
||||
)
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return "retrieveBalance=$retrieveBalance, retrieveTransactions=$retrieveTransactions, abortIfTanIsRequired=$abortIfTanIsRequired"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package net.codinux.banking.client.model.request
|
||||
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.config.NoArgConstructor
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
|
||||
@NoArgConstructor
|
||||
open class GetAccountDataRequest(bankCode: String, loginName: String, password: String, val options: GetAccountDataOptions? = null)
|
||||
: AccountCredentials(bankCode, loginName, password) {
|
||||
|
||||
constructor(credentials: AccountCredentials, options: GetAccountDataOptions? = null)
|
||||
: this(credentials.bankCode, credentials.loginName, credentials.loginName, options)
|
||||
|
||||
override fun toString() = "${super.toString()}: $options"
|
||||
}
|
|
@ -3,6 +3,7 @@ package net.codinux.banking.client.fints4k
|
|||
import net.codinux.banking.client.BankingClient
|
||||
import net.codinux.banking.client.model.AccountCredentials
|
||||
import net.codinux.banking.client.model.options.GetAccountDataOptions
|
||||
import net.codinux.banking.client.model.request.GetAccountDataRequest
|
||||
import net.codinux.banking.client.model.response.GetAccountDataResponse
|
||||
import net.codinux.banking.client.model.response.Response
|
||||
import net.dankito.banking.fints.FinTsClient
|
||||
|
@ -17,8 +18,8 @@ open class FinTs4kBankingClient : BankingClient {
|
|||
})
|
||||
|
||||
|
||||
override suspend fun getAccountDataAsync(credentials: AccountCredentials, options: GetAccountDataOptions): Response<GetAccountDataResponse> {
|
||||
val response = client.getAccountDataAsync(mapper.mapToGetAccountDataParameter(credentials, options))
|
||||
override suspend fun getAccountDataAsync(request: GetAccountDataRequest): Response<GetAccountDataResponse> {
|
||||
val response = client.getAccountDataAsync(mapper.mapToGetAccountDataParameter(request, request.options ?: GetAccountDataOptions()))
|
||||
|
||||
return mapper.map(response)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue