/*
  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-donau.h
 * @brief C interface for GET /private/donau of the merchant backend
 * @author Christian Grothoff
 */
#ifndef _TALER_MERCHANT__GET_PRIVATE_DONAU_H
#define _TALER_MERCHANT__GET_PRIVATE_DONAU_H

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


/**
 * Handle for a GET /private/donau request.
 */
struct TALER_MERCHANT_DonauInstanceGetHandle;


/**
 * Individual Donau instance details.
 */
struct TALER_MERCHANT_DonauInstanceEntry
{
  /**
   * Serial number of the Donau instance in merchant database.
   */
  uint64_t donau_instance_serial;

  /**
   * The URL of the Donau service.
   */
  const char *donau_url;

  /**
   * Name of the charity associated with the Donau instance.
   */
  const char *charity_name;

  /**
   * Public key of the charity.
   */
  struct DONAU_CharityPublicKeyP charity_pub_key;

  /**
   * ID of the charity on Donau.
   */
  uint64_t charity_id;

  /**
   * Maximum donation amount per year allowed for the charity.
   */
  struct TALER_Amount charity_max_per_year;

  /**
   * Total donations received by the charity in the current year.
   */
  struct TALER_Amount charity_receipts_to_date;

  /**
   * The current year being tracked for donations.
   */
  int64_t current_year;

  /**
   * Additional key information related to the Donau instance.
   */
  const struct DONAU_Keys *donau_keys;
};


/**
 * Response details for a GET /private/donau request.
 */
struct TALER_MERCHANT_DonauInstanceGetResponse
{

  /**
   * HTTP response details.
   */
  struct TALER_MERCHANT_HttpResponse hr;

  /**
   * Details depending on the HTTP status code.
   */
  union
  {

    /**
     * Details on #MHD_HTTP_OK.
     */
    struct
    {

      /**
       * Number of Donau instances in @a donau_instances.
       */
      unsigned int donau_instances_length;

      /**
       * Array of Donau instance entries.
       */
      const struct TALER_MERCHANT_DonauInstanceEntry *donau_instances;

    } ok;

  } details;

};


/**
 * Callback for a GET /private/donau request.
 *
 * @param cls closure
 * @param igr response details
 */
typedef void
(*TALER_MERCHANT_DonauInstanceGetCallback)(
  void *cls,
  const struct TALER_MERCHANT_DonauInstanceGetResponse *igr);


/**
 * Issue a GET /private/donau request to list registered Donau instances.
 *
 * @param ctx CURL context to use
 * @param backend_url base URL of the merchant backend
 * @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_DonauInstanceGetHandle *
TALER_MERCHANT_donau_instances_get (
  struct GNUNET_CURL_Context *ctx,
  const char *backend_url,
  TALER_MERCHANT_DonauInstanceGetCallback cb,
  void *cb_cls);


/**
 * Cancel a GET /private/donau request.
 *
 * @param[in] dgh handle to cancel
 */
void
TALER_MERCHANT_donau_instances_get_cancel (
  struct TALER_MERCHANT_DonauInstanceGetHandle *dgh);


#endif
