get-templates-TEMPLATE_ID.h (3944B)
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-templates-TEMPLATE_ID.h 19 * @brief C interface for GET /templates/$TEMPLATE_ID (wallet-facing) of the merchant backend 20 * @author Christian Grothoff 21 */ 22 #ifndef _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_H 23 #define _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_H 24 25 #include <taler/merchant/common.h> 26 27 28 /** 29 * Handle for a GET /templates/$TEMPLATE_ID request (wallet-facing). 30 */ 31 struct TALER_MERCHANT_GetTemplatesHandle; 32 33 34 /** 35 * Response details for a GET /templates/$TEMPLATE_ID request (wallet-facing). 36 */ 37 struct TALER_MERCHANT_GetTemplatesResponse 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 * Template contract (JSON). 59 */ 60 const json_t *template_contract; 61 62 /** 63 * Editable defaults (JSON object), or NULL if not provided. 64 */ 65 const json_t *editable_defaults; 66 67 /** 68 * Required currency, or NULL if not provided. 69 * FIXME: currently not provided by the backend. Fix backend! 70 */ 71 const char *required_currency; 72 73 } ok; 74 75 } details; 76 77 }; 78 79 80 /** 81 * Set up GET /templates/$TEMPLATE_ID operation (wallet-facing). 82 * Note that you must explicitly start the operation after 83 * possibly setting options. 84 * 85 * @param ctx the context 86 * @param url base URL of the merchant backend 87 * @param template_id identifier of the template to retrieve 88 * @return handle to operation 89 */ 90 struct TALER_MERCHANT_GetTemplatesHandle * 91 TALER_MERCHANT_get_templates_create ( 92 struct GNUNET_CURL_Context *ctx, 93 const char *url, 94 const char *template_id); 95 96 97 #ifndef TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE 98 /** 99 * Type of the closure used by 100 * the #TALER_MERCHANT_GetTemplatesCallback. 101 */ 102 #define TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE void 103 #endif /* TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE */ 104 105 /** 106 * Callback for a GET /templates/$TEMPLATE_ID request (wallet-facing). 107 * 108 * @param cls closure 109 * @param wtgr response details 110 */ 111 typedef void 112 (*TALER_MERCHANT_GetTemplatesCallback)( 113 TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE *cls, 114 const struct TALER_MERCHANT_GetTemplatesResponse *wtgr); 115 116 117 /** 118 * Start GET /templates/$TEMPLATE_ID operation (wallet-facing). 119 * 120 * @param[in,out] gth operation to start 121 * @param cb function to call with the merchant's result 122 * @param cb_cls closure for @a cb 123 * @return status code, #TALER_EC_NONE on success 124 */ 125 enum TALER_ErrorCode 126 TALER_MERCHANT_get_templates_start ( 127 struct TALER_MERCHANT_GetTemplatesHandle *gth, 128 TALER_MERCHANT_GetTemplatesCallback cb, 129 TALER_MERCHANT_GET_TEMPLATES_RESULT_CLOSURE *cb_cls); 130 131 132 /** 133 * Cancel GET /templates/$TEMPLATE_ID operation (wallet-facing). 134 * This function must not be called by clients after the 135 * TALER_MERCHANT_GetTemplatesCallback has been invoked 136 * (as in those cases it'll be called internally by the 137 * implementation already). 138 * 139 * @param[in] gth operation to cancel 140 */ 141 void 142 TALER_MERCHANT_get_templates_cancel ( 143 struct TALER_MERCHANT_GetTemplatesHandle *gth); 144 145 146 #endif /* _TALER_MERCHANT__GET_TEMPLATES_TEMPLATE_ID_H */