diff options
Diffstat (limited to 'wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt')
-rw-r--r-- | wallet/src/commonMain/kotlin/net/taler/lib/wallet/api/WalletFactory.kt | 28 |
1 files changed, 14 insertions, 14 deletions
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) } |