get-private-tokenfamilies-TOKEN_FAMILY_SLUG.h (5209B)
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-tokenfamilies-TOKEN_FAMILY_SLUG.h 19 * @brief C interface for GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG 20 * of the merchant backend 21 * @author Christian Grothoff 22 */ 23 #ifndef _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_H 24 #define _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_H 25 26 #include <taler/merchant/common.h> 27 28 29 /** 30 * Handle for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request. 31 */ 32 struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle; 33 34 35 /** 36 * Response details for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request. 37 */ 38 struct TALER_MERCHANT_GetPrivateTokenfamiliesResponse 39 { 40 41 /** 42 * HTTP response details. 43 */ 44 struct TALER_MERCHANT_HttpResponse hr; 45 46 /** 47 * Details depending on the HTTP status code. 48 */ 49 union 50 { 51 52 /** 53 * Details on #MHD_HTTP_OK. 54 */ 55 struct 56 { 57 58 /** 59 * URL-safe slug identifier of the token family. 60 */ 61 const char *slug; 62 63 /** 64 * Human-readable name. 65 */ 66 const char *name; 67 68 /** 69 * Human-readable description. 70 */ 71 const char *description; 72 73 /** 74 * Internationalized descriptions (JSON), or NULL. 75 */ 76 const json_t *description_i18n; 77 78 /** 79 * Extra data associated with this token family (JSON), or NULL. 80 */ 81 const json_t *extra_data; 82 83 /** 84 * Start of validity period. 85 */ 86 struct GNUNET_TIME_Timestamp valid_after; 87 88 /** 89 * End of validity period. 90 */ 91 struct GNUNET_TIME_Timestamp valid_before; 92 93 /** 94 * Duration of individual token validity. 95 */ 96 struct GNUNET_TIME_Relative duration; 97 98 /** 99 * Granularity for validity period alignment. 100 */ 101 struct GNUNET_TIME_Relative validity_granularity; 102 103 /** 104 * Offset from purchase time to start of validity. 105 */ 106 struct GNUNET_TIME_Relative start_offset; 107 108 /** 109 * Kind of token family ("subscription" or "discount"). 110 */ 111 const char *kind; 112 113 /** 114 * Total number of tokens issued. 115 */ 116 uint64_t issued; 117 118 /** 119 * Total number of tokens used. 120 */ 121 uint64_t used; 122 123 } ok; 124 125 } details; 126 127 }; 128 129 130 /** 131 * Set up GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG operation. 132 * Note that you must explicitly start the operation after 133 * possibly setting options. 134 * 135 * @param ctx the context 136 * @param url base URL of the merchant backend 137 * @param token_family_slug slug of the token family to retrieve 138 * @return handle to operation 139 */ 140 struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle * 141 TALER_MERCHANT_get_private_tokenfamilies_create ( 142 struct GNUNET_CURL_Context *ctx, 143 const char *url, 144 const char *token_family_slug); 145 146 147 #ifndef TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE 148 /** 149 * Type of the closure used by 150 * the #TALER_MERCHANT_GetPrivateTokenfamiliesCallback. 151 */ 152 #define TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE void 153 #endif /* TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE */ 154 155 /** 156 * Callback for a GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG request. 157 * 158 * @param cls closure 159 * @param tfgr response details 160 */ 161 typedef void 162 (*TALER_MERCHANT_GetPrivateTokenfamiliesCallback)( 163 TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE *cls, 164 const struct TALER_MERCHANT_GetPrivateTokenfamiliesResponse *tfgr); 165 166 167 /** 168 * Start GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG operation. 169 * 170 * @param[in,out] gptf operation to start 171 * @param cb function to call with the merchant's result 172 * @param cb_cls closure for @a cb 173 * @return status code, #TALER_EC_NONE on success 174 */ 175 enum TALER_ErrorCode 176 TALER_MERCHANT_get_private_tokenfamilies_start ( 177 struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle *gptf, 178 TALER_MERCHANT_GetPrivateTokenfamiliesCallback cb, 179 TALER_MERCHANT_GET_PRIVATE_TOKENFAMILIES_RESULT_CLOSURE *cb_cls); 180 181 182 /** 183 * Cancel GET /private/tokenfamilies/$TOKEN_FAMILY_SLUG operation. 184 * This function must not be called by clients after the 185 * TALER_MERCHANT_GetPrivateTokenfamiliesCallback has been invoked 186 * (as in those cases it'll be called internally by the 187 * implementation already). 188 * 189 * @param[in] gptf operation to cancel 190 */ 191 void 192 TALER_MERCHANT_get_private_tokenfamilies_cancel ( 193 struct TALER_MERCHANT_GetPrivateTokenfamiliesHandle *gptf); 194 195 196 #endif /* _TALER_MERCHANT__GET_PRIVATE_TOKENFAMILIES_TOKEN_FAMILY_SLUG_H */