TalerMessage.kt (5934B)
1 /* 2 * This file is part of LibEuFin. 3 * Copyright (C) 2024-2025 Taler Systems S.A. 4 * 5 * LibEuFin is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation; either version 3, or 8 * (at your option) any later version. 9 * 10 * LibEuFin is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General 13 * Public License for more details. 14 * 15 * You should have received a copy of the GNU Affero General Public 16 * License along with LibEuFin; see the file COPYING. If not, see 17 * <http://www.gnu.org/licenses/> 18 */ 19 20 package tech.libeufin.common 21 22 import kotlinx.serialization.* 23 24 enum class IncomingType { 25 reserve, 26 kyc, 27 wad 28 } 29 30 enum class TransferStatusState { 31 pending, 32 transient_failure, 33 permanent_failure, 34 success 35 } 36 37 /** Response GET /taler-wire-gateway/config */ 38 @Serializable 39 data class WireGatewayConfig( 40 val currency: String, 41 val support_account_check: Boolean 42 ) { 43 val name: String = "taler-wire-gateway" 44 val version: String = WIRE_GATEWAY_API_VERSION 45 } 46 47 /** Request POST /taler-wire-gateway/transfer */ 48 @Serializable 49 data class TransferRequest( 50 val request_uid: HashCode, 51 val amount: TalerAmount, 52 val exchange_base_url: BaseURL, 53 val wtid: ShortHashCode, 54 val credit_account: Payto 55 ) 56 57 /** Response POST /taler-wire-gateway/transfer */ 58 @Serializable 59 data class TransferResponse( 60 val timestamp: TalerTimestamp, 61 val row_id: Long 62 ) 63 64 /** Request GET /taler-wire-gateway/transfers */ 65 @Serializable 66 data class TransferList( 67 val transfers: List<TransferListStatus>, 68 val debit_account: String 69 ) 70 @Serializable 71 data class TransferListStatus( 72 val row_id: Long, 73 val status: TransferStatusState, 74 val amount: TalerAmount, 75 val credit_account: String, 76 val timestamp: TalerTimestamp 77 ) 78 79 /** Request GET /taler-wire-gateway/transfers/{ROW_iD} */ 80 @Serializable 81 data class TransferStatus( 82 val status: TransferStatusState, 83 val status_msg: String? = null, 84 val amount: TalerAmount, 85 val origin_exchange_url: String, 86 val wtid: ShortHashCode, 87 val credit_account: String, 88 val timestamp: TalerTimestamp 89 ) 90 91 /** Request POST /taler-wire-gateway/admin/add-incoming */ 92 @Serializable 93 data class AddIncomingRequest( 94 val amount: TalerAmount, 95 val reserve_pub: EddsaPublicKey, 96 val debit_account: Payto 97 ) 98 99 /** Response POST /taler-wire-gateway/admin/add-incoming */ 100 @Serializable 101 data class AddIncomingResponse( 102 val timestamp: TalerTimestamp, 103 val row_id: Long 104 ) 105 106 /** Request POST /taler-wire-gateway/admin/add-kycauth */ 107 @Serializable 108 data class AddKycauthRequest( 109 val amount: TalerAmount, 110 val account_pub: EddsaPublicKey, 111 val debit_account: Payto 112 ) 113 114 /** Response GET /taler-wire-gateway/history/incoming */ 115 @Serializable 116 data class IncomingHistory( 117 val incoming_transactions: List<IncomingBankTransaction>, 118 val credit_account: String 119 ) 120 121 /** Inner response GET /taler-wire-gateway/history/incoming */ 122 @Serializable 123 sealed interface IncomingBankTransaction { 124 val row_id: Long 125 val date: TalerTimestamp 126 val amount: TalerAmount 127 val debit_account: String 128 val credit_fee: TalerAmount? 129 } 130 131 @Serializable 132 @SerialName("KYCAUTH") 133 data class IncomingKycAuthTransaction( 134 override val row_id: Long, 135 override val date: TalerTimestamp, 136 override val amount: TalerAmount, 137 override val credit_fee: TalerAmount? = null, 138 override val debit_account: String, 139 val account_pub: EddsaPublicKey 140 ): IncomingBankTransaction 141 @Serializable 142 @SerialName("RESERVE") 143 data class IncomingReserveTransaction( 144 override val row_id: Long, 145 override val date: TalerTimestamp, 146 override val amount: TalerAmount, 147 override val credit_fee: TalerAmount? = null, 148 override val debit_account: String, 149 val reserve_pub: EddsaPublicKey 150 ): IncomingBankTransaction 151 @Serializable 152 @SerialName("WAD") 153 data class IncomingWadTransaction( 154 override val row_id: Long, 155 override val date: TalerTimestamp, 156 override val amount: TalerAmount, 157 override val credit_fee: TalerAmount? = null, 158 override val debit_account: String, 159 val origin_exchange_url: String, 160 val wad_id: String // TODO 24 bytes Base32 161 ): IncomingBankTransaction 162 163 /** Response GET /taler-wire-gateway/history/outgoing */ 164 @Serializable 165 data class OutgoingHistory( 166 val outgoing_transactions: List<OutgoingTransaction>, 167 val debit_account: String 168 ) 169 170 /** Inner response GET /taler-wire-gateway/history/outgoing */ 171 @Serializable 172 data class OutgoingTransaction( 173 val row_id: Long, // DB row ID of the payment. 174 val date: TalerTimestamp, 175 val amount: TalerAmount, 176 val credit_account: String, 177 val wtid: ShortHashCode, 178 val exchange_base_url: String, 179 val debit_fee: TalerAmount? = null 180 ) 181 182 /** Response GET /taler-wire-gateway/account/check */ 183 @Serializable 184 class AccountInfo() 185 186 /** Response GET /taler-revenue/config */ 187 @Serializable 188 data class RevenueConfig( 189 val currency: String 190 ) { 191 val name: String = "taler-revenue" 192 val version: String = REVENUE_API_VERSION 193 } 194 195 /** Request GET /taler-revenue/history */ 196 @Serializable 197 data class RevenueIncomingHistory( 198 val incoming_transactions : List<RevenueIncomingBankTransaction>, 199 val credit_account: String 200 ) 201 202 /** Inner request GET /taler-revenue/history */ 203 @Serializable 204 data class RevenueIncomingBankTransaction( 205 val row_id: Long, 206 val date: TalerTimestamp, 207 val amount: TalerAmount, 208 val credit_fee: TalerAmount? = null, 209 val debit_account: String, 210 val subject: String 211 ) 212 213 /** Response GET /taler-observability/config */ 214 @Serializable 215 class TalerObservabilityConfig() { 216 val name: String = "taler-observability" 217 val version: String = OBSERVABILITY_API_VERSION 218 }