taler-android

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

TokenResponses.kt (2270B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2026 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.tokens
     18 
     19 import kotlinx.serialization.Serializable
     20 import net.taler.common.Merchant
     21 import net.taler.common.Timestamp
     22 
     23 @Serializable
     24 data class DiscountListDetail(
     25     val tokenFamilyHash: String,
     26     val tokenIssuePubHash: String,
     27     val merchantBaseUrl: String,
     28     val merchantInfo: Merchant? = null,
     29     val name: String,
     30     val description: String,
     31     val descriptionI18n: Map<String, String>,
     32     val validityStart: Timestamp,
     33     val validityEnd: Timestamp,
     34     val tokensAvailable: Int,
     35 ) {
     36     val isActive: Boolean get() {
     37         val now = Timestamp.now()
     38         return now in validityStart..validityEnd
     39     }
     40 
     41     val isExpired: Boolean get() {
     42         val now = Timestamp.now()
     43         return now >= validityEnd
     44     }
     45 }
     46 
     47 @Serializable
     48 data class ListDiscountsResponse(
     49     val discounts: List<DiscountListDetail>,
     50 )
     51 
     52 @Serializable
     53 data class SubscriptionListDetail(
     54     val tokenFamilyHash: String,
     55     val tokenIssuePubHash: String,
     56     val merchantBaseUrl: String,
     57     val merchantInfo: Merchant? = null,
     58     val name: String,
     59     val description: String,
     60     val descriptionI18n: Map<String, String>,
     61     val validityStart: Timestamp,
     62     val validityEnd: Timestamp,
     63 ) {
     64     val isActive: Boolean get() {
     65         val now = Timestamp.now()
     66         return now in validityStart..validityEnd
     67     }
     68 
     69     val isExpired: Boolean get() {
     70         val now = Timestamp.now()
     71         return now >= validityEnd
     72     }
     73 }
     74 
     75 @Serializable
     76 data class ListSubscriptionsResponse(
     77     val subscriptions: List<SubscriptionListDetail>,
     78 )