aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/merchant_api_get_product.c50
-rw-r--r--src/lib/merchant_api_patch_product.c11
-rw-r--r--src/lib/merchant_api_post_products.c9
3 files changed, 45 insertions, 25 deletions
diff --git a/src/lib/merchant_api_get_product.c b/src/lib/merchant_api_get_product.c
index 0388c793..e9263b07 100644
--- a/src/lib/merchant_api_get_product.c
+++ b/src/lib/merchant_api_get_product.c
@@ -97,11 +97,12 @@ handle_get_product_finished (void *cls,
struct TALER_Amount price;
json_t *image;
json_t *taxes;
- int64_t total_stocked;
+ int64_t total_stock;
uint64_t total_sold;
uint64_t total_lost;
- json_t *location;
- struct GNUNET_TIME_Absolute next_restock;
+ json_t *address;
+ bool rst_ok = true;
+ struct GNUNET_TIME_Absolute next_restock = {0};
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("description",
&description),
@@ -109,29 +110,46 @@ handle_get_product_finished (void *cls,
&description_i18n),
GNUNET_JSON_spec_string ("unit",
&unit),
- TALER_JSON_spec_amount ("price_fee",
+ TALER_JSON_spec_amount ("price",
&price),
GNUNET_JSON_spec_json ("image",
&image),
GNUNET_JSON_spec_json ("taxes",
&taxes),
- GNUNET_JSON_spec_int64 ("total_stocked",
- &total_stocked),
+ GNUNET_JSON_spec_int64 ("total_stock",
+ &total_stock),
GNUNET_JSON_spec_uint64 ("total_sold",
&total_sold),
GNUNET_JSON_spec_uint64 ("total_lost",
&total_lost),
- GNUNET_JSON_spec_json ("location",
- &location),
- GNUNET_JSON_spec_absolute_time ("next_restock",
- &next_restock),
+ GNUNET_JSON_spec_json ("address",
+ &address),
GNUNET_JSON_spec_end ()
};
- if (GNUNET_OK ==
- GNUNET_JSON_parse (json,
- spec,
- NULL, NULL))
+ if (NULL !=
+ json_object_get (json,
+ "next_restock"))
+ {
+ struct GNUNET_JSON_Specification spect[] = {
+ GNUNET_JSON_spec_absolute_time ("next_restock",
+ &next_restock),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json,
+ spect,
+ NULL, NULL))
+ rst_ok = false;
+ }
+
+
+ if ( (rst_ok) &&
+ (GNUNET_OK ==
+ GNUNET_JSON_parse (json,
+ spec,
+ NULL, NULL)) )
{
pgh->cb (pgh->cb_cls,
&hr,
@@ -141,10 +159,10 @@ handle_get_product_finished (void *cls,
&price,
image,
taxes,
- total_stocked,
+ total_stock,
total_sold,
total_lost,
- location,
+ address,
next_restock);
GNUNET_JSON_parse_free (spec);
TALER_MERCHANT_product_get_cancel (pgh);
diff --git a/src/lib/merchant_api_patch_product.c b/src/lib/merchant_api_patch_product.c
index 4fba0974..c97bd1a5 100644
--- a/src/lib/merchant_api_patch_product.c
+++ b/src/lib/merchant_api_patch_product.c
@@ -167,10 +167,10 @@ handle_patch_product_finished (void *cls,
* applicable taxes.
* @param image base64-encoded product image
* @param taxes list of taxes paid by the merchant
- * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books),
+ * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books),
* must be larger than previous values
* @param total_lost in @a units, must be larger than previous values, and may
- * not exceed total_stocked minus total_sold; if it does, the transaction
+ * not exceed total_stock minus total_sold; if it does, the transaction
* will fail with a #MHD_HTTP_CONFLICT HTTP status code
* @param location where the product is in stock
* @param next_restock when the next restocking is expected to happen
@@ -189,7 +189,7 @@ TALER_MERCHANT_product_patch (
const struct TALER_Amount *price,
const json_t *image,
const json_t *taxes,
- int64_t total_stocked,
+ int64_t total_stock,
uint64_t total_lost,
const json_t *address,
struct GNUNET_TIME_Absolute next_restock,
@@ -199,6 +199,7 @@ TALER_MERCHANT_product_patch (
struct TALER_MERCHANT_ProductPatchHandle *pph;
json_t *req_obj;
+ (void) GNUNET_TIME_round_abs (&next_restock);
req_obj = json_pack ("{s:s, s:O, s:s, s:o, s:O,"
" s:O, s:I: s:I, s:O, s:o}",
"description",
@@ -214,8 +215,8 @@ TALER_MERCHANT_product_patch (
/* End of first group of 5 */
"taxes",
taxes,
- "total_stocked",
- (json_int_t) total_stocked,
+ "total_stock",
+ (json_int_t) total_stock,
"total_lost",
(json_int_t) total_lost,
"address",
diff --git a/src/lib/merchant_api_post_products.c b/src/lib/merchant_api_post_products.c
index 7c3f57ba..af2e4ea6 100644
--- a/src/lib/merchant_api_post_products.c
+++ b/src/lib/merchant_api_post_products.c
@@ -167,7 +167,7 @@ handle_post_products_finished (void *cls,
* applicable taxes.
* @param image base64-encoded product image
* @param taxes list of taxes paid by the merchant
- * @param total_stocked in @a units, -1 to indicate "infinite" (i.e. electronic books)
+ * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books)
* @param address where the product is in stock
* @param next_restock when the next restocking is expected to happen, 0 for unknown,
* #GNUNET_TIME_UNIT_FOREVER_ABS for 'never'.
@@ -186,7 +186,7 @@ TALER_MERCHANT_products_post (
const struct TALER_Amount *price,
const json_t *image,
const json_t *taxes,
- int64_t total_stocked,
+ int64_t total_stock,
const json_t *address,
struct GNUNET_TIME_Absolute next_restock,
TALER_MERCHANT_ProductsPostCallback cb,
@@ -195,6 +195,7 @@ TALER_MERCHANT_products_post (
struct TALER_MERCHANT_ProductsPostHandle *pph;
json_t *req_obj;
+ (void) GNUNET_TIME_round_abs (&next_restock);
req_obj = json_pack ("{s:s, s:s, s:O, s:s, s:o,"
" s:O, s:O, s:I, s:O, s:o}",
"product_id",
@@ -212,8 +213,8 @@ TALER_MERCHANT_products_post (
image,
"taxes",
taxes,
- "total_stocked",
- (json_int_t) total_stocked,
+ "total_stock",
+ (json_int_t) total_stock,
"address",
address,
"next_restock",