get-private-otp-devices.h (4005B)
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-otp-devices.h 19 * @brief C interface for the GET /private/otp-devices endpoint 20 * @author Christian Grothoff 21 */ 22 #ifndef _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_H 23 #define _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_H 24 25 #include <taler/merchant/common.h> 26 27 28 /** 29 * Handle for a GET /private/otp-devices request. 30 */ 31 struct TALER_MERCHANT_GetPrivateOtpDevicesHandle; 32 33 34 /** 35 * Entry for one OTP device. 36 */ 37 struct TALER_MERCHANT_GetPrivateOtpDevicesOtpDeviceEntry 38 { 39 40 /** 41 * Identifier of the OTP device. 42 */ 43 const char *otp_device_id; 44 45 /** 46 * Human-readable description of the OTP device. 47 */ 48 const char *otp_device_description; 49 50 }; 51 52 53 /** 54 * Response details for a GET /private/otp-devices request. 55 */ 56 struct TALER_MERCHANT_GetPrivateOtpDevicesResponse 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 OTP devices in @a otp_devices. 78 */ 79 unsigned int otp_devices_length; 80 81 /** 82 * Array of OTP device entries. 83 */ 84 const struct TALER_MERCHANT_GetPrivateOtpDevicesOtpDeviceEntry * 85 otp_devices; 86 87 } ok; 88 89 } details; 90 91 }; 92 93 94 /** 95 * Set up GET /private/otp-devices operation. 96 * Note that you must explicitly start the operation after 97 * possibly setting options. 98 * 99 * @param ctx the context 100 * @param url base URL of the merchant backend 101 * @return handle to operation 102 */ 103 struct TALER_MERCHANT_GetPrivateOtpDevicesHandle * 104 TALER_MERCHANT_get_private_otp_devices_create ( 105 struct GNUNET_CURL_Context *ctx, 106 const char *url); 107 108 109 #ifndef TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE 110 /** 111 * Type of the closure used by 112 * the #TALER_MERCHANT_GetPrivateOtpDevicesCallback. 113 */ 114 #define TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE void 115 #endif /* TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE */ 116 117 /** 118 * Callback for a GET /private/otp-devices request. 119 * 120 * @param cls closure 121 * @param ogr response details 122 */ 123 typedef void 124 (*TALER_MERCHANT_GetPrivateOtpDevicesCallback)( 125 TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE *cls, 126 const struct TALER_MERCHANT_GetPrivateOtpDevicesResponse *ogr); 127 128 129 /** 130 * Start GET /private/otp-devices operation. 131 * 132 * @param[in,out] gpoh operation to start 133 * @param cb function to call with the merchant's result 134 * @param cb_cls closure for @a cb 135 * @return status code, #TALER_EC_NONE on success 136 */ 137 enum TALER_ErrorCode 138 TALER_MERCHANT_get_private_otp_devices_start ( 139 struct TALER_MERCHANT_GetPrivateOtpDevicesHandle *gpoh, 140 TALER_MERCHANT_GetPrivateOtpDevicesCallback cb, 141 TALER_MERCHANT_GET_PRIVATE_OTP_DEVICES_RESULT_CLOSURE *cb_cls); 142 143 144 /** 145 * Cancel GET /private/otp-devices operation. This function must not be 146 * called by clients after the TALER_MERCHANT_GetPrivateOtpDevicesCallback 147 * has been invoked (as in those cases it'll be called internally by the 148 * implementation already). 149 * 150 * @param[in] gpoh operation to cancel 151 */ 152 void 153 TALER_MERCHANT_get_private_otp_devices_cancel ( 154 struct TALER_MERCHANT_GetPrivateOtpDevicesHandle *gpoh); 155 156 157 #endif /* _TALER_MERCHANT__GET_PRIVATE_OTP_DEVICES_H */