/*
  This file is part of TALER
  Copyright (C) 2014-2026 Taler Systems SA

  TALER is free software; you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2.1, or (at your option) any later version.

  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with
  TALER; see the file COPYING.LGPL.  If not, see
  <http://www.gnu.org/licenses/>
*/
/**
 * @file include/taler/taler-merchant/get-private-webhooks-WEBHOOK_ID.h
 * @brief C interface for GET /private/webhooks/$WEBHOOK_ID of the merchant backend
 * @author Priscilla Huang
 * @author Christian Grothoff
 */
#ifndef _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H
#define _TALER_MERCHANT__GET_PRIVATE_WEBHOOKS_WEBHOOK_ID_H

#include <taler/taler-merchant/common.h>


/**
 * Handle for a GET /private/webhooks/$WEBHOOK_ID request.
 */
struct TALER_MERCHANT_WebhookGetHandle;


/**
 * Callback for a GET /private/webhooks/$WEBHOOK_ID request.
 *
 * @param cls closure
 * @param hr HTTP response details
 * @param event_type event type that triggers this webhook, or NULL on error
 * @param url URL to send the webhook notification to, or NULL on error
 * @param http_method HTTP method to use, or NULL on error
 * @param header_template template for HTTP headers, or NULL on error
 * @param body_template template for the HTTP body, or NULL on error
 */
typedef void
(*TALER_MERCHANT_WebhookGetCallback)(
  void *cls,
  const struct TALER_MERCHANT_HttpResponse *hr,
  const char *event_type,
  const char *url,
  const char *http_method,
  const char *header_template,
  const char *body_template);


/**
 * Issue a GET /private/webhooks/$WEBHOOK_ID request.
 *
 * @param ctx CURL context to use
 * @param backend_url base URL of the merchant backend
 * @param webhook_id identifier of the webhook to retrieve
 * @param cb callback to invoke with the result
 * @param cb_cls closure for @a cb
 * @return handle for the request, NULL on hard error
 */
struct TALER_MERCHANT_WebhookGetHandle *
TALER_MERCHANT_webhook_get (struct GNUNET_CURL_Context *ctx,
                            const char *backend_url,
                            const char *webhook_id,
                            TALER_MERCHANT_WebhookGetCallback cb,
                            void *cb_cls);


/**
 * Cancel a GET /private/webhooks/$WEBHOOK_ID request.
 *
 * @param[in] wgh handle to cancel
 */
void
TALER_MERCHANT_webhook_get_cancel (
  struct TALER_MERCHANT_WebhookGetHandle *wgh);


#endif
