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

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

/**
 * Typically called by `iterate_token_families`.
 *
 * @param cls closure
 * @param slug slug of the token family
 * @param name name of the token family
 * @param description description of the token family
 * @param description_i18n Internationalized token family description.
 * @param start_time start time of the token family's validity period
 * @param expiration end time of the token family's validity period
 * @param kind kind of the token family
 */
typedef void
(*TALER_MERCHANTDB_TokenFamiliesCallback)(
  void *cls,
  const char *slug,
  const char *name,
  const char *description,
  const json_t *description_i18n,
  struct GNUNET_TIME_Timestamp start_time,
  struct GNUNET_TIME_Timestamp expiration,
  const char *kind);

/**
 * Lookup all of the token families the given instance has configured.
 *
 * @param pg database context
 * @param instance_id instance to lookup token families for
 * @param cb function to call on all token families found
 * @param cb_cls closure for @a cb
 * @return database result code
 */
enum GNUNET_DB_QueryStatus
TALER_MERCHANTDB_iterate_token_families (
  struct TALER_MERCHANTDB_PostgresContext *pg,
  const char *instance_id,
  TALER_MERCHANTDB_TokenFamiliesCallback cb,
  void *cb_cls);

#endif
