/*
   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/auditor-database/iterate_purse_expired.h
 * @brief implementation of the iterate_purse_expired function for Postgres
 * @author Christian Grothoff
 */
#ifndef AUDITOR_DATABASE_ITERATE_PURSE_EXPIRED_H
#define AUDITOR_DATABASE_ITERATE_PURSE_EXPIRED_H

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


/**
 * Function called on expired purses.
 *
 * @param cls closure
 * @param purse_pub public key of the purse
 * @param balance amount of money in the purse
 * @param expiration_date when did the purse expire?
 * @return #GNUNET_OK to continue to iterate
 */
#ifndef TALER_AUDITORDB_EXPIRED_PURSE_RESULT_CLOSURE
/**
 * Type of the closure for #TALER_AUDITORDB_ExpiredPurseCallback.
 */
#define TALER_AUDITORDB_EXPIRED_PURSE_RESULT_CLOSURE void
#endif
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ExpiredPurseCallback)(
  TALER_AUDITORDB_EXPIRED_PURSE_RESULT_CLOSURE *cls,
  const struct TALER_PurseContractPublicKeyP *purse_pub,
  const struct TALER_Amount *balance,
  struct GNUNET_TIME_Timestamp expiration_date);


/* Callback typedefs */
/**
 * Function called on expired purses.
 *
 * @param cls closure
 * @param purse_pub public key of the purse
 * @param balance amount of money in the purse
 * @param expiration_date when did the purse expire?
 * @return #GNUNET_OK to continue to iterate
 */
typedef enum GNUNET_GenericReturnValue
(*TALER_AUDITORDB_ExpiredPurseCallback)(
  TALER_AUDITORDB_EXPIRED_PURSE_RESULT_CLOSURE *cls,
  const struct TALER_PurseContractPublicKeyP *purse_pub,
  const struct TALER_Amount *balance,
  struct GNUNET_TIME_Timestamp expiration_date);

/**
 * Get information about expired purses.
 *
 * @param pg the database context
 * @param cb function to call on expired purses
 * @param cb_cls closure for @a cb
 * @return transaction status code
 */
enum GNUNET_DB_QueryStatus
TALER_AUDITORDB_iterate_purse_expired (struct TALER_AUDITORDB_PostgresContext *
                                       pg
                                       ,
                                       TALER_AUDITORDB_ExpiredPurseCallback cb,
                                       TALER_AUDITORDB_EXPIRED_PURSE_RESULT_CLOSURE
                                       *cb_cls);

#endif
