diff options
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | debian/changelog | 6 | ||||
-rw-r--r-- | src/backend/Makefile.am | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 12 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_config.c | 2 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-templates-ID.c | 35 | ||||
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-templates-ID.h | 7 | ||||
-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_config.c | 4 |
10 files changed, 128 insertions, 36 deletions
diff --git a/configure.ac b/configure.ac index 84236997..659d7349 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ # This configure file is in the public domain AC_PREREQ([2.69]) -AC_INIT([taler-merchant],[0.9.4b],[taler-bug@gnunet.org]) +AC_INIT([taler-merchant],[0.10.0],[taler-bug@gnunet.org]) AC_CONFIG_SRCDIR([src/backend/taler-merchant-httpd.c]) AC_CONFIG_HEADERS([taler_merchant_config.h]) # support for non-recursive builds diff --git a/debian/changelog b/debian/changelog index e2ab2dd2..36344f8b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +taler-merchant (0.10.0) unstable; urgency=low + + * Implement public GET API for templates (#8608). + + -- Christian Grothoff <grothoff@gnu.org> Sat, 9 Mar 2024 21:50:12 +0200 + taler-merchant (0.9.4-3) unstable; urgency=low * v0.9.4b bugfix release (mostly updates SPA). diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index 9ece7912..d521608d 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -28,6 +28,8 @@ taler_merchant_httpd_SOURCES = \ taler-merchant-httpd_exchanges.c taler-merchant-httpd_exchanges.h \ taler-merchant-httpd_get-orders-ID.c \ taler-merchant-httpd_get-orders-ID.h \ + taler-merchant-httpd_get-templates-ID.c \ + taler-merchant-httpd_get-templates-ID.h \ taler-merchant-httpd_helper.c \ taler-merchant-httpd_helper.h \ taler-merchant-httpd_mhd.c \ diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 8220f84d..7384bfc9 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -31,6 +31,7 @@ #include "taler-merchant-httpd_config.h" #include "taler-merchant-httpd_exchanges.h" #include "taler-merchant-httpd_get-orders-ID.h" +#include "taler-merchant-httpd_get-templates-ID.h" #include "taler-merchant-httpd_mhd.h" #include "taler-merchant-httpd_private-delete-account-ID.h" #include "taler-merchant-httpd_private-delete-instances-ID.h" @@ -1268,7 +1269,6 @@ url_handler (void *cls, .url_prefix = "/tokenfamilies/", .method = MHD_HTTP_METHOD_GET, .have_id_segment = true, - .allow_deleted_instance = true, .handler = &TMH_private_get_tokenfamilies_SLUG }, /* DELETE /tokenfamilies/$SLUG/: */ @@ -1276,7 +1276,6 @@ url_handler (void *cls, .url_prefix = "/tokenfamilies/", .method = MHD_HTTP_METHOD_DELETE, .have_id_segment = true, - .allow_deleted_instance = true, .handler = &TMH_private_delete_token_families_SLUG }, /* PATCH /tokenfamilies/$SLUG/: */ @@ -1284,7 +1283,6 @@ url_handler (void *cls, .url_prefix = "/tokenfamilies/", .method = MHD_HTTP_METHOD_PATCH, .have_id_segment = true, - .allow_deleted_instance = true, .handler = &TMH_private_patch_token_family_SLUG, }, { @@ -1414,12 +1412,18 @@ url_handler (void *cls, .have_id_segment = true, .handler = &TMH_return_static }, + /* GET /templates/$ID/: */ + { + .url_prefix = "/templates/", + .method = MHD_HTTP_METHOD_GET, + .have_id_segment = true, + .handler = &TMH_get_templates_ID + }, /* POST /templates/$ID: */ { .url_prefix = "/templates/", .method = MHD_HTTP_METHOD_POST, .have_id_segment = true, - .allow_deleted_instance = true, .handler = &TMH_post_using_templates_ID, .max_upload = 1024 * 1024 }, diff --git a/src/backend/taler-merchant-httpd_config.c b/src/backend/taler-merchant-httpd_config.c index 074c2a7e..d020985b 100644 --- a/src/backend/taler-merchant-httpd_config.c +++ b/src/backend/taler-merchant-httpd_config.c @@ -42,7 +42,7 @@ * #MERCHANT_PROTOCOL_CURRENT and #MERCHANT_PROTOCOL_AGE in * merchant_api_config.c! */ -#define MERCHANT_PROTOCOL_VERSION "10:0:6" +#define MERCHANT_PROTOCOL_VERSION "11:0:7" /** diff --git a/src/backend/taler-merchant-httpd_private-get-templates-ID.c b/src/backend/taler-merchant-httpd_private-get-templates-ID.c index e9dfc00f..a5b05f0c 100644 --- a/src/backend/taler-merchant-httpd_private-get-templates-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-templates-ID.c @@ -23,18 +23,11 @@ #include <taler/taler_json_lib.h> -/** - * Handle a GET "/templates/$ID" request. - * - * @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_templates_ID (const struct TMH_RequestHandler *rh, - struct MHD_Connection *connection, - struct TMH_HandlerContext *hc) +TMH_private_get_templates_ID ( + const struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + struct TMH_HandlerContext *hc) { struct TMH_MerchantInstance *mi = hc->instance; struct TALER_MERCHANTDB_TemplateDetails tp = { 0 }; @@ -48,17 +41,19 @@ TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, if (0 > qs) { GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "lookup_template"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "lookup_template"); } - if (0 == qs) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, - hc->infix); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, + hc->infix); } { MHD_RESULT ret; diff --git a/src/backend/taler-merchant-httpd_private-get-templates-ID.h b/src/backend/taler-merchant-httpd_private-get-templates-ID.h index 384ab818..fcdd6a2e 100644 --- a/src/backend/taler-merchant-httpd_private-get-templates-ID.h +++ b/src/backend/taler-merchant-httpd_private-get-templates-ID.h @@ -33,9 +33,10 @@ * @return MHD result code */ MHD_RESULT -TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, - struct MHD_Connection *connection, - struct TMH_HandlerContext *hc); +TMH_private_get_templates_ID ( + const struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + struct TMH_HandlerContext *hc); /* end of taler-merchant-httpd_private-get-templates-ID.h */ #endif diff --git a/src/include/taler_merchant_service.h b/src/include/taler_merchant_service.h index 448b8ba4..2ed51a29 100644 --- a/src/include/taler_merchant_service.h +++ b/src/include/taler_merchant_service.h @@ -4598,7 +4598,7 @@ TALER_MERCHANT_templates_get_cancel ( /** - * Handle for a GET /template/$ID operation. Gets details + * Handle for a GET /private/template/$ID operation. Gets details * about a single template. Do not confused with a * `struct TALER_MERCHANT_TemplatesGetHandle`, which * obtains a list of all templates. @@ -4607,7 +4607,7 @@ struct TALER_MERCHANT_TemplateGetHandle; /** - * Details in a response to a GET /templates request. + * Details in a response to a GET /private/templates/$ID request. */ struct TALER_MERCHANT_TemplateGetResponse { @@ -4650,7 +4650,7 @@ struct TALER_MERCHANT_TemplateGetResponse /** - * Function called with the result of the GET /template/$ID operation. + * Function called with the result of the GET /private/template/$ID operation. * * @param cls closure * @param tgr HTTP response details @@ -4662,7 +4662,7 @@ typedef void /** - * Make a GET /template/$ID request to get details about an + * Make a GET /private/template/$ID request to get details about an * individual template. * * @param ctx the context @@ -4682,7 +4682,7 @@ TALER_MERCHANT_template_get ( /** - * Cancel GET /templates/$ID operation. + * Cancel GET /private/templates/$ID operation. * * @param tgh operation to cancel */ @@ -4692,6 +4692,89 @@ TALER_MERCHANT_template_get_cancel ( /** + * Handle for a (public) GET /template/$ID operation. Gets details about a + * single template. Do not confused with a `struct + * TALER_MERCHANT_TemplateGetHandle`, which is for the private API. + */ +struct TALER_MERCHANT_WalletTemplateGetHandle; + + +/** + * Details in a response to a GET /templates request. + */ +struct TALER_MERCHANT_WalletTemplateGetResponse +{ + /** + * HTTP response details. + */ + struct TALER_MERCHANT_HttpResponse hr; + + /** + * Response details depending on the HTTP status. + */ + union + { + /** + * Information returned if the status was #MHD_HTTP_OK. + */ + struct + { + + /** + * Template for the contract. + */ + const json_t *template_contract; + + } ok; + + } details; + +}; + + +/** + * Function called with the result of the GET /template/$ID operation. + * + * @param cls closure + * @param tgr HTTP response details + */ +typedef void +(*TALER_MERCHANT_WalletTemplateGetCallback)( + void *cls, + const struct TALER_MERCHANT_WalletTemplateGetResponse *tgr); + + +/** + * Make a GET /template/$ID request to get details about an + * individual template. + * + * @param ctx the context + * @param backend_url HTTP base URL for the backend + * @param template_id identifier of the template to inquire about + * @param cb function to call with the backend's template information + * @param cb_cls closure for @a cb + * @return the request handle; NULL upon error + */ +struct TALER_MERCHANT_WalletTemplateGetHandle * +TALER_MERCHANT_wallet_template_get ( + struct GNUNET_CURL_Context *ctx, + const char *backend_url, + const char *template_id, + TALER_MERCHANT_WalletTemplateGetCallback cb, + void *cb_cls); + + +/** + * Cancel GET /templates/$ID operation. + * + * @param tgh operation to cancel + */ +void +TALER_MERCHANT_wallet_template_get_cancel ( + struct TALER_MERCHANT_WalletTemplateGetHandle *tgh); + + +/** * Handle for a POST /templates operation. */ struct TALER_MERCHANT_TemplatesPostHandle; diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 641ea717..04b2b089 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -65,6 +65,7 @@ libtalermerchant_la_SOURCES = \ merchant_api_post_using_templates.c \ merchant_api_post_webhooks.c \ merchant_api_wallet_get_order.c \ + merchant_api_wallet_get_template.c \ merchant_api_wallet_post_order_refund.c libtalermerchant_la_LIBADD = \ diff --git a/src/lib/merchant_api_get_config.c b/src/lib/merchant_api_get_config.c index b8328f9e..3f1471e3 100644 --- a/src/lib/merchant_api_get_config.c +++ b/src/lib/merchant_api_get_config.c @@ -34,12 +34,12 @@ * Which version of the Taler protocol is implemented * by this library? Used to determine compatibility. */ -#define MERCHANT_PROTOCOL_CURRENT 10 +#define MERCHANT_PROTOCOL_CURRENT 11 /** * How many configs are we backwards-compatible with? */ -#define MERCHANT_PROTOCOL_AGE 5 +#define MERCHANT_PROTOCOL_AGE 6 /** |