summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_get_products.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_get_products.c')
-rw-r--r--src/testing/testing_api_cmd_get_products.c85
1 files changed, 45 insertions, 40 deletions
diff --git a/src/testing/testing_api_cmd_get_products.c b/src/testing/testing_api_cmd_get_products.c
index 190bb4c1..97a105be 100644
--- a/src/testing/testing_api_cmd_get_products.c
+++ b/src/testing/testing_api_cmd_get_products.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,17 +71,14 @@ struct GetProductsState
* Callback for a GET /products operation.
*
* @param cls closure for this function
- * @param hr HTTP response details
- * @param products_length length of the @a products array
- * @param products array of products the requested instance offers
+ * @param gpr response details
*/
static void
get_products_cb (void *cls,
- const struct TALER_MERCHANT_HttpResponse *hr,
- unsigned int products_length,
- const struct TALER_MERCHANT_InventoryEntry products[])
+ const struct TALER_MERCHANT_GetProductsResponse *gpr)
{
struct GetProductsState *gis = cls;
+ const struct TALER_MERCHANT_HttpResponse *hr = &gpr->hr;
gis->igh = NULL;
if (gis->http_status != hr->http_status)
@@ -97,40 +94,47 @@ get_products_cb (void *cls,
switch (hr->http_status)
{
case MHD_HTTP_OK:
- if (products_length != gis->products_length)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Length of products found does not match\n");
- TALER_TESTING_interpreter_fail (gis->is);
- return;
- }
- for (unsigned int i = 0; i < gis->products_length; ++i)
- {
- const struct TALER_TESTING_Command *product_cmd;
-
- product_cmd = TALER_TESTING_interpreter_lookup_command (
- gis->is,
- gis->products[i]);
+ unsigned int products_length
+ = gpr->details.ok.products_length;
+ const struct TALER_MERCHANT_InventoryEntry *products
+ = gpr->details.ok.products;
+ if (products_length != gis->products_length)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Length of products found does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ for (unsigned int i = 0; i < gis->products_length; ++i)
{
- const char **product_id;
+ const struct TALER_TESTING_Command *product_cmd;
+
+ product_cmd = TALER_TESTING_interpreter_lookup_command (
+ gis->is,
+ gis->products[i]);
- if (GNUNET_OK !=
- TALER_TESTING_get_trait_product_id (product_cmd,
- &product_id))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Could not fetch product id\n");
- TALER_TESTING_interpreter_fail (gis->is);
- return;
- }
- if (0 != strcmp (products[i].product_id,
- *product_id))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Product id does not match\n");
- TALER_TESTING_interpreter_fail (gis->is);
- return;
+ const char *product_id;
+
+ if (GNUNET_OK !=
+ TALER_TESTING_get_trait_product_id (product_cmd,
+ &product_id))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not fetch product id\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
+ if (0 != strcmp (products[i].product_id,
+ product_id))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Product id does not match\n");
+ TALER_TESTING_interpreter_fail (gis->is);
+ return;
+ }
}
}
}
@@ -166,10 +170,11 @@ get_products_run (void *cls,
struct GetProductsState *gis = cls;
gis->is = is;
- gis->igh = TALER_MERCHANT_products_get (is->ctx,
- gis->merchant_url,
- &get_products_cb,
- gis);
+ gis->igh = TALER_MERCHANT_products_get (
+ TALER_TESTING_interpreter_get_context (is),
+ gis->merchant_url,
+ &get_products_cb,
+ gis);
GNUNET_assert (NULL != gis->igh);
}