/*
  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 Affero 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 Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License along with
  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
 */
/**
 * @file include/taler/exchange/post-kyc-upload-ID.h
 * @brief C interface for POST /kyc-upload/$ID
 * @author Christian Grothoff
 */
#ifndef _TALER_EXCHANGE__POST_KYC_UPLOAD_ID_H
#define _TALER_EXCHANGE__POST_KYC_UPLOAD_ID_H

#include <taler/exchange/common.h>

/**
 * Handle for an operation to POST /kyc-upload/$ID.
 */
struct TALER_EXCHANGE_PostKycUploadHandle;


/**
 * Set up POST /kyc-upload/$ID operation.
 * Note that you must explicitly start the operation after setup.
 *
 * @param ctx CURL context
 * @param url exchange base URL
 * @param id identifier for the KYC process the upload is for
 * @param attributes the client-provided evidence to upload; a
 *        `CustomerKycAttributes` object that depends on the form
 *        being submitted, but MUST include the form ID
 * @return handle to operation, NULL on error
 */
struct TALER_EXCHANGE_PostKycUploadHandle *
TALER_EXCHANGE_post_kyc_upload_create (
  struct GNUNET_CURL_Context *ctx,
  const char *url,
  const char *id,
  const json_t *attributes);


/**
 * Set up POST /kyc-upload/$ID operation to accept the exchange's
 * terms of service.  This is a convenience wrapper around
 * #TALER_EXCHANGE_post_kyc_upload_create() that submits the
 * @c "accept-tos" KYC form affirming acceptance of the given
 * version of the terms of service.
 * Note that you must explicitly start the operation after setup.
 *
 * @param ctx CURL context
 * @param url exchange base URL
 * @param id identifier for the KYC process the acceptance is for
 * @param tos_etag ETag identifying the version of the terms of
 *        service being accepted; this is the value returned in the
 *        @e tos_required field of a GET /kyc-check/$H_NORMALIZED_PAYTO
 *        (or /kyc-info) response
 * @return handle to operation, NULL on error
 */
struct TALER_EXCHANGE_PostKycUploadHandle *
TALER_EXCHANGE_post_kyc_upload_accept_tos_create (
  struct GNUNET_CURL_Context *ctx,
  const char *url,
  const char *id,
  const char *tos_etag);


/**
 * KYC upload response details.
 */
struct TALER_EXCHANGE_PostKycUploadResponse
{
  /**
   * HTTP response data
   */
  struct TALER_EXCHANGE_HttpResponse hr;

  /**
   * Details depending on @e hr.http_status.
   */
  union
  {
    /**
     * Empty, @e hr.http_status is #MHD_HTTP_NO_CONTENT.
     */
    char empty[0];

  } details;

};


#ifndef TALER_EXCHANGE_POST_KYC_UPLOAD_RESULT_CLOSURE
/**
 * Type of the closure used by
 * the #TALER_EXCHANGE_PostKycUploadCallback.
 */
#define TALER_EXCHANGE_POST_KYC_UPLOAD_RESULT_CLOSURE void
#endif /* TALER_EXCHANGE_POST_KYC_UPLOAD_RESULT_CLOSURE */

/**
 * Type of the function that receives the result of a
 * POST /kyc-upload/$ID request.
 *
 * @param cls closure
 * @param result result returned by the HTTP server
 */
typedef void
(*TALER_EXCHANGE_PostKycUploadCallback)(
  TALER_EXCHANGE_POST_KYC_UPLOAD_RESULT_CLOSURE *cls,
  const struct TALER_EXCHANGE_PostKycUploadResponse *result);


/**
 * Start POST /kyc-upload/$ID operation.
 *
 * @param[in,out] pksh operation to start
 * @param cb function to call with the exchange's result
 * @param cb_cls closure for @a cb
 * @return status code, #TALER_EC_NONE on success
 */
enum TALER_ErrorCode
TALER_EXCHANGE_post_kyc_upload_start (
  struct TALER_EXCHANGE_PostKycUploadHandle *pksh,
  TALER_EXCHANGE_PostKycUploadCallback cb,
  TALER_EXCHANGE_POST_KYC_UPLOAD_RESULT_CLOSURE *cb_cls);


/**
 * Cancel POST /kyc-upload/$ID operation.  This function must not be called by
 * clients after the TALER_EXCHANGE_PostKycUploadCallback has been invoked (as
 * in those cases it'll be called internally by the implementation already).
 *
 * @param[in] pksh operation to cancel
 */
void
TALER_EXCHANGE_post_kyc_upload_cancel (
  struct TALER_EXCHANGE_PostKycUploadHandle *pksh);


#endif /* _TALER_EXCHANGE__POST_KYC_UPLOAD_ID_H */
