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

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


struct TALER_MERCHANTDB_PostgresContext;

/**
 * Look up the ``Taler-Terms-Version`` of the terms of
 * service that the user has accepted early for a given
 * exchange (via the ``POST /private/accept-tos-early``
 * endpoint).
 *
 * @param pg database context
 * @param merchant_id merchant backend instance ID
 * @param exchange_url base URL of the exchange to look up
 * @param[out] tos_version set to a newly allocated string with the
 *        accepted ``Taler-Terms-Version``; caller must @a GNUNET_free
 *        it.  Set to NULL if no acceptance is on record for this
 *        @a exchange_url, in which case the query status will be
 *        ``GNUNET_DB_STATUS_SUCCESS_NO_RESULTS``.
 * @return database result code
 */
enum GNUNET_DB_QueryStatus
TALER_MERCHANTDB_get_tos_accepted_early (
  struct TALER_MERCHANTDB_PostgresContext *pg,
  const char *merchant_id,
  const char *exchange_url,
  char **tos_version);

#endif
