summaryrefslogtreecommitdiff
path: root/src/testing/testing_api_cmd_post_products.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_api_cmd_post_products.c')
-rw-r--r--src/testing/testing_api_cmd_post_products.c66
1 files changed, 38 insertions, 28 deletions
diff --git a/src/testing/testing_api_cmd_post_products.c b/src/testing/testing_api_cmd_post_products.c
index be3c3071..c841f1b1 100644
--- a/src/testing/testing_api_cmd_post_products.c
+++ b/src/testing/testing_api_cmd_post_products.c
@@ -35,7 +35,7 @@ struct PostProductsState
{
/**
- * Handle for a "GET product" request.
+ * Handle for a "POST /products" request.
*/
struct TALER_MERCHANT_ProductsPostHandle *iph;
@@ -95,6 +95,11 @@ struct PostProductsState
json_t *address;
/**
+ * Minimum age requirement to use for the product.
+ */
+ unsigned int minimum_age;
+
+ /**
* when the next restocking is expected to happen, 0 for unknown,
*/
struct GNUNET_TIME_Timestamp next_restock;
@@ -168,20 +173,22 @@ post_products_run (void *cls,
struct PostProductsState *pis = cls;
pis->is = is;
- pis->iph = TALER_MERCHANT_products_post (is->ctx,
- pis->merchant_url,
- pis->product_id,
- pis->description,
- pis->description_i18n,
- pis->unit,
- &pis->price,
- pis->image,
- pis->taxes,
- pis->total_stock,
- pis->address,
- pis->next_restock,
- &post_products_cb,
- pis);
+ pis->iph = TALER_MERCHANT_products_post2 (
+ TALER_TESTING_interpreter_get_context (is),
+ pis->merchant_url,
+ pis->product_id,
+ pis->description,
+ pis->description_i18n,
+ pis->unit,
+ &pis->price,
+ pis->image,
+ pis->taxes,
+ pis->total_stock,
+ pis->address,
+ pis->next_restock,
+ pis->minimum_age,
+ &post_products_cb,
+ pis);
GNUNET_assert (NULL != pis->iph);
}
@@ -196,7 +203,7 @@ post_products_run (void *cls,
* @param index index number of the object to extract.
* @return #GNUNET_OK on success
*/
-static int
+static enum GNUNET_GenericReturnValue
post_products_traits (void *cls,
const void **ret,
const char *trait,
@@ -204,18 +211,17 @@ post_products_traits (void *cls,
{
struct PostProductsState *pps = cls;
struct TALER_TESTING_Trait traits[] = {
- TALER_TESTING_make_trait_product_description (&pps->description),
+ TALER_TESTING_make_trait_product_description (pps->description),
TALER_TESTING_make_trait_i18n_description (pps->description_i18n),
- TALER_TESTING_make_trait_product_unit (&pps->unit),
+ TALER_TESTING_make_trait_product_unit (pps->unit),
TALER_TESTING_make_trait_amount (&pps->price),
- TALER_TESTING_make_trait_product_image (
- (const char **) &pps->image),
+ TALER_TESTING_make_trait_product_image (pps->image),
TALER_TESTING_make_trait_taxes (pps->taxes),
TALER_TESTING_make_trait_product_stock (&pps->total_stock),
TALER_TESTING_make_trait_address (pps->address),
TALER_TESTING_make_trait_timestamp (0,
&pps->next_restock),
- TALER_TESTING_make_trait_product_id (&pps->product_id),
+ TALER_TESTING_make_trait_product_id (pps->product_id),
TALER_TESTING_trait_end (),
};
@@ -265,6 +271,7 @@ TALER_TESTING_cmd_merchant_post_products2 (
const char *image,
json_t *taxes,
int64_t total_stock,
+ uint32_t minimum_age,
json_t *address,
struct GNUNET_TIME_Timestamp next_restock,
unsigned int http_status)
@@ -288,6 +295,7 @@ TALER_TESTING_cmd_merchant_post_products2 (
pis->image = GNUNET_strdup (image);
pis->taxes = taxes; /* ownership taken */
pis->total_stock = total_stock;
+ pis->minimum_age = minimum_age;
pis->address = address; /* ownership taken */
pis->next_restock = next_restock;
{
@@ -305,12 +313,13 @@ TALER_TESTING_cmd_merchant_post_products2 (
struct TALER_TESTING_Command
-TALER_TESTING_cmd_merchant_post_products (const char *label,
- const char *merchant_url,
- const char *product_id,
- const char *description,
- const char *price,
- unsigned int http_status)
+TALER_TESTING_cmd_merchant_post_products (
+ const char *label,
+ const char *merchant_url,
+ const char *product_id,
+ const char *description,
+ const char *price,
+ unsigned int http_status)
{
return TALER_TESTING_cmd_merchant_post_products2 (
label,
@@ -322,7 +331,8 @@ TALER_TESTING_cmd_merchant_post_products (const char *label,
price,
"",
json_array (),
- 4,
+ 4, /* total stock */
+ 0, /* minimum age */
json_pack ("{s:s}", "street", "my street"),
GNUNET_TIME_UNIT_ZERO_TS,
http_status);