Line data Source code
1 : /* 2 : This file is part of TALER 3 : Copyright (C) 2022 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 backenddb/pg_update_instance.c 18 : * @brief Implementation of the update_instance function for Postgres 19 : * @author Christian Grothoff 20 : * @author Iván Ávalos 21 : */ 22 : #include "platform.h" 23 : #include <taler/taler_error_codes.h> 24 : #include <taler/taler_dbevents.h> 25 : #include <taler/taler_pq_lib.h> 26 : #include "pg_update_instance.h" 27 : #include "pg_helper.h" 28 : 29 : 30 : enum GNUNET_DB_QueryStatus 31 4 : TMH_PG_update_instance (void *cls, 32 : const struct TALER_MERCHANTDB_InstanceSettings *is) 33 : { 34 4 : struct PostgresClosure *pg = cls; 35 4 : struct GNUNET_PQ_QueryParam params[] = { 36 4 : GNUNET_PQ_query_param_string (is->id), 37 4 : GNUNET_PQ_query_param_string (is->name), 38 4 : TALER_PQ_query_param_json (is->address), 39 4 : TALER_PQ_query_param_json (is->jurisdiction), 40 4 : GNUNET_PQ_query_param_bool (is->use_stefan), 41 4 : GNUNET_PQ_query_param_relative_time ( 42 : &is->default_wire_transfer_delay), 43 4 : GNUNET_PQ_query_param_relative_time ( 44 : &is->default_pay_delay), 45 4 : (NULL == is->website) 46 4 : ? GNUNET_PQ_query_param_null () 47 4 : : GNUNET_PQ_query_param_string (is->website), 48 4 : (NULL == is->email) 49 4 : ? GNUNET_PQ_query_param_null () 50 4 : : GNUNET_PQ_query_param_string (is->email), 51 4 : (NULL == is->logo) 52 4 : ? GNUNET_PQ_query_param_null () 53 4 : : GNUNET_PQ_query_param_string (is->logo), 54 : GNUNET_PQ_query_param_end 55 : }; 56 : 57 4 : check_connection (pg); 58 4 : PREPARE (pg, 59 : "update_instance", 60 : "UPDATE merchant_instances SET" 61 : " merchant_name=$2" 62 : ",address=$3" 63 : ",jurisdiction=$4" 64 : ",use_stefan=$5" 65 : ",default_wire_transfer_delay=$6" 66 : ",default_pay_delay=$7" 67 : ",website=$8" 68 : ",email=$9" 69 : ",logo=$10" 70 : " WHERE merchant_id=$1"); 71 4 : return GNUNET_PQ_eval_prepared_non_select (pg->conn, 72 : "update_instance", 73 : params); 74 : }