summaryrefslogtreecommitdiff
path: root/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api
diff options
context:
space:
mode:
Diffstat (limited to 'wallet/src/commonMain/kotlin/net/taler/lib/wallet/api')
-rw-r--r--wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Exchanges.kt12
-rw-r--r--wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Version.kt10
-rw-r--r--wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletApi.kt14
-rw-r--r--wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt28
-rw-r--r--wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Withdrawal.kt4
5 files changed, 34 insertions, 34 deletions
diff --git a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Exchanges.kt b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Exchanges.kt
index 2542dd6..b847ebb 100644
--- a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Exchanges.kt
+++ b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Exchanges.kt
@@ -18,12 +18,12 @@ package net.taler.lib.wallet.api
import net.taler.lib.wallet.exchange.ExchangeRecord
-data class ExchangeListItem(
+public data class ExchangeListItem(
val exchangeBaseUrl: String,
val currency: String,
- val paytoUris: List<String>
+ val paytoUris: List<String>,
) {
- companion object {
+ internal companion object {
fun fromExchangeRecord(exchange: ExchangeRecord): ExchangeListItem? {
return if (exchange.details == null || exchange.wireInfo == null) null
else ExchangeListItem(
@@ -31,13 +31,13 @@ data class ExchangeListItem(
currency = exchange.details.currency,
paytoUris = exchange.wireInfo.accounts.map {
it.paytoUri
- }
+ },
)
}
}
}
-data class GetExchangeTosResult(
+public data class GetExchangeTosResult(
/**
* Markdown version of the current ToS.
*/
@@ -51,5 +51,5 @@ data class GetExchangeTosResult(
/**
* Version tag of the last ToS that the user has accepted, if any.
*/
- val acceptedEtag: String? = null
+ val acceptedEtag: String? = null,
)
diff --git a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Version.kt b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Version.kt
index 12916d3..ddf41db 100644
--- a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Version.kt
+++ b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Version.kt
@@ -18,9 +18,9 @@ package net.taler.lib.wallet.api
import net.taler.lib.common.Version
-class SupportedVersions(
- val walletVersion: Version,
- val exchangeVersion: Version,
- val bankVersion: Version,
- val merchantVersion: Version
+public class SupportedVersions(
+ public val walletVersion: Version,
+ public val exchangeVersion: Version,
+ public val bankVersion: Version,
+ public val merchantVersion: Version,
)
diff --git a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletApi.kt b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletApi.kt
index 026c682..995d3cb 100644
--- a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletApi.kt
+++ b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletApi.kt
@@ -19,11 +19,11 @@ package net.taler.lib.wallet.api
import net.taler.lib.common.Amount
public interface WalletApi {
- fun getVersions(): SupportedVersions
- fun getWithdrawalDetailsForUri(talerWithdrawUri: String): WithdrawalDetailsForUri
- fun getWithdrawalDetailsForAmount(exchangeBaseUrl: String, amount: Amount): WithdrawalDetails
- fun listExchanges(): List<ExchangeListItem>
- fun addExchange(exchangeBaseUrl: String): ExchangeListItem
- fun getExchangeTos(exchangeBaseUrl: String): GetExchangeTosResult
- fun setExchangeTosAccepted(exchangeBaseUrl: String, acceptedEtag: String)
+ public fun getVersions(): SupportedVersions
+ public fun getWithdrawalDetailsForUri(talerWithdrawUri: String): WithdrawalDetailsForUri
+ public fun getWithdrawalDetailsForAmount(exchangeBaseUrl: String, amount: Amount): WithdrawalDetails
+ public fun listExchanges(): List<ExchangeListItem>
+ public fun addExchange(exchangeBaseUrl: String): ExchangeListItem
+ public fun getExchangeTos(exchangeBaseUrl: String): GetExchangeTosResult
+ public fun setExchangeTosAccepted(exchangeBaseUrl: String, acceptedEtag: String)
}
diff --git a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt
index d56f80c..4a72eb7 100644
--- a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt
+++ b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt
@@ -31,10 +31,10 @@ import net.taler.lib.wallet.operations.Withdraw
public expect class WalletFactory {
- fun createWalletApi(): WalletApi
+ public fun createWalletApi(): WalletApi
}
-internal class WalletApiImpl {
+public class WalletApiImpl {
private val httpClient: HttpClient = getDefaultHttpClient()
private val db: Db = DbFactory().openDb()
@@ -43,25 +43,25 @@ internal class WalletApiImpl {
private val exchangeManager: Exchange = Exchange(crypto, signature, httpClient, db = db)
private val withdrawManager = Withdraw(httpClient, db, crypto, signature, exchangeManager)
- fun getVersions(): SupportedVersions {
+ public fun getVersions(): SupportedVersions {
return SupportedVersions(
walletVersion = Version(8, 0, 0),
exchangeVersion = Version(8, 0, 0),
bankVersion = Version(0, 0, 0),
- merchantVersion = Version(1, 0, 0)
+ merchantVersion = Version(1, 0, 0),
)
}
- suspend fun getWithdrawalDetailsForUri(talerWithdrawUri: String): WithdrawalDetailsForUri {
+ public suspend fun getWithdrawalDetailsForUri(talerWithdrawUri: String): WithdrawalDetailsForUri {
val bankInfo = withdrawManager.getBankInfo(talerWithdrawUri)
return WithdrawalDetailsForUri(
amount = bankInfo.amount,
defaultExchangeBaseUrl = bankInfo.suggestedExchange,
- possibleExchanges = emptyList()
+ possibleExchanges = emptyList(),
)
}
- suspend fun getWithdrawalDetailsForAmount(
+ public suspend fun getWithdrawalDetailsForAmount(
exchangeBaseUrl: String,
amount: Amount
): WithdrawalDetails {
@@ -69,37 +69,37 @@ internal class WalletApiImpl {
return WithdrawalDetails(
tosAccepted = details.exchange.termsOfServiceAccepted,
amountRaw = amount,
- amountEffective = amount - details.overhead - details.withdrawFee
+ amountEffective = amount - details.overhead - details.withdrawFee,
)
}
- suspend fun listExchanges(): List<ExchangeListItem> {
+ public suspend fun listExchanges(): List<ExchangeListItem> {
return db.listExchanges().mapNotNull { exchange ->
ExchangeListItem.fromExchangeRecord(exchange)
}
}
- suspend fun addExchange(exchangeBaseUrl: String): ExchangeListItem {
+ public suspend fun addExchange(exchangeBaseUrl: String): ExchangeListItem {
val exchange = exchangeManager.updateFromUrl(exchangeBaseUrl)
db.put(exchange)
return ExchangeListItem.fromExchangeRecord(exchange) ?: TODO("error handling")
}
- suspend fun getExchangeTos(exchangeBaseUrl: String): GetExchangeTosResult {
+ public suspend fun getExchangeTos(exchangeBaseUrl: String): GetExchangeTosResult {
val record = db.getExchangeByBaseUrl(exchangeBaseUrl) ?: TODO("error handling")
return GetExchangeTosResult(
tos = record.termsOfServiceText ?: TODO("error handling"),
currentEtag = record.termsOfServiceLastEtag ?: TODO("error handling"),
- acceptedEtag = record.termsOfServiceAcceptedEtag
+ acceptedEtag = record.termsOfServiceAcceptedEtag,
)
}
- suspend fun setExchangeTosAccepted(exchangeBaseUrl: String, acceptedEtag: String) {
+ public suspend fun setExchangeTosAccepted(exchangeBaseUrl: String, acceptedEtag: String) {
db.transaction {
val record = getExchangeByBaseUrl(exchangeBaseUrl) ?: TODO("error handling")
val updatedRecord = record.copy(
termsOfServiceAcceptedEtag = acceptedEtag,
- termsOfServiceAcceptedTimestamp = Timestamp.now()
+ termsOfServiceAcceptedTimestamp = Timestamp.now(),
)
put(updatedRecord)
}
diff --git a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Withdrawal.kt b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Withdrawal.kt
index 88c96a4..df86881 100644
--- a/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Withdrawal.kt
+++ b/wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/Withdrawal.kt
@@ -32,7 +32,7 @@ public data class WithdrawalDetailsForUri(
/**
* A list of exchanges that can be used for this withdrawal
*/
- val possibleExchanges: List<ExchangeListItem>
+ val possibleExchanges: List<ExchangeListItem>,
)
public data class WithdrawalDetails(
@@ -49,5 +49,5 @@ public data class WithdrawalDetails(
/**
* Amount that will be added to the user's wallet balance.
*/
- val amountEffective: Amount
+ val amountEffective: Amount,
)