bank_api_post_accounts_withdrawals.h (4622B)
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_post_accounts_withdrawals.h 21 * @brief implements the Taler Bank API "POST accounts/$USERNAME/withdrawals" handler 22 * @author Reto Tellenbach 23 */ 24 #ifndef BANK_API_POST_ACCOUNTS_WITHDRAWALS_H 25 #define BANK_API_POST_ACCOUNTS_WITHDRAWALS_H 26 27 #include <taler/taler_curl_lib.h> 28 #include "bank_api_curl_defaults.h" 29 #include "api_common.h" 30 #include "taler/taler_bank_service.h" 31 32 33 /** 34 * @brief withdrawal operation information 35 * provided for request 36 */ 37 struct TALER_BANK_AccountCreateWithdrawalRequest 38 { 39 /** 40 * Amount to withdraw. 41 * Optionaly and left out for Digitizer withdrawal operation creation 42 */ 43 struct TALER_Amount amount; 44 45 /** 46 * Suggested amount to withdraw 47 * Optionaly and left out for Digitizer withdrawal operations 48 */ 49 struct TALER_Amount suggested_amount; 50 51 /** 52 * If true, tell the wallet not to allow the user to 53 * specify an amount to withdraw and to not provide 54 * any amount when registering with the withdrawal operation. 55 * Set true for Digitizer withdrawals 56 */ 57 bool no_amount_to_wallet; 58 }; 59 60 /** 61 * Withdrawal operation information from creation 62 */ 63 struct TALER_BANK_CreateWithdrawalInformatio 64 { 65 /** 66 * ID identifying the operation being created 67 */ 68 const char *withdrawal_id; 69 70 /** 71 * URI that can be passed to the wallet to initiate the withdrawal 72 */ 73 const char *taler_withdraw_uri; 74 }; 75 76 /** 77 * Response details for a accounts/$USERNAME/withdrawals request 78 */ 79 struct TALER_BANK_CreateWithdrawalResponse 80 { 81 82 /** 83 * HTTP response 84 */ 85 struct TALER_BANK_HttpResponse hr; 86 87 /** 88 * Details returned depending on the @e http_status. 89 */ 90 union 91 { 92 93 /** 94 * Details if status was request was succesfull 95 */ 96 struct 97 { 98 99 /** 100 * Withdrawal operation data returned by 101 * accounts/$USERNAME/withdrawal 102 */ 103 struct TALER_BANK_CreateWithdrawalInformatio wopd; 104 105 } ok; 106 107 } details; 108 109 }; 110 111 112 /** 113 * Function called with information about the bank. 114 * 115 * @param cls closure 116 * @param vr response data 117 */ 118 typedef void 119 (*TALER_BANK_CreateWithdrawalCallback) ( 120 void *cls, 121 const struct TALER_BANK_CreateWithdrawalResponse *vr); 122 123 124 /** 125 * Handle for the post accounts create withdrawal request. 126 */ 127 struct TALER_BANK_PostCreateWithdrawalHandle; 128 129 130 /** 131 * create handle for post TALER_BANK_post_accounts_withdrawal() 132 * @param ctx curl context 133 * @param url bank url 134 * @param username bank account name 135 * @param authorization authentication for account 136 * @param accounts_cb callback 137 * @param accounts_cb_cls callback context 138 * @return NULL on failure 139 */ 140 struct TALER_BANK_PostCreateWithdrawalHandle * 141 TALER_BANK_post_accounts_withdrawal_create ( struct GNUNET_CURL_Context *ctx, 142 const char *base_url, 143 const char *username, 144 const struct DIGITIZER_BankAuthenticationData *authorization); 145 146 147 /** 148 * Http request POST /accounts/withdrawal 149 * @param handle handle, is created with TALER_BANK_post_accounts_withdrawal_create() 150 * @param req_ctx request body data 151 * @param pacw_cb callback 152 * @param pacw_cb_cls callback context 153 * @return GNUNET_NO on failure 154 */ 155 enum GNUNET_GenericReturnValue 156 TALER_BANK_post_accounts_withdrawal ( struct TALER_BANK_PostCreateWithdrawalHandle *handle, 157 const struct TALER_BANK_AccountCreateWithdrawalRequest *req_ctx, 158 TALER_BANK_CreateWithdrawalCallback pacw_cb, 159 void *pacw_cb_cls); 160 161 162 /** 163 * Cancel accounts create withdrawal request. Frees if neccessary 164 * @param account handle 165 */ 166 void 167 TALER_BANK_post_withdrawal_create_cancel ( struct TALER_BANK_PostCreateWithdrawalHandle *pacwh); 168 169 #endif