taler-android

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

Config.kt (1542B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2020 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.merchantlib
     18 
     19 import kotlinx.serialization.SerialName
     20 import kotlinx.serialization.Serializable
     21 
     22 @Serializable
     23 data class ConfigResponse(
     24     /**
     25      * libtool-style representation of the Merchant protocol version, see
     26      * https://www.gnu.org/software/libtool/manual/html_node/Versioning.html#Versioning
     27      * The format is "current:revision:age".
     28      */
     29     val version: String,
     30 
     31     /**
     32     Currency supported by this backend.
     33      */
     34     val currency: String
     35 )
     36 
     37 @Serializable
     38 data class MerchantConfig(
     39     @SerialName("base_url")
     40     val baseUrl: String,
     41     @SerialName("api_key")
     42     val apiKey: String
     43 ) {
     44     fun urlFor(endpoint: String): String {
     45         val sb = StringBuilder(baseUrl)
     46         if (sb.last() != '/') sb.append('/')
     47         sb.append(endpoint)
     48         return sb.toString()
     49     }
     50 }