/*
   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 iterate_kyc_references.h
 * @brief implementation of the iterate_kyc_reference function
 * @author Christian Grothoff
 */
#ifndef EXCHANGE_DATABASE_ITERATE_KYC_REFERENCES_H
#define EXCHANGE_DATABASE_ITERATE_KYC_REFERENCES_H

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


/**
 * Function called on all legitimization operations
 * we have performed for the given account so far
 * (and that have not yet expired).
 *
 * @param cls closure
 * @param kyc_provider_name name of the provider
 *        of the respective KYC process
 * @param provider_user_id UID at a provider (can be NULL)
 * @param legi_id legitimization process ID (can be NULL)
 */
#ifndef TALER_EXCHANGEDB_LEGITIMIZATION_PROCESS_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_EXCHANGEDB_LegitimizationProcessCallback.
 */
#define TALER_EXCHANGEDB_LEGITIMIZATION_PROCESS_RESULT_CLOSURE void
#endif
typedef void
(*TALER_EXCHANGEDB_LegitimizationProcessCallback)(
  TALER_EXCHANGEDB_LEGITIMIZATION_PROCESS_RESULT_CLOSURE *cls,
  const char *kyc_provider_name,
  const char *provider_user_id,
  const char *legi_id);


/* Callback typedefs */
/**
 * Function called on all legitimization operations
 * we have performed for the given account so far
 * (and that have not yet expired).
 *
 * @param cls closure
 * @param kyc_provider_name name of the provider
 *        of the respective KYC process
 * @param provider_user_id UID at a provider (can be NULL)
 * @param legi_id legitimization process ID (can be NULL)
 */
typedef void
(*TALER_EXCHANGEDB_LegitimizationProcessCallback)(
  TALER_EXCHANGEDB_LEGITIMIZATION_PROCESS_RESULT_CLOSURE *cls,
  const char *kyc_provider_name,
  const char *provider_user_id,
  const char *legi_id);

/**
 * Call us on KYC legitimization processes satisfied and not expired for the
 * given account.
 *
 * @param pg the database context
 * @param h_payto account identifier
 * @param lpc function to call for each satisfied KYC legitimization process
 * @param lpc_cls closure for @a lpc
 * @return transaction status code
 */
enum GNUNET_DB_QueryStatus
TALER_EXCHANGEDB_iterate_kyc_references (struct
                                         TALER_EXCHANGEDB_PostgresContext *pg,
                                         const struct
                                         TALER_NormalizedPaytoHashP *
                                         h_payto,
                                         TALER_EXCHANGEDB_LegitimizationProcessCallback
                                         lpc,
                                         TALER_EXCHANGEDB_LEGITIMIZATION_PROCESS_RESULT_CLOSURE
                                         *lpc_cls);

#endif
