diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-06-09 12:00:17 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-06-09 12:00:17 +0200 |
commit | 0c481ef1b4c216ab6ba23a14c692cf384efb21dd (patch) | |
tree | d1b2c1a9f189a2c4888a2bcdbb29169fe9f8ee45 | |
parent | b5b3f8adc175519530ee17137e532393727682ca (diff) | |
parent | cb8cb51cbda0eb3255754ea87c0098280a1b4286 (diff) | |
download | merchant-0c481ef1b4c216ab6ba23a14c692cf384efb21dd.tar.gz merchant-0c481ef1b4c216ab6ba23a14c692cf384efb21dd.tar.bz2 merchant-0c481ef1b4c216ab6ba23a14c692cf384efb21dd.zip |
Merge branch 'protocolV1' of git+ssh://git.taler.net/merchant into protocolV1
-rw-r--r-- | src/backend/Makefile.am | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-tips.c | 20 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-tips.h | 41 | ||||
-rw-r--r-- | src/include/taler_merchant_service.h | 93 | ||||
-rw-r--r-- | src/lib/Makefile.am | 1 | ||||
-rw-r--r-- | src/lib/merchant_api_get_tips.c | 21 |
6 files changed, 178 insertions, 0 deletions
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index ffcb2c6c..4a7fa382 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -26,6 +26,8 @@ taler_merchant_httpd_SOURCES = \ taler-merchant-httpd_get-orders-ID.h \ taler-merchant-httpd_get-tips-ID.c \ taler-merchant-httpd_get-tips-ID.h \ + taler-merchant-httpd_private-get-tips.c \ + taler-merchant-httpd_private-get-tips.h \ taler-merchant-httpd_mhd.c taler-merchant-httpd_mhd.h \ taler-merchant-httpd_private-delete-instances-ID.c \ taler-merchant-httpd_private-delete-instances-ID.h \ diff --git a/src/backend/taler-merchant-httpd_private-get-tips.c b/src/backend/taler-merchant-httpd_private-get-tips.c new file mode 100644 index 00000000..f874f5b5 --- /dev/null +++ b/src/backend/taler-merchant-httpd_private-get-tips.c @@ -0,0 +1,20 @@ +/* + This file is part of TALER + (C) 2020 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file backend/taler-merchant-httpd_private-get-tips.c + * @brief implementation of a GET /private/tips handler + * @author Jonathan Buchanan + */ diff --git a/src/backend/taler-merchant-httpd_private-get-tips.h b/src/backend/taler-merchant-httpd_private-get-tips.h new file mode 100644 index 00000000..a892726e --- /dev/null +++ b/src/backend/taler-merchant-httpd_private-get-tips.h @@ -0,0 +1,41 @@ +/* + This file is part of TALER + (C) 2020 Taler Systems SA + + TALER is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> +*/ +/** + * @file backend/taler-merchant-httpd_private-get-tips.h + * @brief headers for GET /private/tips handler + * @author Jonathan Buchanan + */ +#ifndef TALER_MERCHANT_HTTPD_PRIVATE_GET_TIPS_H +#define TALER_MERCHANT_HTTPD_PRIVATE_GET_TIPS_H +#include <microhttpd.h> +#include "taler-merchant-httpd.h" + + +/** + * Manages a GET /private/tips call. + * + * @param rh context of the handler + * @param connection the MHD connection to handle + * @param[in,out] hc context with further information about the request + * @return MHD result code + */ +MHD_RESULT +TMH_private_get_tips (const struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + struct TMH_HandlerContext *hc); + + +#endif diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 19f059b6..4c0fa0c7 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -2820,6 +2820,99 @@ TALER_MERCHANT_tip_get_cancel (struct TALER_MERCHANT_TipGetHandle *tqh); /** + * Handle for a GET /private/tips request. + */ +struct TALER_MERCHANT_TipsGetHandle; + + +/** + * Database entry information of a tip. + */ +struct TALER_MERCHANT_TipEntry +{ + /** + * Row number of the tip in the database. + */ + unsigned int row_id; + + + /** + * Identifier for the tip. + */ + struct GNUNET_HashCode tip_id; + + /** + * Total value of the tip (including fees). + */ + struct TALER_Amount tip_amount; + +}; + + +/** + * Callback to process a GET /private/tips request. + * + * @param cls closure + * @param hr HTTP response details + * @param tips_length length of the @a tips array + * @param tips the array of tips, NULL on error + */ +typedef void +(*TALER_MERCHANT_TipsGetCallback) ( + void *cls, + const struct TALER_MERCHANT_HttpResponse *hr, + unsigned int tips_length, + const struct TALER_MERCHANT_TipEntry tips[]); + + +/** + * Issue a GET /private/tips request to the backend. + * + * @param ctx execution context + * @param backend_url base URL of the merchant backend + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return handle for this operation, NULL upon errors + */ +struct TALER_MERCHANT_TipsGetHandle * +TALER_MERCHANT_tips_get (struct GNUNET_CURL_Context *ctx, + const char *backend_url, + TALER_MERCHANT_TipsGetCallback cb, + void *cb_cls); + + +/** + * Issue a GET /private/tips request with filters to the backend. + * + * @param ctx execution context + * @param backend_url base URL of the merchant backend + * @param include_expired whether to return all tips or only unexpired tips + * @param limit number of results to return, negative for descending row id, positive for ascending + * @param offset row id to start returning results from + * @param cb function to call with the result + * @param cb_cls closure for @a cb + * @return handle for this operation, NULL upon errors + */ +struct TALER_MERCHANT_TipsGetHandle * +TALER_MERCHANT_tips_get2 (struct GNUNET_CURL_Context *ctx, + const char *backend_url, + bool include_expired, + int limit, + unsigned int offset, + TALER_MERCHANT_TipsGetCallback cb, + void *cb_cls); + + +/** + * Cancel a GET /private/tips request. + * + * @param + */ +void +TALER_MERCHANT_tips_get_cancel (struct TALER_MERCHANT_TipsGetHandle *); + + +/** * Handle for a POST /tips/$TIP_ID/pickup operation. */ struct TALER_MERCHANT_TipPickupHandle; diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 50b7a6d0..5e9eaa30 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -39,6 +39,7 @@ libtalermerchant_la_SOURCES = \ merchant_api_post_products.c \ merchant_api_post_reserves.c \ merchant_api_post_transfers.c \ + merchant_api_get_tips.c \ \ merchant_api_tip_authorize.c \ merchant_api_tip_pickup.c \ diff --git a/src/lib/merchant_api_get_tips.c b/src/lib/merchant_api_get_tips.c new file mode 100644 index 00000000..05f8e7b4 --- /dev/null +++ b/src/lib/merchant_api_get_tips.c @@ -0,0 +1,21 @@ +/* + This file is part of TALER + Copyright (C) 2020 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 lib/merchant_api_get_tips.c + * @brief Implementation of the GET /private/tips request of the merchant's HTTP API + * @author Jonathan Buchanan + */ |