/*
  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/post-templates-TEMPLATE_ID.h
 * @brief C interface for POST /templates/$TEMPLATE_ID (create order from template)
 *        of the merchant backend
 * @author Christian Grothoff
 */
#ifndef _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_H
#define _TALER_MERCHANT__POST_TEMPLATES_TEMPLATE_ID_H

#include <taler/taler-merchant/common.h>
#include <taler/taler-merchant/post-private-orders.h>


/**
 * Handle for a POST /templates/$TEMPLATE_ID request.
 */
struct TALER_MERCHANT_UsingTemplatesPostHandle;


/**
 * Issue a POST /templates/$TEMPLATE_ID request to create an order from
 * a template using a simple amount and summary.
 *
 * @param ctx CURL context to use
 * @param backend_url base URL of the merchant backend
 * @param template_id identifier of the template to use
 * @param summary order summary
 * @param amount total amount for the order
 * @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_UsingTemplatesPostHandle *
TALER_MERCHANT_using_templates_post (
  struct GNUNET_CURL_Context *ctx,
  const char *backend_url,
  const char *template_id,
  const char *summary,
  const struct TALER_Amount *amount,
  TALER_MERCHANT_PostOrdersCallback cb,
  void *cb_cls);


/**
 * Issue a POST /templates/$TEMPLATE_ID request to create an order from
 * a template using detailed contract customization.
 *
 * @param ctx CURL context to use
 * @param backend_url base URL of the merchant backend
 * @param template_id identifier of the template to use
 * @param details JSON object with template-specific order details
 * @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_UsingTemplatesPostHandle *
TALER_MERCHANT_using_templates_post2 (
  struct GNUNET_CURL_Context *ctx,
  const char *backend_url,
  const char *template_id,
  const json_t *details,
  TALER_MERCHANT_PostOrdersCallback cb,
  void *cb_cls);


/**
 * Cancel a POST /templates/$TEMPLATE_ID request.
 *
 * @param[in] utph handle to cancel
 */
void
TALER_MERCHANT_using_templates_post_cancel (
  struct TALER_MERCHANT_UsingTemplatesPostHandle *utph);


#endif
