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

#include <taler/taler_util.h>
#include <taler/taler_json_lib.h>
#include "merchantdb_lib.h"


struct TALER_MERCHANTDB_PostgresContext;
/* Callback typedefs */
/**
 * Function called with information about wire transfers
 * that taler-merchant-exchange still needs to process.
 *
 * @param cls closure
 * @param rowid row of the transfer in the merchant database
 * @param instance_id instance that received the transfer
 * @param exchange_url URL of the exchange that is making the deposit
 * @param payto_uri account of the merchant that received the transfer
 * @param wtid wire transfer subject identifying the aggregation
 * @param next_attempt when should we next try to interact with the exchange
 */
typedef void
(*TALER_MERCHANTDB_OpenTransferCallback)(
  void *cls,
  uint64_t rowid,
  const char *instance_id,
  const char *exchange_url,
  struct TALER_FullPayto payto_uri,
  const struct TALER_WireTransferIdentifierRawP *wtid,
  struct GNUNET_TIME_Absolute next_attempt);

/**
 * Retrieve wire transfer details of wire details
 * that taler-merchant-exchange still needs to
 * investigate.
 *
 * @param pg database context
 * @param limit maximum number of results to return
 * @param cb function called with the wire transfer data
 * @param cb_cls closure for @a cb
 * @return transaction status
 */
enum GNUNET_DB_QueryStatus
TALER_MERCHANTDB_iterate_open_expected_transfers (struct TALER_MERCHANTDB_PostgresContext *pg,
                                                  uint64_t limit,
                                                  TALER_MERCHANTDB_OpenTransferCallback cb,
                                                  void *cb_cls);


#endif
