/*
  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-private-tokenfamilies.h
 * @brief C interface for POST /private/tokenfamilies of the merchant backend
 * @author Christian Grothoff
 */
#ifndef _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_H
#define _TALER_MERCHANT__POST_PRIVATE_TOKENFAMILIES_H

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


/**
 * Handle for a POST /private/tokenfamilies request.
 */
struct TALER_MERCHANT_TokenFamiliesPostHandle;


/**
 * Callback for a POST /private/tokenfamilies request.
 *
 * @param cls closure
 * @param hr HTTP response details
 */
typedef void
(*TALER_MERCHANT_TokenFamiliesPostCallback)(
  void *cls,
  const struct TALER_MERCHANT_HttpResponse *hr);


/**
 * Issue a POST /private/tokenfamilies request to create a new token family.
 *
 * @param ctx CURL context to use
 * @param backend_url base URL of the merchant backend
 * @param slug URL-safe slug identifier for the new token family
 * @param name human-readable name
 * @param description human-readable description
 * @param description_i18n internationalized descriptions (JSON), or NULL
 * @param extra_data extra data (JSON), or NULL
 * @param valid_after start of validity period
 * @param valid_before end of validity period
 * @param duration duration of individual token validity
 * @param validity_granularity granularity for validity alignment
 * @param start_offset offset from purchase to start of validity
 * @param kind kind of token family ("subscription" or "discount")
 * @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_TokenFamiliesPostHandle *
TALER_MERCHANT_token_families_post (
  struct GNUNET_CURL_Context *ctx,
  const char *backend_url,
  const char *slug,
  const char *name,
  const char *description,
  const json_t *description_i18n,
  const json_t *extra_data,
  struct GNUNET_TIME_Timestamp valid_after,
  struct GNUNET_TIME_Timestamp valid_before,
  struct GNUNET_TIME_Relative duration,
  struct GNUNET_TIME_Relative validity_granularity,
  struct GNUNET_TIME_Relative start_offset,
  const char *kind,
  TALER_MERCHANT_TokenFamiliesPostCallback cb,
  void *cb_cls);


/**
 * Cancel a POST /private/tokenfamilies request.
 *
 * @param[in] pph handle to cancel
 */
void
TALER_MERCHANT_token_families_post_cancel (
  struct TALER_MERCHANT_TokenFamiliesPostHandle *pph);


#endif
