insert_instance.c (3783B)
1 /* 2 This file is part of TALER 3 Copyright (C) 2022, 2025 Taler Systems SA 4 5 TALER is free software; you can redistribute it and/or modify it under the 6 terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 3, or (at your option) any later version. 8 9 TALER is distributed in the hope that it will be useful, but WITHOUT ANY 10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 11 A PARTICULAR PURPOSE. See the GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License along with 14 TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/> 15 */ 16 /** 17 * @file src/backenddb/insert_instance.c 18 * @brief Implementation of the insert_instance function for Postgres 19 * @author Christian Grothoff 20 * @author Iván Ávalos 21 */ 22 #include "platform.h" 23 #include <taler/taler_pq_lib.h> 24 #include "merchant-database/insert_instance.h" 25 #include "helper.h" 26 27 28 enum GNUNET_DB_QueryStatus 29 TALER_MERCHANTDB_insert_instance ( 30 struct TALER_MERCHANTDB_PostgresContext *pg, 31 const struct TALER_MerchantPublicKeyP *merchant_pub, 32 const struct TALER_MerchantPrivateKeyP *merchant_priv, 33 const struct TALER_MERCHANTDB_InstanceSettings *is, 34 const struct TALER_MERCHANTDB_InstanceAuthSettings *ias) 35 { 36 struct GNUNET_PQ_QueryParam params[] = { 37 GNUNET_PQ_query_param_auto_from_type (merchant_pub), 38 GNUNET_PQ_query_param_auto_from_type (merchant_priv), 39 GNUNET_PQ_query_param_auto_from_type (&ias->auth_hash), 40 GNUNET_PQ_query_param_auto_from_type (&ias->auth_salt), 41 GNUNET_PQ_query_param_string (is->id), 42 GNUNET_PQ_query_param_string (is->name), 43 TALER_PQ_query_param_json (is->address), 44 TALER_PQ_query_param_json (is->jurisdiction), 45 GNUNET_PQ_query_param_bool (is->use_stefan), 46 GNUNET_PQ_query_param_relative_time ( 47 &is->default_wire_transfer_delay), 48 GNUNET_PQ_query_param_relative_time (&is->default_pay_delay), 49 GNUNET_PQ_query_param_relative_time (&is->default_refund_delay), 50 (NULL == is->website) 51 ? GNUNET_PQ_query_param_null () 52 : GNUNET_PQ_query_param_string (is->website), 53 (NULL == is->email) 54 ? GNUNET_PQ_query_param_null () 55 : GNUNET_PQ_query_param_string (is->email), 56 (NULL == is->logo) 57 ? GNUNET_PQ_query_param_null () 58 : GNUNET_PQ_query_param_string (is->logo), 59 (NULL == is->phone) 60 ? GNUNET_PQ_query_param_null () 61 : GNUNET_PQ_query_param_string (is->phone), 62 GNUNET_PQ_query_param_bool (is->phone_validated), 63 GNUNET_PQ_query_param_bool (is->email_validated), 64 GNUNET_PQ_query_param_string ( 65 GNUNET_TIME_round_interval2s ( 66 is->default_wire_transfer_rounding_interval)), 67 GNUNET_PQ_query_param_end 68 }; 69 70 PREPARE (pg, 71 "insert_instance", 72 "INSERT INTO merchant.merchant_instances" 73 "(merchant_pub" 74 ",merchant_priv" 75 ",auth_hash" 76 ",auth_salt" 77 ",merchant_id" 78 ",merchant_name" 79 ",address" 80 ",jurisdiction" 81 ",use_stefan" 82 ",default_wire_transfer_delay" 83 ",default_pay_delay" 84 ",default_refund_delay" 85 ",website" 86 ",email" 87 ",logo" 88 ",phone_number" 89 ",phone_validated" 90 ",email_validated" 91 ",default_wire_transfer_rounding_interval)" 92 "VALUES" 93 "($1,$2,$3,$4,LOWER($5),$6,$7::TEXT::JSONB,$8::TEXT::JSONB," 94 "$9,$10,$11,$12,$13,$14,$15,$16,$17,$18," 95 "$19::merchant.time_rounder_interval)"); 96 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 97 "insert_instance", 98 params); 99 }