gnunet-svn
[Top][All Lists]
Advanced

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

[taler-merchant] branch master updated: be more generous in terms of whi


From: gnunet
Subject: [taler-merchant] branch master updated: be more generous in terms of which fields are required when creating/updating products
Date: Tue, 20 Apr 2021 15:48:22 +0200

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

grothoff pushed a commit to branch master
in repository merchant.

The following commit(s) were added to refs/heads/master by this push:
     new 7dbc601c be more generous in terms of which fields are required when 
creating/updating products
7dbc601c is described below

commit 7dbc601c4f472111e1666be9cc55d397d1c446e6
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Apr 20 15:48:20 2021 +0200

    be more generous in terms of which fields are required when 
creating/updating products
---
 ...aler-merchant-httpd_private-patch-products-ID.c | 40 +++++++++++++++-------
 .../taler-merchant-httpd_private-post-products.c   | 34 ++++++++++++------
 2 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/src/backend/taler-merchant-httpd_private-patch-products-ID.c 
b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
index 92f5c036..cc4678a7 100644
--- a/src/backend/taler-merchant-httpd_private-patch-products-ID.c
+++ b/src/backend/taler-merchant-httpd_private-patch-products-ID.c
@@ -110,30 +110,36 @@ TMH_private_patch_products_ID (const struct 
TMH_RequestHandler *rh,
 {
   struct TMH_MerchantInstance *mi = hc->instance;
   const char *product_id = hc->infix;
-  struct TALER_MERCHANTDB_ProductDetails pd;
+  struct TALER_MERCHANTDB_ProductDetails pd = {0};
   int64_t total_stock;
   enum GNUNET_DB_QueryStatus qs;
   struct GNUNET_JSON_Specification spec[] = {
     GNUNET_JSON_spec_string ("description",
                              (const char **) &pd.description),
-    GNUNET_JSON_spec_json ("description_i18n",
-                           &pd.description_i18n),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("description_i18n",
+                             &pd.description_i18n)),
     GNUNET_JSON_spec_string ("unit",
                              (const char **) &pd.unit),
     TALER_JSON_spec_amount ("price",
                             &pd.price),
-    GNUNET_JSON_spec_string ("image",
-                             (const char **) &pd.image),
-    GNUNET_JSON_spec_json ("taxes",
-                           &pd.taxes),
-    GNUNET_JSON_spec_json ("address",
-                           &pd.address),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_string ("image",
+                               (const char **) &pd.image)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("taxes",
+                             &pd.taxes)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("address",
+                             &pd.address)),
     GNUNET_JSON_spec_int64 ("total_stock",
                             &total_stock),
-    GNUNET_JSON_spec_uint64 ("total_lost",
-                             &pd.total_lost),
-    TALER_JSON_spec_absolute_time ("next_restock",
-                                   &pd.next_restock),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_uint64 ("total_lost",
+                               &pd.total_lost)),
+    GNUNET_JSON_spec_mark_optional (
+      TALER_JSON_spec_absolute_time ("next_restock",
+                                     &pd.next_restock)),
     GNUNET_JSON_spec_end ()
   };
 
@@ -166,6 +172,14 @@ TMH_private_patch_products_ID (const struct 
TMH_RequestHandler *rh,
     pd.total_stock = INT64_MAX;
   else
     pd.total_stock = (uint64_t) total_stock;
+  if (NULL == pd.address)
+    pd.address = json_object ();
+  if (NULL == pd.description_i18n)
+    pd.description_i18n = json_object ();
+  if (NULL == pd.taxes)
+    pd.taxes = json_object ();
+  if (NULL == pd.image)
+    pd.image = "";
   if (NULL != json_object_get (hc->request_body,
                                "next_restock"))
   {
diff --git a/src/backend/taler-merchant-httpd_private-post-products.c 
b/src/backend/taler-merchant-httpd_private-post-products.c
index dac92bb9..76413cc4 100644
--- a/src/backend/taler-merchant-httpd_private-post-products.c
+++ b/src/backend/taler-merchant-httpd_private-post-products.c
@@ -83,8 +83,9 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
                              &product_id),
     GNUNET_JSON_spec_string ("description",
                              (const char **) &pd.description),
-    GNUNET_JSON_spec_json ("description_i18n",
-                           &pd.description_i18n),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("description_i18n",
+                             &pd.description_i18n)),
     GNUNET_JSON_spec_mark_optional (
       TALER_JSON_spec_absolute_time ("next_restock",
                                      &pd.next_restock)),
@@ -92,16 +93,20 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
                              (const char **) &pd.unit),
     TALER_JSON_spec_amount ("price",
                             &pd.price),
-    GNUNET_JSON_spec_string ("image",
-                             (const char **) &pd.image),
-    GNUNET_JSON_spec_json ("taxes",
-                           &pd.taxes),
-    GNUNET_JSON_spec_json ("address",
-                           &pd.address),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_string ("image",
+                               (const char **) &pd.image)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("taxes",
+                             &pd.taxes)),
+    GNUNET_JSON_spec_mark_optional (
+      GNUNET_JSON_spec_json ("address",
+                             &pd.address)),
     GNUNET_JSON_spec_int64 ("total_stock",
                             &total_stock),
-    TALER_JSON_spec_absolute_time ("next_restock",
-                                   &pd.next_restock),
+    GNUNET_JSON_spec_mark_optional (
+      TALER_JSON_spec_absolute_time ("next_restock",
+                                     &pd.next_restock)),
     GNUNET_JSON_spec_end ()
   };
 
@@ -136,7 +141,14 @@ TMH_private_post_products (const struct TMH_RequestHandler 
*rh,
   else
     pd.total_stock = (uint64_t) total_stock;
 
-
+  if (NULL == pd.address)
+    pd.address = json_object ();
+  if (NULL == pd.description_i18n)
+    pd.description_i18n = json_object ();
+  if (NULL == pd.taxes)
+    pd.taxes = json_object ();
+  if (NULL == pd.image)
+    pd.image = "";
   for (unsigned int i = 0; i<MAX_RETRIES; i++)
   {
     /* Test if an product of this id is known */

-- 
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]