Added example for reading TAN from command line
This commit is contained in:
parent
2853087836
commit
62fe93e88e
29
README.md
29
README.md
|
@ -82,7 +82,10 @@ class ShowUsage {
|
|||
|
||||
This fetches the booked account transactions of the last 90 days. In most cases no TAN is required for this.
|
||||
|
||||
You can also specify options e.g. which transactions should be retrieved:
|
||||
|
||||
#### GetAccountData parameter
|
||||
|
||||
You can also specify options e.g. which transactions you would like to retrieve:
|
||||
|
||||
```kotlin
|
||||
val options = GetAccountDataOptions(
|
||||
|
@ -95,15 +98,35 @@ val options = GetAccountDataOptions(
|
|||
val response = client.getAccountData(options)
|
||||
```
|
||||
|
||||
Retrieving transactions older than 90 days requires a TAN, so add TAN handling in Client Callback:
|
||||
### TAN handling
|
||||
|
||||
Retrieving transactions older than 90 days or sometimes even log in requires a TAN, so add TAN handling in Client Callback:
|
||||
|
||||
```kotlin
|
||||
val client = FinTs4kBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
|
||||
val tan: String? = null // if a TAN is required, add a UI or ...
|
||||
val tan: String? = null // if a TAN is required, read TAN from command line, add a UI, ...
|
||||
callback.invoke(EnterTanResult(tan)) // ... set a break point here, get TAN e.g. from your TAN app, set tan variable in debugger view and resume debugger
|
||||
})
|
||||
```
|
||||
|
||||
E.g. TAN handling on the command line:
|
||||
|
||||
```kotlin
|
||||
println("Enter password for $bankCode:")
|
||||
val password = readln() // as an alternative for hard coding password; of course can also be done for bankCode and login name
|
||||
|
||||
val client = FinTs4kBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
|
||||
println("A TAN is required for ${tanChallenge.forAction}. Selected TAN method is '${tanChallenge.selectedTanMethod.displayName}'. Messsage of your credit institute:")
|
||||
println(tanChallenge.messageToShowToUser)
|
||||
println("Get TAN from your TAN app etc., enter it and press Enter (or press Enter without an input to abort process):")
|
||||
|
||||
val tan: String? = readlnOrNull().takeUnless { it.isNullOrBlank() } // map empty input to null to abort process
|
||||
callback.invoke(EnterTanResult(tan))
|
||||
})
|
||||
```
|
||||
|
||||
### Error handling
|
||||
|
||||
Add some error handling by checking `response.error`:
|
||||
|
||||
```kotlin
|
||||
|
|
|
@ -42,9 +42,16 @@ class ShowUsage {
|
|||
}
|
||||
|
||||
fun getAccountDataFullExample() {
|
||||
println("Enter password for $bankCode:")
|
||||
val password = readln() // as an alternative for hard coding password; of course can also be done for bankCode and login name
|
||||
|
||||
val client = FinTs4kBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
|
||||
val tan: String? = null // if a TAN is required, add a UI or ...
|
||||
callback.invoke(EnterTanResult(tan)) // ... set a break point here, get TAN e.g. from your TAN app, set tan variable in debugger view and resume debugger
|
||||
println("A TAN is required for ${tanChallenge.forAction}. Selected TAN method is '${tanChallenge.selectedTanMethod.displayName}'. Messsage of your credit institute:")
|
||||
println(tanChallenge.messageToShowToUser)
|
||||
println("Get TAN from your TAN app etc., enter it and press Enter (or press Enter without an input to abort process):")
|
||||
|
||||
val tan: String? = readlnOrNull().takeUnless { it.isNullOrBlank() } // map empty input to null to abort process
|
||||
callback.invoke(EnterTanResult(tan))
|
||||
})
|
||||
|
||||
val options = GetAccountDataOptions(
|
||||
|
@ -65,7 +72,10 @@ class ShowUsage {
|
|||
|
||||
|
||||
fun updateAccountTransactions() {
|
||||
val client = FinTs4kBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback())
|
||||
val client = FinTs4kBankingClientForUser(bankCode, loginName, password, SimpleBankingClientCallback { tanChallenge, callback ->
|
||||
val tan: String? = readlnOrNull() // if a TAN is required, read TAN from command line, add a UI, ...
|
||||
callback.invoke(EnterTanResult(tan)) // ... set a break point here, get TAN e.g. from your TAN app, set tan variable in debugger view and resume debugger
|
||||
})
|
||||
|
||||
// simulate account transactions we retrieved last time
|
||||
val today = Clock.System.now().toLocalDateTime(TimeZone.currentSystemDefault()).date
|
||||
|
|
Loading…
Reference in New Issue