diff options
Diffstat (limited to 'src/include/taler_merchantdb_plugin.h')
-rw-r--r-- | src/include/taler_merchantdb_plugin.h | 170 |
1 files changed, 161 insertions, 9 deletions
diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h index 12b13e33..d06ab76c 100644 --- a/src/include/taler_merchantdb_plugin.h +++ b/src/include/taler_merchantdb_plugin.h @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014-2023 Taler Systems SA + Copyright (C) 2014-2024 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software @@ -441,6 +441,75 @@ struct TALER_MERCHANTDB_OtpDeviceDetails /** + * Typically called by `lookup_categories`. + * + * @param cls closure + * @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 + */ +typedef void +(*TALER_MERCHANTDB_CategoriesCallback)( + void *cls, + uint64_t category_id, + const char *category_name, + const json_t *category_name_i18n, + uint64_t product_count); + + +/** + * Details about a product category. + */ +struct TALER_MERCHANTDB_ProductSummary +{ + /** + * ID of the product. + */ + char *product_id; + + /** + * Description for the product. + */ + char *description; + + /** + * Translation of the @e description. + */ + json_t *description_i18n; + +}; + +/** + * Details about a product category. + */ +struct TALER_MERCHANTDB_CategoryDetails +{ + + /** + * Name of the category. + */ + char *category_name; + + /** + * Translations of the name of the category. + */ + json_t *category_name_i18n; + + /** + * Products in the category. + */ + struct TALER_MERCHANTDB_ProductSummary *products; + + /** + * Length of the @e products array. + */ + unsigned int num_products; + +}; + + +/** * Typically called by `lookup_webhooks`. * * @param cls a `json_t *` JSON array to build @@ -2876,6 +2945,24 @@ struct TALER_MERCHANTDB_Plugin /** + * Update details about a particular template. + * + * @param cls closure + * @param instance_id instance to update template for + * @param template_id template to update + * @param td update to the template details on success, can be NULL + * (in that case we only want to check if the template exists) + * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template + * does not yet exist. + */ + enum GNUNET_DB_QueryStatus + (*update_template)(void *cls, + const char *instance_id, + const char *template_id, + const struct TALER_MERCHANTDB_TemplateDetails *td); + + + /** * Delete information about an OTP device. * * @param cls closure @@ -2971,21 +3058,86 @@ struct TALER_MERCHANTDB_Plugin /** - * Update details about a particular template. + * Delete information about a product category. * * @param cls closure - * @param instance_id instance to update template for - * @param template_id template to update - * @param td update to the template details on success, can be NULL - * (in that case we only want to check if the template exists) + * @param instance_id instance to delete category of + * @param category_id identifies the category to delete + * @return DB status code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS + * if template unknown. + */ + enum GNUNET_DB_QueryStatus + (*delete_category)(void *cls, + const char *instance_id, + uint64_t category_id); + + /** + * Insert new product category. + * + * @param cls closure + * @param instance_id instance to insert OTP device for + * @param category_name name of the category + * @param category_name_i18n translations of the category name + * @param[out] category_id set to the category id on success + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*insert_category)(void *cls, + const char *instance_id, + const char *category_name, + const json_t *category_name_i18n, + uint64_t *category_id); + + + /** + * Update descriptions of a product category. + * + * @param cls closure + * @param instance_id instance to update OTP device for + * @param category_id category to update + * @param category_name name of the category + * @param category_name_i18n translations of the category name * @return database result code, #GNUNET_DB_STATUS_SUCCESS_NO_RESULTS if the template * does not yet exist. */ enum GNUNET_DB_QueryStatus - (*update_template)(void *cls, + (*update_category)(void *cls, const char *instance_id, - const char *template_id, - const struct TALER_MERCHANTDB_TemplateDetails *td); + uint64_t category_id, + const char *category_name, + const json_t *category_name_i18n); + + /** + * Lookup all of the product categories the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup OTP devices for + * @param cb function to call on all categories found + * @param cb_cls closure for @a cb + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*lookup_categories)(void *cls, + const char *instance_id, + TALER_MERCHANTDB_CategoriesCallback cb, + void *cb_cls); + + + /** + * Lookup details about product category. + * + * @param cls closure + * @param instance_id instance to lookup template for + * @param category_id category to update + * @param[out] cd set to the category details on success, can be NULL + * (in that case we only want to check if the category exists) + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*select_category)(void *cls, + const char *instance_id, + uint64_t category_id, + struct TALER_MERCHANTDB_CategoryDetails *cd); /** |