/*
   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_pending_reports.h
 * @brief implementation of the iterate_pending_reports function for Postgres
 * @author Christian Grothoff
 */
#ifndef MERCHANT_DATABASE_ITERATE_PENDING_REPORTS_H
#define MERCHANT_DATABASE_ITERATE_PENDING_REPORTS_H

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


/**
 * Typically called by `iterate_pending_reports`.
 *
 * @param cls closure
 * @param instance_id name of the instance
 * @param report_id serial number of the report
 * @param report_program_section configuration section of program
 *   for report generation
 * @param report_description text describing the report
 * @param mime_type mime type to request
 * @param report_token token to authorize access to the data source
 * @param target_address where to send report data
 * @param frequency report frequency
 * @param frequency_shift how much to shift the report time from a
 *   multiple of the report @a frequency
 * @param next_transmission when is the next transmission of this report
 *   due
 * @param one_shot true if the report should be removed from the
 *   list after generation instead of being repeated
 */
typedef void
(*TALER_MERCHANTDB_ReportsPendingCallback)(
  void *cls,
  const char *instance_id,
  uint64_t report_id,
  const char *report_program_section,
  const char *report_description,
  const char *mime_type,
  const struct TALER_MERCHANT_ReportToken *report_token,
  const char *target_address,
  struct GNUNET_TIME_Relative frequency,
  struct GNUNET_TIME_Relative frequency_shift,
  struct GNUNET_TIME_Absolute next_transmission,
  bool one_shot);

/**
 * Lookup all of the reports pending for the given backend.
 *
 * @param pg database context
 * @param cb function to call on all reports found
 * @param cb_cls closure for @a cb
 * @return database result code
 */
enum GNUNET_DB_QueryStatus
TALER_MERCHANTDB_iterate_pending_reports (
  struct TALER_MERCHANTDB_PostgresContext *pg,
  TALER_MERCHANTDB_ReportsPendingCallback cb,
  void *cb_cls);

#endif
