get-private-webhooks-WEBHOOK_ID.h (4093B)
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-webhooks-WEBHOOK_ID.h 19 * @brief C interface for GET /private/webhooks/$WEBHOOK_ID of the merchant backend 20 * @author Priscilla Huang 21 * @author Christian Grothoff 22 */ 23 #ifndef _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H 24 #define _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H 25 26 #include <taler/merchant/common.h> 27 28 29 /** 30 * Handle for a GET /private/webhooks/$WEBHOOK_ID request. 31 */ 32 struct TALER_MERCHANT_GetPrivateWebhookHandle; 33 34 35 /** 36 * Response details for a GET /private/webhooks/$WEBHOOK_ID request. 37 */ 38 struct TALER_MERCHANT_GetPrivateWebhookResponse 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 * Event type that triggers this webhook. 60 */ 61 const char *event_type; 62 63 /** 64 * URL to send the webhook notification to. 65 */ 66 const char *url; 67 68 /** 69 * HTTP method to use. 70 */ 71 const char *http_method; 72 73 /** 74 * Template for HTTP headers, or NULL. 75 */ 76 const char *header_template; 77 78 /** 79 * Template for the HTTP body, or NULL. 80 */ 81 const char *body_template; 82 83 } ok; 84 85 } details; 86 87 }; 88 89 90 /** 91 * Set up GET /private/webhooks/$WEBHOOK_ID operation. 92 * Note that you must explicitly start the operation after 93 * possibly setting options. 94 * 95 * @param ctx the context 96 * @param url base URL of the merchant backend 97 * @param webhook_id identifier of the webhook to retrieve 98 * @return handle to operation 99 */ 100 struct TALER_MERCHANT_GetPrivateWebhookHandle * 101 TALER_MERCHANT_get_private_webhook_create ( 102 struct GNUNET_CURL_Context *ctx, 103 const char *url, 104 const char *webhook_id); 105 106 107 #ifndef TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE 108 /** 109 * Type of the closure used by 110 * the #TALER_MERCHANT_GetPrivateWebhookCallback. 111 */ 112 #define TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE void 113 #endif /* TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE */ 114 115 /** 116 * Callback for a GET /private/webhooks/$WEBHOOK_ID request. 117 * 118 * @param cls closure 119 * @param wgr response details 120 */ 121 typedef void 122 (*TALER_MERCHANT_GetPrivateWebhookCallback)( 123 TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE *cls, 124 const struct TALER_MERCHANT_GetPrivateWebhookResponse *wgr); 125 126 127 /** 128 * Start GET /private/webhooks/$WEBHOOK_ID operation. 129 * 130 * @param[in,out] gpw operation to start 131 * @param cb function to call with the merchant's result 132 * @param cb_cls closure for @a cb 133 * @return status code, #TALER_EC_NONE on success 134 */ 135 enum TALER_ErrorCode 136 TALER_MERCHANT_get_private_webhook_start ( 137 struct TALER_MERCHANT_GetPrivateWebhookHandle *gpw, 138 TALER_MERCHANT_GetPrivateWebhookCallback cb, 139 TALER_MERCHANT_GET_PRIVATE_WEBHOOK_RESULT_CLOSURE *cb_cls); 140 141 142 /** 143 * Cancel GET /private/webhooks/$WEBHOOK_ID operation. This function 144 * must not be called by clients after the 145 * TALER_MERCHANT_GetPrivateWebhookCallback has been invoked 146 * (as in those cases it'll be called internally by the 147 * implementation already). 148 * 149 * @param[in] gpw operation to cancel 150 */ 151 void 152 TALER_MERCHANT_get_private_webhook_cancel ( 153 struct TALER_MERCHANT_GetPrivateWebhookHandle *gpw); 154 155 156 #endif /* _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H */