diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-pos.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-pos.c b/src/backend/taler-merchant-httpd_private-get-pos.c index f8f84400..6221fc08 100644 --- a/src/backend/taler-merchant-httpd_private-get-pos.c +++ b/src/backend/taler-merchant-httpd_private-get-pos.c @@ -41,6 +41,40 @@ struct Context /** + * Add category to the @e ca array. + * + * @param cls a `struct Context` with JSON arrays to build + * @param category_id ID of the category + * @param category_name name of the category + * @param category_name_i18n translations of the @a category_name + * @param product_count number of products in the category + */ +static void +add_category ( + void *cls, + uint64_t category_id, + const char *category_name, + const json_t *category_name_i18n, + uint64_t product_count) +{ + struct Context *ctx = cls; + + (void) product_count; + GNUNET_assert ( + 0 == + json_array_append_new ( + ctx->ca, + GNUNET_JSON_PACK ( + GNUNET_JSON_pack_uint64 ("id", + category_id), + GNUNET_JSON_pack_object_incref ("name_i18n", + (json_t *) category_name_i18n), + GNUNET_JSON_pack_string ("name", + category_name)))); +} + + +/** * Add product details to our JSON array. * * @param cls a `struct Context` with JSON arrays to build @@ -134,6 +168,20 @@ TMH_private_get_pos (const struct TMH_RequestHandler *rh, 0), GNUNET_JSON_pack_string ("name", "default")))); + qs = TMH_db->lookup_categories (TMH_db->cls, + hc->instance->settings.id, + &add_category, + &ctx); + if (0 > qs) + { + GNUNET_break (0); + json_decref (ctx.pa); + json_decref (ctx.ca); + return TALER_MHD_reply_with_error (connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + NULL); + } qs = TMH_db->lookup_all_products (TMH_db->cls, hc->instance->settings.id, &add_product, |