From 89c8198bbfcba44a37cb124f80a7deb1d98474c1 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 9 Mar 2024 21:03:39 +0100 Subject: implement #8608 --- src/include/taler_merchant_service.h | 93 ++++++++++++++++++++++++++++++++++-- 1 file changed, 88 insertions(+), 5 deletions(-) (limited to 'src/include/taler_merchant_service.h') 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 */ @@ -4691,6 +4691,89 @@ TALER_MERCHANT_template_get_cancel ( struct TALER_MERCHANT_TemplateGetHandle *tgh); +/** + * 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. */ -- cgit v1.2.3