merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit be0fec7f89952f07765cb1010f0ff619177c24a0
parent 73c7f55f10735fc3c8ca13820a2d7eb8e5d295d7
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 26 Dec 2025 10:55:21 +0100

DB API boilerplate for merchant-0028.sql

Diffstat:
Msrc/backenddb/Makefile.am | 18++++++++++++++++++
Asrc/backenddb/merchant-0028.sql | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_delete_money_pot.c | 34++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_delete_money_pot.h | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_delete_product_group.c | 33+++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_delete_product_group.h | 42++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_delete_report.c | 34++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_delete_report.h | 42++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_money_pot.c | 38++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_money_pot.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_product_group.c | 37+++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_product_group.h | 47+++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_report.c | 42++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_insert_report.h | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_lookup_reports_pending.c | 33+++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_lookup_reports_pending.h | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_money_pot.c | 36++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_money_pot.h | 48++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_money_pots.c | 37+++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_money_pots.h | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_product_groups.c | 37+++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_product_groups.h | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_report.c | 43+++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_report.h | 65+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_reports.c | 36++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_select_reports.h | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_money_pot.c | 40++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_money_pot.h | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_product_group.c | 38++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_product_group.h | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_report.c | 42++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_report.h | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_report_status.c | 38++++++++++++++++++++++++++++++++++++++
Asrc/backenddb/pg_update_report_status.h | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/backenddb/plugin_merchantdb_postgres.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/include/taler_merchantdb_plugin.h | 454+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
36 files changed, 2018 insertions(+), 18 deletions(-)

diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am @@ -44,6 +44,7 @@ sql_DATA = \ merchant-0025.sql \ merchant-0026.sql \ merchant-0027.sql \ + merchant-0028.sql \ drop.sql BUILT_SOURCES = \ @@ -147,6 +148,22 @@ libtaler_plugin_merchantdb_postgres_la_SOURCES = \ pg_solve_mfa_challenge.h pg_solve_mfa_challenge.c \ pg_update_mfa_challenge.h pg_update_mfa_challenge.c \ pg_create_mfa_challenge.h pg_create_mfa_challenge.c \ + pg_insert_report.h pg_insert_report.c \ + pg_delete_report.h pg_delete_report.c \ + pg_update_report.h pg_update_report.c \ + pg_select_reports.h pg_select_reports.c \ + pg_lookup_reports_pending.h pg_lookup_reports_pending.c \ + pg_update_report_status.h pg_update_report_status.c \ + pg_select_report.h pg_select_report.c \ + pg_insert_product_group.h pg_insert_product_group.c \ + pg_delete_product_group.h pg_delete_product_group.c \ + pg_update_product_group.h pg_update_product_group.c \ + pg_select_product_groups.h pg_select_product_groups.c \ + pg_insert_money_pot.h pg_insert_money_pot.c \ + pg_delete_money_pot.h pg_delete_money_pot.c \ + pg_update_money_pot.h pg_update_money_pot.c \ + pg_select_money_pots.h pg_select_money_pots.c \ + pg_select_money_pot.h pg_select_money_pot.c \ pg_lock_product.h pg_lock_product.c \ pg_lookup_account.h pg_lookup_account.c \ pg_lookup_all_products.h pg_lookup_all_products.c \ @@ -253,6 +270,7 @@ libtaler_plugin_merchantdb_postgres_la_LIBADD = \ $(LTLIBINTL) libtaler_plugin_merchantdb_postgres_la_LDFLAGS = \ $(TALER_PLUGIN_LDFLAGS) \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalerexchange \ -ltalerpq \ -ltalerutil \ diff --git a/src/backenddb/merchant-0028.sql b/src/backenddb/merchant-0028.sql @@ -0,0 +1,124 @@ +-- +-- This file is part of TALER +-- Copyright (C) 2025 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 published by the Free Software +-- Foundation; either version 3, or (at your option) any later version. +-- +-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY +-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +-- A PARTICULAR PURPOSE. See the GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License along with +-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + +-- @file merchant-0028.sql +-- @brief Add tables for notifications, product groups and money pots +-- @author Christian Grothoff + +BEGIN; + +-- Check patch versioning is in place. +SELECT _v.register_patch('merchant-0028', NULL, NULL); + +SET search_path TO merchant; + +CREATE TABLE merchant_reports + (report_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY + ,merchant_serial BIGINT NOT NULL + REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE + ,report_program_section TEXT NOT NULL + ,report_description TEXT NOT NULL + ,mime_type TEXT NOT NULL + ,data_source TEXT NOT NULL + ,target_address TEXT NOT NULL + ,frequency INT8 NOT NULL + ,frequency_shift INT8 NOT NULL + ,next_transmission INT8 NOT NULL + ,last_error_code INT4 DEFAULT NULL + ,last_error_detail TEXT DEFAULT NULL + ); +COMMENT ON TABLE merchant_reports + IS 'Specifies where we should send periodic reports about instance activities'; +COMMENT ON COLUMN merchant_reports.report_serial + IS 'Unique identifier for the report'; +COMMENT ON COLUMN merchant_reports.merchant_serial + IS 'Which instance the report is about'; +COMMENT ON COLUMN merchant_reports.report_program_section + IS 'Which helper program (configuration section) to use to transmit the report'; +COMMENT ON COLUMN merchant_reports.mime_type + IS 'Mime-type to request from the backend for the transmission'; +COMMENT ON COLUMN merchant_reports.data_source + IS 'Relative URL of the instance for a GET request to request data to send'; +COMMENT ON COLUMN merchant_reports.target_address + IS 'Address to which the report should be sent'; +COMMENT ON COLUMN merchant_reports.frequency + IS 'Relative time with the desired report frequency'; +COMMENT ON COLUMN merchant_reports.frequency_shift + IS 'Relative time (possibly negative!) by which to offset the actual transmission from the frequency multiple'; +COMMENT ON COLUMN merchant_reports.next_transmission + IS 'Absolute time at which we should do the next transmission'; +COMMENT ON COLUMN merchant_reports.last_error_code + IS 'ErrorCode of the last attempted transmission, NULL on success'; +COMMENT ON COLUMN merchant_reports.last_error_detail + IS 'Additional human-readable text explaining errors from the last transmission attempt (for diagnostics), NULL on success'; + + +CREATE TABLE merchant_product_group + (product_group_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY + ,merchant_serial BIGINT NOT NULL + REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE + ,product_group_name TEXT NOT NULL + ,product_group_description TEXT NOT NULL + ,UNIQUE (merchant_serial,product_group_name) + ); +COMMENT ON TABLE merchant_product_group + IS 'Specifies a product group'; +COMMENT ON COLUMN merchant_product_group.product_group_serial + IS 'Unique identifier for the group'; +COMMENT ON COLUMN merchant_product_group.merchant_serial + IS 'Merchant instance using the group'; +COMMENT ON COLUMN merchant_product_group.product_group_name + IS 'Name for the group'; +COMMENT ON COLUMN merchant_product_group.product_group_description + IS 'Human-readable description for the group'; + + +ALTER TABLE merchant_inventory + ADD COLUMN product_group_serial INT8 DEFAULT (NULL) + REFERENCES merchant_product_group (product_group_serial) + ON DELETE SET NULL, + ADD COLUMN price_is_net BOOL DEFAULT (FALSE); + +COMMENT ON COLUMN merchant_inventory.product_group_serial + IS 'Specifies the product group a given product is a member of. If NULL, the product is in the __default__ group'; +COMMENT ON COLUMN merchant_inventory.price_is_net + IS 'If true, the price given is the net price; if false, it is the gross price.'; + + +CREATE TABLE merchant_money_pot + (money_pot_serial BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY + ,merchant_serial BIGINT NOT NULL + REFERENCES merchant_instances (merchant_serial) ON DELETE CASCADE + ,money_pot_name TEXT NOT NULL + ,money_pot_description TEXT NOT NULL + ,pot_total taler_amount_currency NOT NULL + ,UNIQUE (merchant_serial,money_pot_name) + ); +COMMENT ON TABLE merchant_money_pot + IS 'Accounting construct for tracking finances by groups such as net income, taxes, tips to be paid to staff, etc.'; +COMMENT ON COLUMN merchant_money_pot.money_pot_serial + IS 'Unique identifier for the money pot'; +COMMENT ON COLUMN merchant_money_pot.merchant_serial + IS 'Merchant instance using the group'; +COMMENT ON COLUMN merchant_money_pot.money_pot_name + IS 'Name for the money pot'; +COMMENT ON COLUMN merchant_money_pot.money_pot_description + IS 'Human-readable description for the money pot'; +COMMENT ON COLUMN merchant_money_pot.pot_total + IS 'Total amount in the pot'; + + + +COMMIT; diff --git a/src/backenddb/pg_delete_money_pot.c b/src/backenddb/pg_delete_money_pot.c @@ -0,0 +1,34 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_money_pot.c + * @brief Implementation of the delete_money_pot function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_delete_money_pot.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_delete_money_pot (void *cls, + const char *instance_id, + uint64_t money_pot_id) +{ +} diff --git a/src/backenddb/pg_delete_money_pot.h b/src/backenddb/pg_delete_money_pot.h @@ -0,0 +1,41 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_money_pot.h + * @brief implementation of the delete_money_pot function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_DELETE_MONEY_POT_H +#define PG_DELETE_MONEY_POT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Delete information about a money pot. + * + * @param cls closure + * @param instance_id instance to delete token family of + * @param money_pot_id serial number of the pot to delete + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_delete_money_pot (void *cls, + const char *instance_id, + uint64_t money_pot_id); + +#endif diff --git a/src/backenddb/pg_delete_product_group.c b/src/backenddb/pg_delete_product_group.c @@ -0,0 +1,33 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_product_group.c + * @brief Implementation of the delete_product_group function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_delete_product_group.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_delete_product_group (void *cls, + const char *instance_id, + uint64_t product_group_id) +{ +} diff --git a/src/backenddb/pg_delete_product_group.h b/src/backenddb/pg_delete_product_group.h @@ -0,0 +1,42 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_product_group.h + * @brief implementation of the delete_product_group function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_DELETE_PRODUCT_GROUP_H +#define PG_DELETE_PRODUCT_GROUP_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Delete information about a product group. + * + * @param cls closure + * @param instance_id instance to delete product group of + * @param product_group_id serial number of the group to delete + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_delete_product_group (void *cls, + const char *instance_id, + uint64_t product_group_id); + +#endif diff --git a/src/backenddb/pg_delete_report.c b/src/backenddb/pg_delete_report.c @@ -0,0 +1,34 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_report.c + * @brief Implementation of the delete_report function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_delete_report.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_delete_report (void *cls, + const char *instance_id, + uint64_t report_id) +{ +} diff --git a/src/backenddb/pg_delete_report.h b/src/backenddb/pg_delete_report.h @@ -0,0 +1,42 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_delete_report.h + * @brief implementation of the delete_report function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_DELETE_REPORT_H +#define PG_DELETE_REPORT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Delete information about a report. + * + * @param cls closure + * @param instance_id instance to delete report of + * @param report_id serial number of the pot to delete + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_delete_report (void *cls, + const char *instance_id, + uint64_t report_id); + +#endif diff --git a/src/backenddb/pg_insert_money_pot.c b/src/backenddb/pg_insert_money_pot.c @@ -0,0 +1,38 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_money_pot.c + * @brief Implementation of the insert_money_pot function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_insert_money_pot.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_insert_money_pot ( + void *cls, + const char *instance_id, + const char *name, + const char *description, + const char *pod_currency, + uint64_t *money_pot_id) +{ +} diff --git a/src/backenddb/pg_insert_money_pot.h b/src/backenddb/pg_insert_money_pot.h @@ -0,0 +1,48 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_money_pot.h + * @brief implementation of the insert_money_pot function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_INSERT_MONEY_POT_H +#define PG_INSERT_MONEY_POT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Insert details about a particular pot. + * + * @param cls closure + * @param instance_id instance to insert pot for + * @param name set to name of the pot + * @param description set to description of the pot + * @param pod_currency the expected currency in the pot + * @param[out] money_pot_id serial number of the new pot + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_insert_money_pot ( + void *cls, + const char *instance_id, + const char *name, + const char *description, + const char *pod_currency, + uint64_t *money_pot_id); + +#endif diff --git a/src/backenddb/pg_insert_product_group.c b/src/backenddb/pg_insert_product_group.c @@ -0,0 +1,37 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_product_group.c + * @brief Implementation of the insert_product_group function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_insert_product_group.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_insert_product_group ( + void *cls, + const char *instance_id, + const char *name, + const char *description, + uint64_t *product_group_id) +{ +} diff --git a/src/backenddb/pg_insert_product_group.h b/src/backenddb/pg_insert_product_group.h @@ -0,0 +1,47 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_product_group.h + * @brief implementation of the insert_product_group function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_INSERT_PRODUCT_GROUP_H +#define PG_INSERT_PRODUCT_GROUP_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Insert details about a particular product group. + * + * @param cls closure + * @param instance_id instance to insert group for + * @param name set to name of the group + * @param description set to description of the group + * @param[out] product_group_id serial number of the new group + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_insert_product_group ( + void *cls, + const char *instance_id, + const char *name, + const char *description, + uint64_t *product_group_id); + +#endif diff --git a/src/backenddb/pg_insert_report.c b/src/backenddb/pg_insert_report.c @@ -0,0 +1,42 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_report.c + * @brief Implementation of the insert_report function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_insert_report.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_insert_report ( + void *cls, + const char *instance_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift, + uint64_t *report_id) +{ +} diff --git a/src/backenddb/pg_insert_report.h b/src/backenddb/pg_insert_report.h @@ -0,0 +1,61 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_insert_report.h + * @brief implementation of the insert_report function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_INSERT_REPORT_H +#define PG_INSERT_REPORT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Insert details about a particular pot. + * + * @param cls closure + * @param instance_id instance to insert pot for + * @param report_program_section configuration section of program + * for report generation + * @param report_description text describing the report + * @param mime_type mime type to request from the @a data_source + * @param data_source relative URL (to instance base URL) + * to request report data from + * @param target_address where to send report data + * @param frequency report frequency + * @param frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + * @param[out] report_id serial number of the new pot + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_insert_report ( + void *cls, + const char *instance_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift, + uint64_t *report_id); + + +#endif diff --git a/src/backenddb/pg_lookup_reports_pending.c b/src/backenddb/pg_lookup_reports_pending.c @@ -0,0 +1,33 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_lookup_reports_pending.c + * @brief Implementation of the lookup_reports_pending function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_lookup_reports_pending.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_lookup_reports_pending (void *cls, + TALER_MERCHANTDB_ReportsPendingCallback cb, + void *cb_cls) +{ +} diff --git a/src/backenddb/pg_lookup_reports_pending.h b/src/backenddb/pg_lookup_reports_pending.h @@ -0,0 +1,41 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_lookup_reports_pending.h + * @brief implementation of the lookup_reports_pending function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_LOOKUP_REPORTS_PENDING_H +#define PG_LOOKUP_REPORTS_PENDING_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Lookup all of the reports pending for the given backend. + * + * @param cls closure + * @param cb function to call on all reports found + * @param cb_cls closure for @a cb + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_lookup_reports_pending (void *cls, + TALER_MERCHANTDB_ReportsPendingCallback cb, + void *cb_cls); + +#endif diff --git a/src/backenddb/pg_select_money_pot.c b/src/backenddb/pg_select_money_pot.c @@ -0,0 +1,36 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_money_pot.c + * @brief Implementation of the select_money_pot function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_money_pot.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_select_money_pot (void *cls, + const char *instance_id, + uint64_t money_pot_id, + char **name, + char **description, + struct TALER_Amount *pot_total) +{ +} diff --git a/src/backenddb/pg_select_money_pot.h b/src/backenddb/pg_select_money_pot.h @@ -0,0 +1,48 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_money_pot.h + * @brief implementation of the select_money_pot function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_MONEY_POT_H +#define PG_SELECT_MONEY_POT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Lookup details about a particular money pot. + * + * @param cls closure + * @param instance_id instance to lookup token family for + * @param money_pot_id serial number of the pot to lookup + * @param [out] name set to name of the pot + * @param[out] description set to description of the pot + * @param[out] pot_total set to amount currently in the pot + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_money_pot (void *cls, + const char *instance_id, + uint64_t money_pot_id, + char **name, + char **description, + struct TALER_Amount *pot_total); + +#endif diff --git a/src/backenddb/pg_select_money_pots.c b/src/backenddb/pg_select_money_pots.c @@ -0,0 +1,37 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_money_pots.c + * @brief Implementation of the select_money_pots function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_money_pots.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_select_money_pots (void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_MoneyPotsCallback cb, + void *cb_cls) +{ +} diff --git a/src/backenddb/pg_select_money_pots.h b/src/backenddb/pg_select_money_pots.h @@ -0,0 +1,49 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_money_pots.h + * @brief implementation of the select_money_pots function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_MONEY_POTS_H +#define PG_SELECT_MONEY_POTS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Lookup all of the money pots the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup token families for + * @param limit number of entries to return, negative for descending in execution time, + * positive for ascending in execution time + * @param offset expected_transfer_serial number of the transfer we want to offset from + * @param cb function to call on all money pots found + * @param cb_cls closure for @a cb + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_money_pots (void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_MoneyPotsCallback cb, + void *cb_cls); + +#endif diff --git a/src/backenddb/pg_select_product_groups.c b/src/backenddb/pg_select_product_groups.c @@ -0,0 +1,37 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_product_groups.c + * @brief Implementation of the select_product_groups function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_product_groups.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_select_product_groups (void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_ProductGroupsCallback cb, + void *cb_cls) +{ +} diff --git a/src/backenddb/pg_select_product_groups.h b/src/backenddb/pg_select_product_groups.h @@ -0,0 +1,49 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_product_groups.h + * @brief implementation of the select_product_groups function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_PRODUCT_GROUPS_H +#define PG_SELECT_PRODUCT_GROUPS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Lookup all of the product groups the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup product groups for + * @param limit number of entries to return, negative for descending in execution time, + * positive for ascending in execution time + * @param offset expected_transfer_serial number of the transfer we want to offset from + * @param cb function to call on all groups found + * @param cb_cls closure for @a cb + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_product_groups (void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_ProductGroupsCallback cb, + void *cb_cls); + + +#endif diff --git a/src/backenddb/pg_select_report.c b/src/backenddb/pg_select_report.c @@ -0,0 +1,43 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_report.c + * @brief Implementation of the select_report function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_report.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_select_report (void *cls, + const char *instance_id, + uint64_t report_id, + char **report_program_section, + char **report_description, + char **mime_type, + char **data_source, + char **target_address, + struct GNUNET_TIME_Relative *frequency, + struct GNUNET_TIME_Relative *frequency_shift, + struct GNUNET_TIME_Absolute *next_transmission, + enum TALER_ErrorCode *last_error_code, + char **last_error_detail) +{ +} diff --git a/src/backenddb/pg_select_report.h b/src/backenddb/pg_select_report.h @@ -0,0 +1,65 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_report.h + * @brief implementation of the select_report function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_REPORT_H +#define PG_SELECT_REPORT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Lookup details about a particular report. + * + * @param cls closure + * @param instance_id instance to lookup reports for + * @param report_id serial number of the report to lookup + * @param[out] report_program_section configuration section of program + * for report generation + * @param[out] report_description text describing the report + * @param[out] mime_type mime type to request from the @a data_source + * @param[out] data_source relative URL (to instance base URL) + * to request report data from + * @param[out] target_address where to send report data + * @param[out] frequency report frequency + * @param[out] frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + * @param[out] next_transmission when will the report be generated next + * @param[out] last_error_code status of the last report + * @param[out] last_error_detail details about failures of last generation + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_report (void *cls, + const char *instance_id, + uint64_t report_id, + char **report_program_section, + char **report_description, + char **mime_type, + char **data_source, + char **target_address, + struct GNUNET_TIME_Relative *frequency, + struct GNUNET_TIME_Relative *frequency_shift, + struct GNUNET_TIME_Absolute *next_transmission, + enum TALER_ErrorCode *last_error_code, + char **last_error_detail); + +#endif diff --git a/src/backenddb/pg_select_reports.c b/src/backenddb/pg_select_reports.c @@ -0,0 +1,36 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_reports.c + * @brief Implementation of the select_reports function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_select_reports.h" +#include "pg_helper.h" + +enum GNUNET_DB_QueryStatus +TMH_PG_select_reports (void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_ReportsCallback cb, + void *cb_cls) +{ +} diff --git a/src/backenddb/pg_select_reports.h b/src/backenddb/pg_select_reports.h @@ -0,0 +1,49 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_select_reports.h + * @brief implementation of the select_reports function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_SELECT_REPORTS_H +#define PG_SELECT_REPORTS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Lookup all of the reports the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup reports for + * @param limit number of entries to return, negative for descending in execution time, + * positive for ascending in execution time + * @param offset expected_transfer_serial number of the transfer we want to offset from + * @param cb function to call on all reports found + * @param cb_cls closure for @a cb + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_select_reports (void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_ReportsCallback cb, + void *cb_cls); + + +#endif diff --git a/src/backenddb/pg_update_money_pot.c b/src/backenddb/pg_update_money_pot.c @@ -0,0 +1,40 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_money_pot.c + * @brief Implementation of the update_money_pot function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_update_money_pot.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_update_money_pot ( + void *cls, + const char *instance_id, + uint64_t money_pot_id, + const char *name, + const char *description, + const struct TALER_Amount *old_pot_total, + const struct TALER_Amount *new_pot_total, + bool *conflict) +{ +} diff --git a/src/backenddb/pg_update_money_pot.h b/src/backenddb/pg_update_money_pot.h @@ -0,0 +1,53 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_money_pot.h + * @brief implementation of the update_money_pot function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_UPDATE_MONEY_POT_H +#define PG_UPDATE_MONEY_POT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Update details about a particular money pot. + * + * @param cls closure + * @param instance_id instance to update token family for + * @param money_pot_id serial number of the pot to delete + * @param name set to name of the pot + * @param description set to description of the pot + * @param old_pot_total amount expected currently in the pot + * @param new_pot_total new amount in the pot + * @param[out] conflict set to true if @a old_pot_total does not match + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_update_money_pot ( + void *cls, + const char *instance_id, + uint64_t money_pot_id, + const char *name, + const char *description, + const struct TALER_Amount *old_pot_total, + const struct TALER_Amount *new_pot_total, + bool *conflict); + + +#endif diff --git a/src/backenddb/pg_update_product_group.c b/src/backenddb/pg_update_product_group.c @@ -0,0 +1,38 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_product_group.c + * @brief Implementation of the update_product_group function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_update_product_group.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_update_product_group ( + void *cls, + const char *instance_id, + uint64_t product_group_id, + const char *name, + const char *description, + bool *conflict) +{ +} diff --git a/src/backenddb/pg_update_product_group.h b/src/backenddb/pg_update_product_group.h @@ -0,0 +1,50 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_product_group.h + * @brief implementation of the update_product_group function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_UPDATE_PRODUCT_GROUP_H +#define PG_UPDATE_PRODUCT_GROUP_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Update details about a particular product group. + * + * @param cls closure + * @param instance_id instance to update product group for + * @param product_group_id serial number of the group to update + * @param name set to name of the group + * @param description set to description of the group + * @param[out] conflict set to true if @a name is already used + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_update_product_group ( + void *cls, + const char *instance_id, + uint64_t product_group_id, + const char *name, + const char *description, + bool *conflict); + + +#endif diff --git a/src/backenddb/pg_update_report.c b/src/backenddb/pg_update_report.c @@ -0,0 +1,42 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_report.c + * @brief Implementation of the update_report function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_update_report.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_update_report ( + void *cls, + const char *instance_id, + uint64_t report_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift) +{ +} diff --git a/src/backenddb/pg_update_report.h b/src/backenddb/pg_update_report.h @@ -0,0 +1,60 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_report.h + * @brief implementation of the update_report function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_UPDATE_REPORT_H +#define PG_UPDATE_REPORT_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + + +/** + * Update details about a particular report. + * + * @param cls closure + * @param instance_id instance to update report for + * @param report_id serial number of the report to update + * @param report_program_section configuration section of program + * for report generation + * @param report_description text describing the report + * @param mime_type mime type to request from the @a data_source + * @param data_source relative URL (to instance base URL) + * to request report data from + * @param target_address where to send report data + * @param frequency report frequency + * @param frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_update_report ( + void *cls, + const char *instance_id, + uint64_t report_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift); + +#endif diff --git a/src/backenddb/pg_update_report_status.c b/src/backenddb/pg_update_report_status.c @@ -0,0 +1,38 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_report_status.c + * @brief Implementation of the update_report_status function for Postgres + * @author Christian Grothoff + */ +#include "platform.h" +#include <taler/taler_error_codes.h> +#include <taler/taler_dbevents.h> +#include <taler/taler_pq_lib.h> +#include "pg_update_report_status.h" +#include "pg_helper.h" + + +enum GNUNET_DB_QueryStatus +TMH_PG_update_report_status ( + void *cls, + const char *instance_id, + uint64_t report_id, + struct GNUNET_TIME_Absolute next_transmission, + enum TALER_ErrorCode last_error_code, + const char *last_error_detail) +{ +} diff --git a/src/backenddb/pg_update_report_status.h b/src/backenddb/pg_update_report_status.h @@ -0,0 +1,49 @@ +/* + This file is part of TALER + Copyright (C) 2025 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 published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + TALER is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> + */ +/** + * @file backenddb/pg_update_report_status.h + * @brief implementation of the update_report_status function for Postgres + * @author Christian Grothoff + */ +#ifndef PG_UPDATE_REPORT_STATUS_H +#define PG_UPDATE_REPORT_STATUS_H + +#include <taler/taler_util.h> +#include <taler/taler_json_lib.h> +#include "taler_merchantdb_plugin.h" + +/** + * Update transmission status about a particular report. + * + * @param cls closure + * @param instance_id instance to update report for + * @param report_id serial number of the pot to update + * @param next_tranmission when should the report be generated next + * @param last_error_code #TALER_EC_NONE on success + * @param last_error_detail NULL on success + * @return database result code + */ +enum GNUNET_DB_QueryStatus +TMH_PG_update_report_status ( + void *cls, + const char *instance_id, + uint64_t report_id, + struct GNUNET_TIME_Absolute next_transmission, + enum TALER_ErrorCode last_error_code, + const char *last_error_detail); + + +#endif diff --git a/src/backenddb/plugin_merchantdb_postgres.c b/src/backenddb/plugin_merchantdb_postgres.c @@ -59,6 +59,22 @@ #include "pg_insert_unit.h" #include "pg_update_unit.h" #include "pg_delete_unit.h" +#include "pg_insert_report.h" +#include "pg_delete_report.h" +#include "pg_update_report.h" +#include "pg_select_reports.h" +#include "pg_lookup_reports_pending.h" +#include "pg_update_report_status.h" +#include "pg_select_report.h" +#include "pg_insert_product_group.h" +#include "pg_delete_product_group.h" +#include "pg_update_product_group.h" +#include "pg_select_product_groups.h" +#include "pg_insert_money_pot.h" +#include "pg_delete_money_pot.h" +#include "pg_update_money_pot.h" +#include "pg_select_money_pots.h" +#include "pg_select_money_pot.h" #include "pg_update_wirewatch_progress.h" #include "pg_select_wirewatch_accounts.h" #include "pg_select_open_transfers.h" @@ -672,6 +688,38 @@ libtaler_plugin_merchantdb_postgres_init (void *cls) = &TMH_PG_delete_token_family; plugin->update_token_family = &TMH_PG_update_token_family; + plugin->insert_report + = &TMH_PG_insert_report; + plugin->delete_report + = &TMH_PG_delete_report; + plugin->update_report + = &TMH_PG_update_report; + plugin->select_reports + = &TMH_PG_select_reports; + plugin->lookup_reports_pending + = &TMH_PG_lookup_reports_pending; + plugin->update_report_status + = &TMH_PG_update_report_status; + plugin->select_report + = &TMH_PG_select_report; + plugin->insert_product_group + = &TMH_PG_insert_product_group; + plugin->delete_product_group + = &TMH_PG_delete_product_group; + plugin->update_product_group + = &TMH_PG_update_product_group; + plugin->select_product_groups + = &TMH_PG_select_product_groups; + plugin->insert_money_pot + = &TMH_PG_insert_money_pot; + plugin->delete_money_pot + = &TMH_PG_delete_money_pot; + plugin->update_money_pot + = &TMH_PG_update_money_pot; + plugin->select_money_pots + = &TMH_PG_select_money_pots; + plugin->select_money_pot + = &TMH_PG_select_money_pot; plugin->insert_token_family_key = &TMH_PG_insert_token_family_key; plugin->update_contract_session diff --git a/src/include/taler_merchantdb_plugin.h b/src/include/taler_merchantdb_plugin.h @@ -1311,7 +1311,7 @@ enum TALER_MERCHANTDB_TokenFamilyKind /** * Typically called by `lookup_token_families`. * - * @param cls a `json_t *` JSON array to build + * @param cls closure * @param slug slug of the token family * @param name name of the token family * @param description description of the token family @@ -1333,6 +1333,85 @@ typedef void /** + * Typically called by `select_money_pots`. + * + * @param cls closure + * @param name set to name of the pot + * @param description set to description of the pot + * @param pod_total amount currently in the pot + */ +typedef void +(*TALER_MERCHANTDB_MoneyPotsCallback)( + void *cls, + uint64_t money_pot_id, + const char *name, + const char *description, + const struct TALER_Amount *pot_total, + const struct TALER_Amount *new_pot_total); + + +/** + * Typically called by `select_reports`. + * + * @param cls closure + * @param name name of the report + * @param description description of the report + * @param frequency the report frequency + */ +typedef void +(*TALER_MERCHANTDB_ReportsCallback)( + void *cls, + uint64_t report_id, + const char *report_description, + struct GNUNET_TIME_Relative frequency); + + +/** + * Typically called by `lookup_reports_pending`. + * + * @param cls closure + * @param report_id serial number of the report + * @param report_program_section configuration section of program + * for report generation + * @param report_description text describing the report + * @param mime_type mime type to request from the @a data_source + * @param data_source relative URL (to instance base URL) + * to request report data from + * @param target_address where to send report data + * @param frequency report frequency + * @param frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + */ +typedef void +(*TALER_MERCHANTDB_ReportsPendingCallback)( + void *cls, + uint64_t report_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift); + + +/** + * Typically called by `select_product_groups`. + * + * @param cls closure + * @param product_group_id ID of the product group + * @param group_name set to name of the group + * @param group_description set to description of the group + */ +typedef void +(*TALER_MERCHANTDB_ProductGroupsCallback)( + void *cls, + uint64_t product_group_id, + const char *group_name, + const char *group_description); + + +/** * Details about a token family. */ struct TALER_MERCHANTDB_TokenFamilyDetails @@ -4687,8 +4766,7 @@ struct TALER_MERCHANTDB_Plugin void *cls, const char *donau_url, struct GNUNET_TIME_Absolute *first_retry, - struct DONAU_Keys **keys - ); + struct DONAU_Keys **keys); /** * Lookup a Donau instance by its instance ID and URL. @@ -4715,8 +4793,7 @@ struct TALER_MERCHANTDB_Plugin struct TALER_Amount *charity_max_per_year, struct TALER_Amount *charity_receipts_to_date, json_t **donau_keys_json, - uint64_t *donau_instance_serial - ); + uint64_t *donau_instance_serial); /** * Upsert Donau keys into the database. @@ -4728,8 +4805,7 @@ struct TALER_MERCHANTDB_Plugin (*upsert_donau_keys)( void *cls, const struct DONAU_Keys *keys, - struct GNUNET_TIME_Absolute first_retry - ); + struct GNUNET_TIME_Absolute first_retry); /** * Update information about a Donau instance. @@ -4744,8 +4820,7 @@ struct TALER_MERCHANTDB_Plugin void *cls, const char *donau_url, const struct DONAU_Charity *charity, - uint64_t charity_id - ); + uint64_t charity_id); #endif @@ -4759,8 +4834,7 @@ struct TALER_MERCHANTDB_Plugin (*delete_donau_instance)( void *cls, const char *id, - uint64_t charity_id - ); + uint64_t charity_id); /** * Lookup amount statistics for instance and slug by bucket. @@ -4780,7 +4854,6 @@ struct TALER_MERCHANTDB_Plugin TALER_MERCHANTDB_AmountByBucketStatisticsCallback cb, void *cb_cls); - /** * Lookup counter statistics for instance and slug by bucket. * @@ -4816,6 +4889,7 @@ struct TALER_MERCHANTDB_Plugin const char *slug, TALER_MERCHANTDB_AmountByIntervalStatisticsCallback cb, void *cb_cls); + /** * Lookup counter statistics for instance and slug by interval. * @@ -4827,12 +4901,356 @@ struct TALER_MERCHANTDB_Plugin * @return database result code */ enum GNUNET_DB_QueryStatus - (*lookup_statistics_counter_by_interval)(void *cls, - const char *instance_id, - const char *slug, - TALER_MERCHANTDB_CounterByIntervalStatisticsCallback - cb, - void *cb_cls); + (*lookup_statistics_counter_by_interval)( + void *cls, + const char *instance_id, + const char *slug, + TALER_MERCHANTDB_CounterByIntervalStatisticsCallback cb, + void *cb_cls); + + + /** + * Lookup all of the money pots the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup token families for + * @param limit number of entries to return, negative for descending in execution time, + * positive for ascending in execution time + * @param offset expected_transfer_serial number of the transfer we want to offset from + * @param cb function to call on all money pots found + * @param cb_cls closure for @a cb + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*select_money_pots)(void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_MoneyPotsCallback cb, + void *cb_cls); + + /** + * Lookup details about a particular money pot. + * + * @param cls closure + * @param instance_id instance to lookup token family for + * @param money_pot_id serial number of the pot to lookup + * @param [out] name set to name of the pot + * @param[out] description set to description of the pot + * @param[out] pot_total set to amount currently in the pot + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*select_money_pot)(void *cls, + const char *instance_id, + uint64_t money_pot_id, + char **name, + char **description, + struct TALER_Amount *pot_total); + + /** + * Delete information about a money pot. + * + * @param cls closure + * @param instance_id instance to delete token family of + * @param money_pot_id serial number of the pot to delete + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*delete_money_pot)(void *cls, + const char *instance_id, + uint64_t money_pot_id); + + /** + * Update details about a particular money pot. + * + * @param cls closure + * @param instance_id instance to update token family for + * @param money_pot_id serial number of the pot to delete + * @param name set to name of the pot + * @param description set to description of the pot + * @param old_pot_total amount expected currently in the pot + * @param new_pot_total new amount in the pot + * @param[out] conflict set to true if @a old_pot_total does not match + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*update_money_pot)( + void *cls, + const char *instance_id, + uint64_t money_pot_id, + const char *name, + const char *description, + const struct TALER_Amount *old_pot_total, + const struct TALER_Amount *new_pot_total, + bool *conflict); + + + /** + * Insert details about a particular pot. + * + * @param cls closure + * @param instance_id instance to insert pot for + * @param name set to name of the pot + * @param description set to description of the pot + * @param pod_currency the expected currency in the pot + * @param[out] money_pot_id serial number of the new pot + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*insert_money_pot)( + void *cls, + const char *instance_id, + const char *name, + const char *description, + const char *pod_currency, + uint64_t *money_pot_id); + + // Reports + + /** + * Lookup all of the reports the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup reports for + * @param limit number of entries to return, negative for descending in execution time, + * positive for ascending in execution time + * @param offset expected_transfer_serial number of the transfer we want to offset from + * @param cb function to call on all reports found + * @param cb_cls closure for @a cb + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*select_reports)(void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_ReportsCallback cb, + void *cb_cls); + + + /** + * Lookup all of the reports pending for the given backend. + * + * @param cls closure + * @param cb function to call on all reports found + * @param cb_cls closure for @a cb + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*lookup_reports_pending)(void *cls, + TALER_MERCHANTDB_ReportsPendingCallback cb, + void *cb_cls); + + /** + * Lookup details about a particular report. + * + * @param cls closure + * @param instance_id instance to lookup reports for + * @param report_id serial number of the report to lookup + * @param[out] report_program_section configuration section of program + * for report generation + * @param[out] report_description text describing the report + * @param[out] mime_type mime type to request from the @a data_source + * @param[out] data_source relative URL (to instance base URL) + * to request report data from + * @param[out] target_address where to send report data + * @param[out] frequency report frequency + * @param[out] frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + * @param[out] next_transmission when will the report be generated next + * @param[out] last_error_code status of the last report + * @param[out] last_error_detail details about failures of last generation + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*select_report)(void *cls, + const char *instance_id, + uint64_t report_id, + char **report_program_section, + char **report_description, + char **mime_type, + char **data_source, + char **target_address, + struct GNUNET_TIME_Relative *frequency, + struct GNUNET_TIME_Relative *frequency_shift, + struct GNUNET_TIME_Absolute *next_transmission, + enum TALER_ErrorCode *last_error_code, + char **last_error_detail); + + /** + * Delete information about a report. + * + * @param cls closure + * @param instance_id instance to delete report of + * @param report_id serial number of the pot to delete + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*delete_report)(void *cls, + const char *instance_id, + uint64_t report_id); + + /** + * Update transmission status about a particular report. + * + * @param cls closure + * @param instance_id instance to update report for + * @param report_id serial number of the pot to update + * @param next_tranmission when should the report be generated next + * @param last_error_code #TALER_EC_NONE on success + * @param last_error_detail NULL on success + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*update_report_status)( + void *cls, + const char *instance_id, + uint64_t report_id, + struct GNUNET_TIME_Absolute next_transmission, + enum TALER_ErrorCode last_error_code, + const char *last_error_detail); + + + /** + * Update details about a particular report. + * + * @param cls closure + * @param instance_id instance to update report for + * @param report_id serial number of the report to update + * @param report_program_section configuration section of program + * for report generation + * @param report_description text describing the report + * @param mime_type mime type to request from the @a data_source + * @param data_source relative URL (to instance base URL) + * to request report data from + * @param target_address where to send report data + * @param frequency report frequency + * @param frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*update_report)( + void *cls, + const char *instance_id, + uint64_t report_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift); + + + /** + * Insert details about a particular pot. + * + * @param cls closure + * @param instance_id instance to insert pot for + * @param report_program_section configuration section of program + * for report generation + * @param report_description text describing the report + * @param mime_type mime type to request from the @a data_source + * @param data_source relative URL (to instance base URL) + * to request report data from + * @param target_address where to send report data + * @param frequency report frequency + * @param frequency_shift how much to shift the report time from a + * multiple of the report @a frequency + * @param[out] report_id serial number of the new pot + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*insert_report)( + void *cls, + const char *instance_id, + const char *report_program_section, + const char *report_description, + const char *mime_type, + const char *data_source, + const char *target_address, + struct GNUNET_TIME_Relative frequency, + struct GNUNET_TIME_Relative frequency_shift, + uint64_t *report_id); + + + // groups + + /** + * Lookup all of the product groups the given instance has configured. + * + * @param cls closure + * @param instance_id instance to lookup product groups for + * @param limit number of entries to return, negative for descending in execution time, + * positive for ascending in execution time + * @param offset expected_transfer_serial number of the transfer we want to offset from + * @param cb function to call on all groups found + * @param cb_cls closure for @a cb + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*select_product_groups)(void *cls, + const char *instance_id, + int64_t limit, + uint64_t offset, + TALER_MERCHANTDB_ProductGroupsCallback cb, + void *cb_cls); + + /** + * Delete information about a product group. + * + * @param cls closure + * @param instance_id instance to delete product group of + * @param product_group_id serial number of the group to delete + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*delete_product_group)(void *cls, + const char *instance_id, + uint64_t product_group_id); + + /** + * Update details about a particular product group. + * + * @param cls closure + * @param instance_id instance to update product group for + * @param product_group_id serial number of the group to update + * @param name set to name of the group + * @param description set to description of the group + * @param[out] conflict set to true if @a name is already used + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*update_product_group)( + void *cls, + const char *instance_id, + uint64_t product_group_id, + const char *name, + const char *description, + bool *conflict); + + + /** + * Insert details about a particular product group. + * + * @param cls closure + * @param instance_id instance to insert group for + * @param name set to name of the group + * @param description set to description of the group + * @param[out] product_group_id serial number of the new group + * @return database result code + */ + enum GNUNET_DB_QueryStatus + (*insert_product_group)( + void *cls, + const char *instance_id, + const char *name, + const char *description, + uint64_t *product_group_id); + + }; #endif