/*
  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/get-reserves-attest-RESERVE_PUB.h
 * @brief C interface for GET /reserves/$RESERVE_PUB/attest
 * @author Christian Grothoff
 */
#ifndef _TALER_EXCHANGE__GET_RESERVES_ATTEST_RESERVE_PUB_H
#define _TALER_EXCHANGE__GET_RESERVES_ATTEST_RESERVE_PUB_H

#include <taler/exchange/common.h>

/**
 * Handle for an operation to GET /reserves/$RESERVE_PUB/attest.
 */
struct TALER_EXCHANGE_GetReservesAttestHandle;


/**
 * Response from a GET /reserves/$RESERVE_PUB/attest request.
 */
struct TALER_EXCHANGE_GetReservesAttestResponse
{
  /**
   * HTTP response data.
   */
  struct TALER_EXCHANGE_HttpResponse hr;

  /**
   * Details depending on @e hr.http_status.
   */
  union
  {
    /**
     * Information returned on #MHD_HTTP_OK.
     */
    struct
    {
      /**
       * Length of the @e attributes array.
       */
      size_t attributes_length;

      /**
       * NULL-terminated array of attribute names available about the user.
       */
      const char **attributes;

    } ok;

  } details;

};


#ifndef TALER_EXCHANGE_GET_RESERVES_ATTEST_RESULT_CLOSURE
/**
 * Type of the closure used by
 * the #TALER_EXCHANGE_GetReservesAttestCallback.
 */
#define TALER_EXCHANGE_GET_RESERVES_ATTEST_RESULT_CLOSURE void
#endif /* TALER_EXCHANGE_GET_RESERVES_ATTEST_RESULT_CLOSURE */

/**
 * Type of the function that receives the result of a
 * GET /reserves/$RESERVE_PUB/attest request.
 *
 * @param cls closure
 * @param result result returned by the HTTP server
 */
typedef void
(*TALER_EXCHANGE_GetReservesAttestCallback)(
  TALER_EXCHANGE_GET_RESERVES_ATTEST_RESULT_CLOSURE *cls,
  const struct TALER_EXCHANGE_GetReservesAttestResponse *result);


/**
 * Set up GET /reserves/$RESERVE_PUB/attest operation.
 * Note that you must explicitly start the operation after setup.
 *
 * @param ctx the context
 * @param url base URL of the exchange
 * @param reserve_pub public key of the reserve to get available attributes for
 * @return handle to operation
 */
struct TALER_EXCHANGE_GetReservesAttestHandle *
TALER_EXCHANGE_get_reserves_attest_create (
  struct GNUNET_CURL_Context *ctx,
  const char *url,
  const struct TALER_ReservePublicKeyP *reserve_pub);


/**
 * Start GET /reserves/$RESERVE_PUB/attest operation.
 *
 * @param[in,out] grah 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_get_reserves_attest_start (
  struct TALER_EXCHANGE_GetReservesAttestHandle *grah,
  TALER_EXCHANGE_GetReservesAttestCallback cb,
  TALER_EXCHANGE_GET_RESERVES_ATTEST_RESULT_CLOSURE *cb_cls);


/**
 * Cancel GET /reserves/$RESERVE_PUB/attest operation.  This function must
 * not be called by clients after the TALER_EXCHANGE_GetReservesAttestCallback
 * has been invoked (as in those cases it'll be called internally by the
 * implementation already).
 *
 * @param[in] grah operation to cancel
 */
void
TALER_EXCHANGE_get_reserves_attest_cancel (
  struct TALER_EXCHANGE_GetReservesAttestHandle *grah);


#endif /* _TALER_EXCHANGE__GET_RESERVES_ATTEST_RESERVE_PUB_H */
