summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_product.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_get_product.c')
-rw-r--r--src/testing/testing_api_cmd_get_product.c81
1 files changed, 27 insertions, 54 deletions
diff --git a/src/testing/testing_api_cmd_get_product.c b/src/testing/testing_api_cmd_get_product.c
index ece36e71..a7d8c186 100644
--- a/src/testing/testing_api_cmd_get_product.c
+++ b/src/testing/testing_api_cmd_get_product.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -71,60 +71,31 @@ struct GetProductState
* Callback for a /get/product/$ID operation.
*
* @param cls closure for this function
- * @param hr HTTP response details
- * @param description description of the product
- * @param description_i18n Map from IETF BCP 47 language tags to localized descriptions
- * @param unit unit in which the product is measured (liters, kilograms, packages, etc.)
- * @param price the price for one @a unit of the product, zero is used to imply that
- * this product is not sold separately or that the price is not fixed and
- * must be supplied by the front-end. If non-zero, price must include
- * applicable taxes.
- * @param image base64-encoded product image
- * @param taxes list of taxes paid by the merchant
- * @param total_stock in @a units, -1 to indicate "infinite" (i.e. electronic books),
- * does NOT indicate remaining stocks, to get remaining stocks,
- * subtract @a total_sold and @a total_lost. Note that this still
- * does not then say how many of the remaining inventory are locked.
- * @param total_sold in @a units, total number of @a unit of product sold
- * @param total_lost in @a units, total number of @a unit of product lost from inventory
- * @param location 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'.
+ * @param pgr response details
*/
static void
get_product_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- const char *description,
- const json_t *description_i18n,
- const char *unit,
- const struct TALER_Amount *price,
- const char *image,
- const json_t *taxes,
- int64_t total_stock,
- uint64_t total_sold,
- uint64_t total_lost,
- const json_t *location,
- struct GNUNET_TIME_Timestamp next_restock)
+ const struct TALER_MERCHANT_ProductGetResponse *pgr)
{
struct GetProductState *gis = cls;
const struct TALER_TESTING_Command *product_cmd;
gis->igh = NULL;
- if (gis->http_status != hr->http_status)
+ if (gis->http_status != pgr->hr.http_status)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u (%d) to command %s\n",
- hr->http_status,
- (int) hr->ec,
+ pgr->hr.http_status,
+ (int) pgr->hr.ec,
TALER_TESTING_interpreter_get_current_label (gis->is));
TALER_TESTING_interpreter_fail (gis->is);
return;
}
- switch (hr->http_status)
+ switch (pgr->hr.http_status)
{
case MHD_HTTP_OK:
{
- const char **expected_description;
+ const char *expected_description;
product_cmd = TALER_TESTING_interpreter_lookup_command (
gis->is,
@@ -133,8 +104,8 @@ get_product_cb (void *cls,
TALER_TESTING_get_trait_product_description (product_cmd,
&expected_description))
TALER_TESTING_interpreter_fail (gis->is);
- if (0 != strcmp (description,
- *expected_description))
+ if (0 != strcmp (pgr->details.ok.description,
+ expected_description))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Product description does not match\n");
@@ -149,7 +120,7 @@ get_product_cb (void *cls,
TALER_TESTING_get_trait_i18n_description (product_cmd,
&expected_description_i18n))
TALER_TESTING_interpreter_fail (gis->is);
- if (1 != json_equal (description_i18n,
+ if (1 != json_equal (pgr->details.ok.description_i18n,
expected_description_i18n))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -165,9 +136,10 @@ get_product_cb (void *cls,
TALER_TESTING_get_trait_amount (product_cmd,
&expected_price))
TALER_TESTING_interpreter_fail (gis->is);
- if ((GNUNET_OK != TALER_amount_cmp_currency (price,
- expected_price)) ||
- (0 != TALER_amount_cmp (price,
+ if ((GNUNET_OK !=
+ TALER_amount_cmp_currency (&pgr->details.ok.price,
+ expected_price)) ||
+ (0 != TALER_amount_cmp (&pgr->details.ok.price,
expected_price)))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -177,14 +149,14 @@ get_product_cb (void *cls,
}
}
{
- const char **expected_image;
+ const char *expected_image;
if (GNUNET_OK !=
TALER_TESTING_get_trait_product_image (product_cmd,
&expected_image))
TALER_TESTING_interpreter_fail (gis->is);
- if (0 != strcmp (image,
- *expected_image))
+ if (0 != strcmp (pgr->details.ok.image,
+ expected_image))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Product image does not match\n");
@@ -199,7 +171,7 @@ get_product_cb (void *cls,
TALER_TESTING_get_trait_taxes (product_cmd,
&expected_taxes))
TALER_TESTING_interpreter_fail (gis->is);
- if (1 != json_equal (taxes,
+ if (1 != json_equal (pgr->details.ok.taxes,
expected_taxes))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -209,14 +181,14 @@ get_product_cb (void *cls,
}
}
{
- const char **expected_unit;
+ const char *expected_unit;
if (GNUNET_OK !=
TALER_TESTING_get_trait_product_unit (product_cmd,
&expected_unit))
TALER_TESTING_interpreter_fail (gis->is);
- if (0 != strcmp (unit,
- *expected_unit))
+ if (0 != strcmp (pgr->details.ok.unit,
+ expected_unit))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Product unit does not match\n");
@@ -231,7 +203,7 @@ get_product_cb (void *cls,
TALER_TESTING_get_trait_address (product_cmd,
&expected_location))
TALER_TESTING_interpreter_fail (gis->is);
- if (1 != json_equal (location,
+ if (1 != json_equal (pgr->details.ok.location,
expected_location))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -247,7 +219,7 @@ get_product_cb (void *cls,
TALER_TESTING_get_trait_product_stock (product_cmd,
&expected_total_stock))
TALER_TESTING_interpreter_fail (gis->is);
- if (total_stock != *expected_total_stock)
+ if (pgr->details.ok.total_stock != *expected_total_stock)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Product total stock does not match\n");
@@ -263,7 +235,7 @@ get_product_cb (void *cls,
0,
&expected_next_restock))
TALER_TESTING_interpreter_fail (gis->is);
- if (GNUNET_TIME_timestamp_cmp (next_restock,
+ if (GNUNET_TIME_timestamp_cmp (pgr->details.ok.next_restock,
!=,
*expected_next_restock))
{
@@ -302,7 +274,8 @@ get_product_run (void *cls,
struct GetProductState *gis = cls;
gis->is = is;
- gis->igh = TALER_MERCHANT_product_get (is->ctx,
+ gis->igh = TALER_MERCHANT_product_get (TALER_TESTING_interpreter_get_context (
+ is),
gis->merchant_url,
gis->product_id,
&get_product_cb,