taler-android

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

ApiResponse.kt (1797B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2023 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.backend
     18 
     19 import kotlinx.serialization.SerialName
     20 import kotlinx.serialization.Serializable
     21 import kotlinx.serialization.json.JsonObject
     22 import net.taler.wallet.events.ObservabilityEvent
     23 
     24 @Serializable
     25 sealed class ApiMessage {
     26 
     27     @Serializable
     28     @SerialName("notification")
     29     data class Notification(
     30         val payload: NotificationPayload,
     31     ) : ApiMessage()
     32 
     33 }
     34 
     35 @Serializable
     36 data class NotificationPayload(
     37     val type: String,
     38     val id: String? = null,
     39     val event: ObservabilityEvent? = null,
     40     val transactionId: String? = null,
     41 )
     42 
     43 @Serializable
     44 sealed class ApiResponse : ApiMessage() {
     45 
     46     abstract val id: Int
     47     abstract val operation: String
     48 
     49     @Serializable
     50     @SerialName("response")
     51     data class Response(
     52         override val id: Int,
     53         override val operation: String,
     54         val result: JsonObject,
     55     ) : ApiResponse()
     56 
     57     @Serializable
     58     @SerialName("error")
     59     data class Error(
     60         override val id: Int,
     61         override val operation: String,
     62         val error: JsonObject,
     63     ) : ApiResponse()
     64 }