gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-merchant] branch master updated (c24599ff -> 89c8198b)


From: gnunet
Subject: [taler-merchant] branch master updated (c24599ff -> 89c8198b)
Date: Sat, 09 Mar 2024 21:07:33 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository merchant.

    from c24599ff version bump
     new 72062fbe improve drop.sql to avoid having to update it whenever new 
SQL revisions are added
     new 89c8198b implement #8608

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 configure.ac                                       |  2 +-
 debian/changelog                                   |  6 ++
 src/backend/Makefile.am                            |  2 +
 src/backend/taler-merchant-httpd.c                 | 12 ++-
 src/backend/taler-merchant-httpd_config.c          |  2 +-
 ...taler-merchant-httpd_private-get-templates-ID.c | 35 ++++----
 ...taler-merchant-httpd_private-get-templates-ID.h |  7 +-
 src/backenddb/drop.sql                             | 16 ++--
 src/include/taler_merchant_service.h               | 93 ++++++++++++++++++++--
 src/lib/Makefile.am                                |  1 +
 src/lib/merchant_api_get_config.c                  |  4 +-
 ...mplate.c => merchant_api_wallet_get_template.c} | 36 ++++-----
 12 files changed, 151 insertions(+), 65 deletions(-)
 copy src/lib/{merchant_api_get_template.c => 
merchant_api_wallet_get_template.c} (83%)

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/backenddb/drop.sql b/src/backenddb/drop.sql
index 07a8ff12..9005b6ed 100644
--- a/src/backenddb/drop.sql
+++ b/src/backenddb/drop.sql
@@ -17,15 +17,15 @@
 -- Everything in one big transaction
 BEGIN;
 
--- This script DROPs all of the tables we create, including the
--- versioning schema!
---
--- Unlike the other SQL files, it SHOULD be updated to reflect the
--- latest requirements for dropping tables.
+-- This script DROPs all of the tables we create.
 
-SELECT _v.unregister_patch('merchant-0001');
-SELECT _v.unregister_patch('merchant-0002');
-SELECT _v.unregister_patch('merchant-0003');
+WITH xpatches AS (
+  SELECT patch_name
+  FROM _v.patches
+  WHERE starts_with(patch_name,'merchant-')
+)
+  SELECT _v.unregister_patch(xpatches.patch_name)
+  FROM xpatches;
 
 
 DROP SCHEMA merchant CASCADE;
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.
  */
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
 
 
 /**
diff --git a/src/lib/merchant_api_get_template.c 
b/src/lib/merchant_api_wallet_get_template.c
similarity index 83%
copy from src/lib/merchant_api_get_template.c
copy to src/lib/merchant_api_wallet_get_template.c
index 9bbcc93a..d9ca95bc 100644
--- a/src/lib/merchant_api_get_template.c
+++ b/src/lib/merchant_api_wallet_get_template.c
@@ -15,7 +15,7 @@
   <http://www.gnu.org/licenses/>
 */
 /**
- * @file merchant_api_get_template.c
+ * @file merchant_api_wallet_get_template.c
  * @brief Implementation of the GET /templates/$ID request of the merchant's 
HTTP API
  * @author Priscilla HUANG
  */
@@ -34,7 +34,7 @@
 /**
  * Handle for a GET /templates/$ID operation.
  */
-struct TALER_MERCHANT_TemplateGetHandle
+struct TALER_MERCHANT_WalletTemplateGetHandle
 {
   /**
    * The url for this request.
@@ -49,7 +49,7 @@ struct TALER_MERCHANT_TemplateGetHandle
   /**
    * Function to call with the result.
    */
-  TALER_MERCHANT_TemplateGetCallback cb;
+  TALER_MERCHANT_WalletTemplateGetCallback cb;
 
   /**
    * Closure for @a cb.
@@ -77,9 +77,9 @@ handle_get_template_finished (void *cls,
                               long response_code,
                               const void *response)
 {
-  struct TALER_MERCHANT_TemplateGetHandle *tgh = cls;
+  struct TALER_MERCHANT_WalletTemplateGetHandle *tgh = cls;
   const json_t *json = response;
-  struct TALER_MERCHANT_TemplateGetResponse tgr = {
+  struct TALER_MERCHANT_WalletTemplateGetResponse tgr = {
     .hr.http_status = (unsigned int) response_code,
     .hr.reply = json
   };
@@ -94,12 +94,6 @@ handle_get_template_finished (void *cls,
     {
       const json_t *contract;
       struct GNUNET_JSON_Specification spec[] = {
-        GNUNET_JSON_spec_string ("template_description",
-                                 &tgr.details.ok.template_description),
-        GNUNET_JSON_spec_mark_optional (
-          GNUNET_JSON_spec_string ("otp_id",
-                                   &tgr.details.ok.otp_id),
-          NULL),
         GNUNET_JSON_spec_object_const ("template_contract",
                                        &contract),
         GNUNET_JSON_spec_end ()
@@ -113,7 +107,7 @@ handle_get_template_finished (void *cls,
         tgr.details.ok.template_contract = contract;
         tgh->cb (tgh->cb_cls,
                  &tgr);
-        TALER_MERCHANT_template_get_cancel (tgh);
+        TALER_MERCHANT_wallet_template_get_cancel (tgh);
         return;
       }
       tgr.hr.http_status = 0;
@@ -141,22 +135,22 @@ handle_get_template_finished (void *cls,
   }
   tgh->cb (tgh->cb_cls,
            &tgr);
-  TALER_MERCHANT_template_get_cancel (tgh);
+  TALER_MERCHANT_wallet_template_get_cancel (tgh);
 }
 
 
-struct TALER_MERCHANT_TemplateGetHandle *
-TALER_MERCHANT_template_get (
+struct TALER_MERCHANT_WalletTemplateGetHandle *
+TALER_MERCHANT_wallet_template_get (
   struct GNUNET_CURL_Context *ctx,
   const char *backend_url,
   const char *template_id,
-  TALER_MERCHANT_TemplateGetCallback cb,
+  TALER_MERCHANT_WalletTemplateGetCallback cb,
   void *cb_cls)
 {
-  struct TALER_MERCHANT_TemplateGetHandle *tgh;
+  struct TALER_MERCHANT_WalletTemplateGetHandle *tgh;
   CURL *eh;
 
-  tgh = GNUNET_new (struct TALER_MERCHANT_TemplateGetHandle);
+  tgh = GNUNET_new (struct TALER_MERCHANT_WalletTemplateGetHandle);
   tgh->ctx = ctx;
   tgh->cb = cb;
   tgh->cb_cls = cb_cls;
@@ -164,7 +158,7 @@ TALER_MERCHANT_template_get (
     char *path;
 
     GNUNET_asprintf (&path,
-                     "private/templates/%s",
+                     "templates/%s",
                      template_id);
     tgh->url = TALER_url_join (backend_url,
                                path,
@@ -191,8 +185,8 @@ TALER_MERCHANT_template_get (
 
 
 void
-TALER_MERCHANT_template_get_cancel (
-  struct TALER_MERCHANT_TemplateGetHandle *tgh)
+TALER_MERCHANT_wallet_template_get_cancel (
+  struct TALER_MERCHANT_WalletTemplateGetHandle *tgh)
 {
   if (NULL != tgh->job)
     GNUNET_CURL_job_cancel (tgh->job);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]