/*
   This file is part of TALER
   Copyright (C) 2022 Taler Systems SA

   TALER is free software; you can redistribute it and/or modify it under the
   terms of the GNU 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 General Public License for more details.

   You should have received a copy of the GNU General Public License along with
   TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file src/include/exchange-database/iterate_wire_fees.h
 * @brief implementation of the iterate_wire_fees function for Postgres
 * @author Christian Grothoff
 */
#ifndef EXCHANGE_DATABASE_ITERATE_WIRE_FEES_H
#define EXCHANGE_DATABASE_ITERATE_WIRE_FEES_H

#include "taler/taler_util.h"
#include "taler/taler_json_lib.h"
#include "exchangedb_lib.h"


/**
 * Provide information about wire fees.
 *
 * @param cls closure
 * @param fees the wire fees we charge
 * @param start_date from when are these fees valid (start date)
 * @param end_date until when are these fees valid (end date, exclusive)
 * @param master_sig master key signature affirming that this is the correct
 *                   fee (of purpose #TALER_SIGNATURE_MASTER_WIRE_FEES)
 */
#ifndef TALER_EXCHANGEDB_WIRE_FEE_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_EXCHANGEDB_WireFeeCallback.
 */
#define TALER_EXCHANGEDB_WIRE_FEE_RESULT_CLOSURE void
#endif
typedef void
(*TALER_EXCHANGEDB_WireFeeCallback)(
  TALER_EXCHANGEDB_WIRE_FEE_RESULT_CLOSURE *cls,
  const struct TALER_WireFeeSet *fees,
  struct GNUNET_TIME_Timestamp start_date,
  struct GNUNET_TIME_Timestamp end_date,
  const struct TALER_MasterSignatureP *master_sig);


/* Callback typedefs */
/**
 * Provide information about wire fees.
 *
 * @param cls closure
 * @param fees the wire fees we charge
 * @param start_date from when are these fees valid (start date)
 * @param end_date until when are these fees valid (end date, exclusive)
 * @param master_sig master key signature affirming that this is the correct
 *                   fee (of purpose #TALER_SIGNATURE_MASTER_WIRE_FEES)
 */
typedef void
(*TALER_EXCHANGEDB_WireFeeCallback)(
  TALER_EXCHANGEDB_WIRE_FEE_RESULT_CLOSURE *cls,
  const struct TALER_WireFeeSet *fees,
  struct GNUNET_TIME_Timestamp start_date,
  struct GNUNET_TIME_Timestamp end_date,
  const struct TALER_MasterSignatureP *master_sig);

/**
 * Obtain information about the fee structure of the exchange for
 * a given @a wire_method
 *
 * @param pg the database context
 * @param wire_method which wire method to obtain fees for
 * @param cb function to call on each account
 * @param cb_cls closure for @a cb
 * @return transaction status code
 */
enum GNUNET_DB_QueryStatus
TALER_EXCHANGEDB_iterate_wire_fees (struct TALER_EXCHANGEDB_PostgresContext *
                                    pg,
                                    const char *wire_method,
                                    TALER_EXCHANGEDB_WireFeeCallback cb,
                                    TALER_EXCHANGEDB_WIRE_FEE_RESULT_CLOSURE
                                    *cb_cls);

#endif
