get-private-units-UNIT.h (3530B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2014-2026 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU Lesser General Public License as published by the Free Software 7 Foundation; either version 2.1, or (at your option) any later version. 8 9 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 Lesser General Public License for more details. 12 13 You should have received a copy of the GNU Lesser General Public License along with 14 TALER; see the file COPYING.LGPL. If not, see 15 <http://www.gnu.org/licenses/> 16 */ 17 /** 18 * @file src/include/taler/merchant/get-private-units-UNIT.h 19 * @brief C interface for GET /private/units/$UNIT of the merchant backend 20 * @author Christian Grothoff 21 */ 22 #ifndef _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_H 23 #define _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_H 24 25 #include <taler/merchant/common.h> 26 27 28 /** 29 * Handle for a GET /private/units/$UNIT request. 30 */ 31 struct TALER_MERCHANT_GetPrivateUnitHandle; 32 33 34 /** 35 * Response details for a GET /private/units/$UNIT request. 36 */ 37 struct TALER_MERCHANT_GetPrivateUnitResponse 38 { 39 40 /** 41 * HTTP response details. 42 */ 43 struct TALER_MERCHANT_HttpResponse hr; 44 45 /** 46 * Details depending on the HTTP status code. 47 */ 48 union 49 { 50 51 /** 52 * Details on #MHD_HTTP_OK. 53 */ 54 struct 55 { 56 57 /** 58 * Detailed unit information. 59 */ 60 struct TALER_MERCHANT_UnitEntry unit; 61 62 } ok; 63 64 } details; 65 66 }; 67 68 69 /** 70 * Set up GET /private/units/$UNIT operation. 71 * Note that you must explicitly start the operation after 72 * possibly setting options. 73 * 74 * @param ctx the context 75 * @param url base URL of the merchant backend 76 * @param unit_id identifier of the unit to retrieve 77 * @return handle to operation 78 */ 79 struct TALER_MERCHANT_GetPrivateUnitHandle * 80 TALER_MERCHANT_get_private_unit_create ( 81 struct GNUNET_CURL_Context *ctx, 82 const char *url, 83 const char *unit_id); 84 85 86 #ifndef TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE 87 /** 88 * Type of the closure used by 89 * the #TALER_MERCHANT_GetPrivateUnitCallback. 90 */ 91 #define TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE void 92 #endif /* TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE */ 93 94 /** 95 * Callback for a GET /private/units/$UNIT request. 96 * 97 * @param cls closure 98 * @param ugr response details 99 */ 100 typedef void 101 (*TALER_MERCHANT_GetPrivateUnitCallback)( 102 TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE *cls, 103 const struct TALER_MERCHANT_GetPrivateUnitResponse *ugr); 104 105 106 /** 107 * Start GET /private/units/$UNIT operation. 108 * 109 * @param[in,out] gpu operation to start 110 * @param cb function to call with the merchant's result 111 * @param cb_cls closure for @a cb 112 * @return status code, #TALER_EC_NONE on success 113 */ 114 enum TALER_ErrorCode 115 TALER_MERCHANT_get_private_unit_start ( 116 struct TALER_MERCHANT_GetPrivateUnitHandle *gpu, 117 TALER_MERCHANT_GetPrivateUnitCallback cb, 118 TALER_MERCHANT_GET_PRIVATE_UNIT_RESULT_CLOSURE *cb_cls); 119 120 121 /** 122 * Cancel GET /private/units/$UNIT operation. This function 123 * must not be called by clients after the 124 * TALER_MERCHANT_GetPrivateUnitCallback has been invoked 125 * (as in those cases it'll be called internally by the 126 * implementation already). 127 * 128 * @param[in] gpu operation to cancel 129 */ 130 void 131 TALER_MERCHANT_get_private_unit_cancel ( 132 struct TALER_MERCHANT_GetPrivateUnitHandle *gpu); 133 134 135 #endif /* _TALER_MERCHANT__GET_PRIVATE_UNITS_UNIT_H */