/*
   This file is part of Challenger
   Copyright (C) 2024 Taler Systems SA

   Challenger 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.

   Challenger 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
   Challenger; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file src/include/challenger-database/update_client.h
 * @brief implementation of the update_client function for Postgres
 * @author Christian Grothoff
 */
#ifndef CHALLENGER_DATABASE_UPDATE_CLIENT_H
#define CHALLENGER_DATABASE_UPDATE_CLIENT_H

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

struct CHALLENGERDB_PostgresContext;
/**
 * Modify client to the list of authorized clients.
 *
 * @param cls
 * @param client_id the client ID on success
 * @param client_url URL of the client
 * @param client_secret authorization secret for the client, NULL to not modify the secret
 * @param[out] uri_conflict set to true if @a client_url is already used by
 *        another client; only meaningful if the return value is
 *        #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS, where it tells the two causes
 *        apart: true means the URI is taken, false that there is no client
 *        with row @a client_id
 * @return transaction status:
 *   #GNUNET_DB_STATUS_SUCCESS_ONE_RESULT if the client was modified
 *   #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the client does not exist or
 *     @a client_url is already used by another client (see @a uri_conflict)
 *   #GNUNET_DB_STATUS_HARD_ERROR on failure
 */
enum GNUNET_DB_QueryStatus
CHALLENGERDB_update_client (struct CHALLENGERDB_PostgresContext *ctx,
                            uint64_t client_id,
                            const char *client_url,
                            const char *client_secret,
                            bool *uri_conflict);


#endif
