taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

Exchanges.kt (1971B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2024 Taler Systems S.A.
      4  *
      5  * GNU Taler is free software; you can redistribute it and/or modify it under the
      6  * terms of the GNU General Public License as published by the Free Software
      7  * Foundation; either version 3, or (at your option) any later version.
      8  *
      9  * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11  * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License along with
     14  * GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15  */
     16 
     17 package net.taler.wallet.exchanges
     18 
     19 import kotlinx.serialization.SerialName
     20 import kotlinx.serialization.Serializable
     21 import net.taler.wallet.balances.ScopeInfo
     22 import net.taler.wallet.cleanExchange
     23 
     24 @Serializable
     25 data class BuiltinExchange(
     26     val exchangeBaseUrl: String,
     27     val currencyHint: String? = null,
     28 )
     29 
     30 @Serializable
     31 data class ExchangeItem(
     32     val exchangeBaseUrl: String,
     33     val masterPub: String? = null,
     34     // can be null before exchange info in wallet-core was fully loaded
     35     val currency: String? = null,
     36     val paytoUris: List<String>,
     37     val scopeInfo: ScopeInfo? = null,
     38     val tosStatus: ExchangeTosStatus,
     39 ) {
     40     val name: String get() = cleanExchange(exchangeBaseUrl)
     41 }
     42 
     43 @Serializable
     44 enum class ExchangeTosStatus {
     45     Unknown,
     46 
     47     @SerialName("pending")
     48     Pending,
     49 
     50     @SerialName("proposed")
     51     Proposed,
     52 
     53     @SerialName("accepted")
     54     Accepted,
     55 
     56     @SerialName("missing-tos")
     57     MissingTos;
     58 
     59     fun isAccepted() = this in listOf(Accepted, MissingTos)
     60 }
     61 
     62 @Serializable
     63 data class TosResponse(
     64     val status: ExchangeTosStatus = ExchangeTosStatus.Unknown,
     65     val content: String,
     66     val currentEtag: String,
     67     val contentLanguage: String? = null,
     68     val tosAvailableLanguages: List<String> = emptyList(),
     69 )