/*
  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 Affero General Public License as published by the Free Software
  Foundation; either version 3, 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 Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License along with
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file include/taler/exchange/post-auditors-AUDITOR_PUB-H_DENOM_PUB.h
 * @brief C interface for POST /auditors/$AUDITOR_PUB/$H_DENOM_PUB
 * @author Christian Grothoff
 */
#ifndef _TALER_EXCHANGE__POST_AUDITORS_AUDITOR_PUB_H_DENOM_PUB_H
#define _TALER_EXCHANGE__POST_AUDITORS_AUDITOR_PUB_H_DENOM_PUB_H

#include <taler/exchange/common.h>

/**
 * Handle for an operation to POST /auditors/$AUDITOR_PUB/$H_DENOM_PUB.
 */
struct TALER_EXCHANGE_PostAuditorsHandle;


/**
 * Set up POST /auditors/$AUDITOR_PUB/$H_DENOM_PUB operation.
 * Note that you must explicitly start the operation after setup.
 *
 * @param ctx the context
 * @param url HTTP base URL for the exchange
 * @param h_denom_pub hash of the public key of the denomination
 * @param auditor_pub public key of the auditor
 * @param auditor_sig signature of the auditor, of
 *        purpose #TALER_SIGNATURE_AUDITOR_EXCHANGE_KEYS
 * @return handle to operation, NULL on error
 */
struct TALER_EXCHANGE_PostAuditorsHandle *
TALER_EXCHANGE_post_auditors_create (
  struct GNUNET_CURL_Context *ctx,
  const char *url,
  const struct TALER_DenominationHashP *h_denom_pub,
  const struct TALER_AuditorPublicKeyP *auditor_pub,
  const struct TALER_AuditorSignatureP *auditor_sig);


/**
 * Response when adding denomination signature by auditor.
 */
struct TALER_EXCHANGE_PostAuditorsResponse
{
  /**
   * HTTP response data.
   */
  struct TALER_EXCHANGE_HttpResponse hr;
};


#ifndef TALER_EXCHANGE_POST_AUDITORS_RESULT_CLOSURE
/**
 * Type of the closure used by
 * the #TALER_EXCHANGE_PostAuditorsCallback.
 */
#define TALER_EXCHANGE_POST_AUDITORS_RESULT_CLOSURE void
#endif /* TALER_EXCHANGE_POST_AUDITORS_RESULT_CLOSURE */

/**
 * Type of the function that receives the result of a
 * POST /auditors/$AUDITOR_PUB/$H_DENOM_PUB request.
 *
 * @param cls closure
 * @param result result returned by the HTTP server
 */
typedef void
(*TALER_EXCHANGE_PostAuditorsCallback)(
  TALER_EXCHANGE_POST_AUDITORS_RESULT_CLOSURE *cls,
  const struct TALER_EXCHANGE_PostAuditorsResponse *result);


/**
 * Start POST /auditors/$AUDITOR_PUB/$H_DENOM_PUB operation.
 *
 * @param[in,out] pah operation to start
 * @param cb function to call with the exchange's result
 * @param cb_cls closure for @a cb
 * @return status code, #TALER_EC_NONE on success
 */
enum TALER_ErrorCode
TALER_EXCHANGE_post_auditors_start (
  struct TALER_EXCHANGE_PostAuditorsHandle *pah,
  TALER_EXCHANGE_PostAuditorsCallback cb,
  TALER_EXCHANGE_POST_AUDITORS_RESULT_CLOSURE *cb_cls);


/**
 * Cancel POST /auditors/$AUDITOR_PUB/$H_DENOM_PUB operation.  This function
 * must not be called by clients after the
 * TALER_EXCHANGE_PostAuditorsCallback has been invoked (as in those cases
 * it'll be called internally by the implementation already).
 *
 * @param[in] pah operation to cancel
 */
void
TALER_EXCHANGE_post_auditors_cancel (
  struct TALER_EXCHANGE_PostAuditorsHandle *pah);


#endif /* _TALER_EXCHANGE__POST_AUDITORS_AUDITOR_PUB_H_DENOM_PUB_H */
