merchant

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

get-private-units.h (3496B)


      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-units.h
     19  * @brief C interface for the GET /private/units endpoint
     20  * @author Christian Grothoff
     21  */
     22 #ifndef _TALER_MERCHANT__GET_PRIVATE_UNITS_H
     23 #define _TALER_MERCHANT__GET_PRIVATE_UNITS_H
     24 
     25 #include <taler/merchant/common.h>
     26 
     27 
     28 /**
     29  * Handle for a GET /private/units request.
     30  */
     31 struct TALER_MERCHANT_GetPrivateUnitsHandle;
     32 
     33 
     34 /**
     35  * Response details for a GET /private/units request.
     36  */
     37 struct TALER_MERCHANT_GetPrivateUnitsResponse
     38 {
     39 
     40   /**
     41    * HTTP response details.
     42    */
     43   struct TALER_MERCHANT_HttpResponse hr;
     44 
     45   /**
     46    * Details depending on the HTTP status code.
     47    */
     48   union
     49   {
     50 
     51     /**
     52      * Details on #MHD_HTTP_OK.
     53      */
     54     struct
     55     {
     56 
     57       /**
     58        * Number of units in @a units.
     59        */
     60       unsigned int units_length;
     61 
     62       /**
     63        * Array of unit entries.
     64        */
     65       const struct TALER_MERCHANT_UnitEntry *units;
     66 
     67     } ok;
     68 
     69   } details;
     70 
     71 };
     72 
     73 
     74 /**
     75  * Set up GET /private/units operation.
     76  * Note that you must explicitly start the operation after
     77  * possibly setting options.
     78  *
     79  * @param ctx the context
     80  * @param url base URL of the merchant backend
     81  * @return handle to operation
     82  */
     83 struct TALER_MERCHANT_GetPrivateUnitsHandle *
     84 TALER_MERCHANT_get_private_units_create (
     85   struct GNUNET_CURL_Context *ctx,
     86   const char *url);
     87 
     88 
     89 #ifndef TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE
     90 /**
     91  * Type of the closure used by
     92  * the #TALER_MERCHANT_GetPrivateUnitsCallback.
     93  */
     94 #define TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE void
     95 #endif /* TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE */
     96 
     97 /**
     98  * Callback for a GET /private/units request.
     99  *
    100  * @param cls closure
    101  * @param ugr response details
    102  */
    103 typedef void
    104 (*TALER_MERCHANT_GetPrivateUnitsCallback)(
    105   TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE *cls,
    106   const struct TALER_MERCHANT_GetPrivateUnitsResponse *ugr);
    107 
    108 
    109 /**
    110  * Start GET /private/units operation.
    111  *
    112  * @param[in,out] gpuh operation to start
    113  * @param cb function to call with the merchant's result
    114  * @param cb_cls closure for @a cb
    115  * @return status code, #TALER_EC_NONE on success
    116  */
    117 enum TALER_ErrorCode
    118 TALER_MERCHANT_get_private_units_start (
    119   struct TALER_MERCHANT_GetPrivateUnitsHandle *gpuh,
    120   TALER_MERCHANT_GetPrivateUnitsCallback cb,
    121   TALER_MERCHANT_GET_PRIVATE_UNITS_RESULT_CLOSURE *cb_cls);
    122 
    123 
    124 /**
    125  * Cancel GET /private/units operation.  This function must not be
    126  * called by clients after the TALER_MERCHANT_GetPrivateUnitsCallback
    127  * has been invoked (as in those cases it'll be called internally by the
    128  * implementation already).
    129  *
    130  * @param[in] gpuh operation to cancel
    131  */
    132 void
    133 TALER_MERCHANT_get_private_units_cancel (
    134   struct TALER_MERCHANT_GetPrivateUnitsHandle *gpuh);
    135 
    136 
    137 #endif /* _TALER_MERCHANT__GET_PRIVATE_UNITS_H */