taler-android

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

DonauResponses.kt (2774B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2025 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.donau
     18 
     19 import androidx.core.net.toUri
     20 import kotlinx.serialization.Serializable
     21 import net.taler.common.Amount
     22 import net.taler.wallet.backend.TalerErrorInfo
     23 
     24 @Serializable
     25 data class DonauInfo(
     26     val donauBaseUrl: String,
     27     val taxPayerId: String,
     28 )
     29 
     30 @Serializable
     31 data class GetDonauResponse(
     32     val currentDonauInfo: DonauInfo? = null,
     33 )
     34 
     35 @Serializable
     36 sealed class GetDonauStatus {
     37     data object None: GetDonauStatus()
     38     data object Loading: GetDonauStatus()
     39     data class Success(val donauInfo: DonauInfo?): GetDonauStatus()
     40     data class Error(val error: TalerErrorInfo): GetDonauStatus()
     41 }
     42 
     43 @Serializable
     44 data class DonauStatement(
     45     val total: Amount,
     46     val year: Int,
     47     val legalDomain: String,
     48     val uri: String,
     49     val donationStatementSig: String,
     50     val donauPub: String,
     51 ) {
     52     val host: String? by lazy {
     53         uri.toUri().host
     54     }
     55 }
     56 
     57 @Serializable
     58 data class DonauSummaryItem(
     59     /** Base URL of the donau service. */
     60     val donauBaseUrl: String,
     61 
     62     /** Legal domain of the donau service (if available). */
     63     val legalDomain: String? = null,
     64 
     65     /** Year of the donation(s). */
     66     val year: Int,
     67 
     68     /**
     69      * Sum of donation receipts we received from merchants in the
     70      * applicable year.
     71      */
     72     val amountReceiptsAvailable: Amount,
     73 
     74     /**
     75      * Sum of donation receipts that were already submitted
     76      * to the donau in the applicable year.
     77      */
     78     val amountReceiptsSubmitted: Amount,
     79 
     80     /**
     81      * Amount of the latest available statement. Missing if no statement
     82      * was requested yet.
     83      */
     84     val amountStatement: Amount? = null,
     85 )
     86 
     87 @Serializable
     88 data class GetDonauStatementsResponse(
     89     val statements: List<DonauStatement>,
     90 )
     91 
     92 @Serializable
     93 sealed class GetDonauStatementsStatus {
     94     data object None: GetDonauStatementsStatus()
     95     data object Loading: GetDonauStatementsStatus()
     96     data class Success(val statements: List<DonauStatement>) : GetDonauStatementsStatus()
     97     data class Error(val error: TalerErrorInfo): GetDonauStatementsStatus()
     98 }