From fad7a98d9d6c74d7be4f48826472fb237ee60d5d Mon Sep 17 00:00:00 2001 From: dankito Date: Sat, 17 Aug 2024 03:25:24 +0200 Subject: [PATCH] Added blocking calls to async BankingClient --- BankingClient/build.gradle.kts | 2 ++ .../banking/client/BankingClientExtensions.kt | 21 +++++++++++++++++++ .../banking/client/BankingClientExtensions.kt | 21 +++++++++++++++++++ gradle.properties | 1 + 4 files changed, 45 insertions(+) create mode 100644 BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt create mode 100644 BankingClient/src/nativeMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt diff --git a/BankingClient/build.gradle.kts b/BankingClient/build.gradle.kts index bf453982..916f176c 100644 --- a/BankingClient/build.gradle.kts +++ b/BankingClient/build.gradle.kts @@ -72,6 +72,8 @@ kotlin { commonMain { dependencies { api(project(":BankingClientModel")) + + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") } } commonTest { diff --git a/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt b/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt new file mode 100644 index 00000000..6e07146d --- /dev/null +++ b/BankingClient/src/jvmMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt @@ -0,0 +1,21 @@ +package net.codinux.banking.client + +import kotlinx.coroutines.runBlocking +import net.codinux.banking.client.model.AccountCredentials +import net.codinux.banking.client.model.options.GetAccountDataOptions + +fun BankingClient.getAccountData(credentials: AccountCredentials) = runBlocking { + this@getAccountData.getAccountDataAsync(credentials) +} + +fun BankingClient.getAccountData(credentials: AccountCredentials, options: GetAccountDataOptions) = runBlocking { + this@getAccountData.getAccountDataAsync(credentials, options) +} + +fun BankingClientForCustomer.getAccountData() = runBlocking { + this@getAccountData.getAccountDataAsync() +} + +fun BankingClientForCustomer.getAccountData(options: GetAccountDataOptions) = runBlocking { + this@getAccountData.getAccountDataAsync(options) +} \ No newline at end of file diff --git a/BankingClient/src/nativeMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt b/BankingClient/src/nativeMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt new file mode 100644 index 00000000..6e07146d --- /dev/null +++ b/BankingClient/src/nativeMain/kotlin/net/codinux/banking/client/BankingClientExtensions.kt @@ -0,0 +1,21 @@ +package net.codinux.banking.client + +import kotlinx.coroutines.runBlocking +import net.codinux.banking.client.model.AccountCredentials +import net.codinux.banking.client.model.options.GetAccountDataOptions + +fun BankingClient.getAccountData(credentials: AccountCredentials) = runBlocking { + this@getAccountData.getAccountDataAsync(credentials) +} + +fun BankingClient.getAccountData(credentials: AccountCredentials, options: GetAccountDataOptions) = runBlocking { + this@getAccountData.getAccountDataAsync(credentials, options) +} + +fun BankingClientForCustomer.getAccountData() = runBlocking { + this@getAccountData.getAccountDataAsync() +} + +fun BankingClientForCustomer.getAccountData(options: GetAccountDataOptions) = runBlocking { + this@getAccountData.getAccountDataAsync(options) +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d7b1bf02..fadc1c09 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,3 +5,4 @@ kotlinVersion=2.0.10 kotlinxDateTimeVersion=0.6.0 jsJodaTimeZoneVersion=2.3.0 +coroutinesVersion=1.8.1