bank_api_get_withdrawals.h (3851B)
1 /* 2 This file is part of TALER cash2ecash 3 Copyright (C) 2026 GNUnet e.V. 4 5 This program 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 of the 8 License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU Affero General Public License for more details. 15 16 You should have received a copy of the GNU Affero General Public License 17 along with this program. If not, see <https://www.gnu.org/licenses/>. 18 */ 19 /** 20 * @file lib/bank_api_get_withdrawals.h 21 * @brief implements the Taler Bank API "GET /withdrawals/$WITHDRAWAL_ID" handler 22 * @author Reto Tellenbach 23 */ 24 #ifndef BANK_API_GET_WITHDRAWALS_H 25 #define BANK_API_GET_WITHDRAWALS_H 26 27 #include "api_common.h" 28 29 30 /** 31 * @brief Information about withrawal operation 32 */ 33 struct TALER_BANK_WithdrawalInfo 34 { 35 /** 36 * Current status of the account 37 * active: the account can be used 38 * locked: the account can be used but cannot create new tokens 39 * deleted: the account has been deleted but is retained for compliance 40 */ 41 const char *status; 42 43 /** 44 * Amount that will be withdrawn with this operation 45 */ 46 struct TALER_Amount amount; 47 48 /** 49 * Suggestion for the amount to be withdrawn with this 50 * operation 51 */ 52 struct TALER_Amount suggested_amount; 53 54 /** 55 * indication that no amount was set at creation. 56 * therfor amount must be set in confirm step 57 */ 58 bool no_amount_to_wallet; 59 60 /** 61 * Bank account username 62 */ 63 const char *username; 64 65 /** 66 * Reserve public key selected by the exchange, 67 * only non-null if status is selected or confirmed. 68 */ 69 const char *selected_reserve_pub; 70 71 /** 72 * Exchange account selected by the wallet 73 * only non-null if status is selected or confirmed. 74 */ 75 const char *selected_exchange_account; 76 }; 77 78 /** 79 * Response details for a /withdrawals/$WITHDRAWAL_ID request 80 */ 81 struct TALER_BANK_WithdrawalResponse 82 { 83 84 /** 85 * HTTP response 86 */ 87 struct TALER_BANK_HttpResponse hr; 88 89 /** 90 * Details returned depending on the @e http_status. 91 */ 92 union 93 { 94 95 /** 96 * Details if status was request was succesfull 97 */ 98 struct 99 { 100 101 /** 102 * Config data returned by accounts/$USERNAME 103 */ 104 struct TALER_BANK_WithdrawalInfo acc; 105 106 } ok; 107 108 } details; 109 110 }; 111 112 113 /** 114 * Function called with information about the withdrawal operation 115 * 116 * @param cls closure 117 * @param vr response data 118 */ 119 typedef void 120 (*TALER_BANK_WithdrawalCallback) ( 121 void *cls, 122 const struct TALER_BANK_WithdrawalResponse *vr); 123 124 125 /** 126 * Handle for the get withdrawal request. 127 */ 128 struct TALER_BANK_GetWithdrawalHandle; 129 130 131 /** 132 * Obtain wopid inforamtion 133 * @param ctx curl context 134 * @param url bank url 135 * @param wopid withdrawal operation id 136 * @param withdrawal_cb callback 137 * @param withdrawal_cb_cls callback context 138 * @param timeout_ms timeout to long-polling, ignored when NULL, therfor no long-poll 139 * @return NULL on failure 140 */ 141 struct TALER_BANK_GetWithdrawalHandle * 142 TALER_BANK_get_withdrawal ( struct GNUNET_CURL_Context *ctx, 143 const char *base_url, 144 const char *wopid, 145 TALER_BANK_WithdrawalCallback withdrawals_cb, 146 void *withdrawals_cb_cls, 147 const char *timeout_ms); 148 149 150 /** 151 * Cancel withdrawal request. Frees if neccessary 152 * @param withdrawal handle 153 */ 154 void TALER_BANK_get_withdrawal_cancel ( struct TALER_BANK_GetWithdrawalHandle *withdrawal); 155 156 #endif