/*
   This file is part of TALER
   Copyright (C) 2025 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_money_pots.h
 * @brief implementation of the iterate_money_pots function for Postgres
 * @author Christian Grothoff
 */
#ifndef MERCHANT_DATABASE_ITERATE_MONEY_POTS_H
#define MERCHANT_DATABASE_ITERATE_MONEY_POTS_H

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


/**
 * Typically called by `iterate_money_pots`.
 *
 * @param cls closure
 * @param name set to name of the pot
 * @param pot_total_len length of @a pot_totals array
 * @param pot_totals amounts currently in the pot
 */
typedef void
(*TALER_MERCHANTDB_MoneyPotsCallback)(
  void *cls,
  uint64_t money_pot_id,
  const char *name,
  size_t pot_total_len,
  const struct TALER_Amount *pot_totals);

/**
 * Lookup all of the money pots the given instance has configured.
 *
 * @param pg database context
 * @param instance_id instance to lookup token families for
 * @param limit number of entries to return, negative for descending in execution time,
 *                positive for ascending in execution time
 * @param offset expected_transfer_serial number of the transfer we want to offset from
 * @param cb function to call on all money pots found
 * @param cb_cls closure for @a cb
 * @return database result code
 */
enum GNUNET_DB_QueryStatus
TALER_MERCHANTDB_iterate_money_pots (
  struct TALER_MERCHANTDB_PostgresContext *pg,
  const char *instance_id,
  int64_t limit,
  uint64_t offset,
  TALER_MERCHANTDB_MoneyPotsCallback cb,
  void *cb_cls);

#endif
