/*
  This file is part of TALER
  Copyright (C) 2014-2026 Taler Systems SA

  TALER is free software; you can redistribute it and/or modify it under the
  terms of the GNU Lesser General Public License as published by the Free Software
  Foundation; either version 2.1, 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 Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public License along with
  TALER; see the file COPYING.LGPL.  If not, see
  <http://www.gnu.org/licenses/>
*/
/**
 * @file include/taler/taler-merchant/get-private-accounts-H_WIRE.h
 * @brief C interface for GET /private/accounts/$H_WIRE of the merchant backend
 * @author Christian Grothoff
 */
#ifndef _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_H
#define _TALER_MERCHANT__GET_PRIVATE_ACCOUNTS_H_WIRE_H

#include <taler/taler-merchant/common.h>


/**
 * Handle for a GET /private/accounts/$H_WIRE request.
 */
struct TALER_MERCHANT_AccountGetHandle;


/**
 * Account details for a merchant wire account.
 */
struct TALER_MERCHANT_AccountDetails
{

  /**
   * Hash of the wire details.
   */
  struct TALER_MerchantWireHashP h_wire;

  /**
   * Salt used in the wire hash computation.
   */
  struct TALER_WireSaltP salt;

  /**
   * Full payto URI of the account.
   */
  struct TALER_FullPayto payto_uri;

  /**
   * URL of the credit facade, or NULL if none.
   */
  const char *credit_facade_url;

  /**
   * True if the account is currently active.
   */
  bool active;

};


/**
 * Response details for a GET /private/accounts/$H_WIRE request.
 */
struct TALER_MERCHANT_AccountGetResponse
{

  /**
   * HTTP response details.
   */
  struct TALER_MERCHANT_HttpResponse hr;

  /**
   * Details depending on the HTTP status code.
   */
  union
  {

    /**
     * Details on #MHD_HTTP_OK.
     */
    struct
    {

      /**
       * Detailed account information.
       */
      struct TALER_MERCHANT_AccountDetails ad;

    } ok;

  } details;

};


/**
 * Callback for a GET /private/accounts/$H_WIRE request.
 *
 * @param cls closure
 * @param agr response details
 */
typedef void
(*TALER_MERCHANT_AccountGetCallback)(
  void *cls,
  const struct TALER_MERCHANT_AccountGetResponse *agr);


/**
 * Issue a GET /private/accounts/$H_WIRE request.
 *
 * @param ctx CURL context to use
 * @param backend_url base URL of the merchant backend
 * @param instance_id identifier of the merchant instance
 * @param h_wire hash of the wire details identifying the account
 * @param cb callback to invoke with the result
 * @param cb_cls closure for @a cb
 * @return handle for the request, NULL on hard error
 */
struct TALER_MERCHANT_AccountGetHandle *
TALER_MERCHANT_account_get (struct GNUNET_CURL_Context *ctx,
                            const char *backend_url,
                            const char *instance_id,
                            const struct TALER_MerchantWireHashP *h_wire,
                            TALER_MERCHANT_AccountGetCallback cb,
                            void *cb_cls);


/**
 * Cancel a GET /private/accounts/$H_WIRE request.
 *
 * @param[in] tgh handle to cancel
 */
void
TALER_MERCHANT_account_get_cancel (
  struct TALER_MERCHANT_AccountGetHandle *tgh);


#endif
