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

#include "taler/taler_util.h"
#include "taler/taler_json_lib.h"
#include "exchangedb_lib.h"
#include "exchange-database/update_to_aml_locked.h"
#include "exchange-database/update_to_aml_unlocked.h"


/**
 * Persist the given @a apr for the given process and account
 * into the database via @a pg.  Called within an open
 * database transaction.
 *
 * @param pg database API handle
 * @param process_row row identifying the legitimization process that was run,
 *        0 if there was no legi process (for example, due to rule
 *        expiration triggering something) and we should simply
 *        create a new row
 * @param account_id hash of account the result is about
 * @param ret_pprs
 * @param apr AML program result to persist
 */
enum GNUNET_DB_QueryStatus
TALER_EXCHANGEDB_do_persist_aml_program_result (
  struct TALER_EXCHANGEDB_PostgresContext *pg,
  uint64_t process_row,
  const struct TALER_NormalizedPaytoHashP *account_id,
  const struct TALER_KYCLOGIC_AmlProgramResult *apr,
  enum TALER_EXCHANGEDB_PersistProgramResultStatus *ret_pprs);

#endif
