merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

get-private-templates.h (3930B)


      1 /*
      2   This file is part of TALER
      3   Copyright (C) 2014-2026 Taler Systems SA
      4 
      5   TALER is free software; you can redistribute it and/or modify it under the
      6   terms of the GNU Lesser General Public License as published by the Free Software
      7   Foundation; either version 2.1, or (at your option) any later version.
      8 
      9   TALER is distributed in the hope that it will be useful, but WITHOUT ANY
     10   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11   A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
     12 
     13   You should have received a copy of the GNU Lesser General Public License along with
     14   TALER; see the file COPYING.LGPL.  If not, see
     15   <http://www.gnu.org/licenses/>
     16 */
     17 /**
     18  * @file src/include/taler/merchant/get-private-templates.h
     19  * @brief C interface for the GET /private/templates endpoint
     20  * @author Christian Grothoff
     21  */
     22 #ifndef _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_H
     23 #define _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_H
     24 
     25 #include <taler/merchant/common.h>
     26 
     27 
     28 /**
     29  * Handle for a GET /private/templates request.
     30  */
     31 struct TALER_MERCHANT_GetPrivateTemplatesHandle;
     32 
     33 
     34 /**
     35  * Entry for one order template.
     36  */
     37 struct TALER_MERCHANT_GetPrivateTemplatesTemplateEntry
     38 {
     39 
     40   /**
     41    * Identifier of the template.
     42    */
     43   const char *template_id;
     44 
     45   /**
     46    * Human-readable description of the template.
     47    */
     48   const char *template_description;
     49 
     50 };
     51 
     52 
     53 /**
     54  * Response details for a GET /private/templates request.
     55  */
     56 struct TALER_MERCHANT_GetPrivateTemplatesResponse
     57 {
     58 
     59   /**
     60    * HTTP response details.
     61    */
     62   struct TALER_MERCHANT_HttpResponse hr;
     63 
     64   /**
     65    * Details depending on the HTTP status code.
     66    */
     67   union
     68   {
     69 
     70     /**
     71      * Details on #MHD_HTTP_OK.
     72      */
     73     struct
     74     {
     75 
     76       /**
     77        * Number of templates in @a templates.
     78        */
     79       unsigned int templates_length;
     80 
     81       /**
     82        * Array of template entries.
     83        */
     84       const struct TALER_MERCHANT_GetPrivateTemplatesTemplateEntry *templates;
     85 
     86     } ok;
     87 
     88   } details;
     89 
     90 };
     91 
     92 
     93 /**
     94  * Set up GET /private/templates operation.
     95  * Note that you must explicitly start the operation after
     96  * possibly setting options.
     97  *
     98  * @param ctx the context
     99  * @param url base URL of the merchant backend
    100  * @return handle to operation
    101  */
    102 struct TALER_MERCHANT_GetPrivateTemplatesHandle *
    103 TALER_MERCHANT_get_private_templates_create (
    104   struct GNUNET_CURL_Context *ctx,
    105   const char *url);
    106 
    107 
    108 #ifndef TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE
    109 /**
    110  * Type of the closure used by
    111  * the #TALER_MERCHANT_GetPrivateTemplatesCallback.
    112  */
    113 #define TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE void
    114 #endif /* TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE */
    115 
    116 /**
    117  * Callback for a GET /private/templates request.
    118  *
    119  * @param cls closure
    120  * @param tgr response details
    121  */
    122 typedef void
    123 (*TALER_MERCHANT_GetPrivateTemplatesCallback)(
    124   TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE *cls,
    125   const struct TALER_MERCHANT_GetPrivateTemplatesResponse *tgr);
    126 
    127 
    128 /**
    129  * Start GET /private/templates operation.
    130  *
    131  * @param[in,out] gpth operation to start
    132  * @param cb function to call with the merchant's result
    133  * @param cb_cls closure for @a cb
    134  * @return status code, #TALER_EC_NONE on success
    135  */
    136 enum TALER_ErrorCode
    137 TALER_MERCHANT_get_private_templates_start (
    138   struct TALER_MERCHANT_GetPrivateTemplatesHandle *gpth,
    139   TALER_MERCHANT_GetPrivateTemplatesCallback cb,
    140   TALER_MERCHANT_GET_PRIVATE_TEMPLATES_RESULT_CLOSURE *cb_cls);
    141 
    142 
    143 /**
    144  * Cancel GET /private/templates operation.  This function must not be
    145  * called by clients after the TALER_MERCHANT_GetPrivateTemplatesCallback
    146  * has been invoked (as in those cases it'll be called internally by the
    147  * implementation already).
    148  *
    149  * @param[in] gpth operation to cancel
    150  */
    151 void
    152 TALER_MERCHANT_get_private_templates_cancel (
    153   struct TALER_MERCHANT_GetPrivateTemplatesHandle *gpth);
    154 
    155 
    156 #endif /* _TALER_MERCHANT__GET_PRIVATE_TEMPLATES_H */