Line data Source code
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 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 : GNUNET_PQ_query_param_relative_time (
46 : &is->default_refund_delay),
47 4 : (NULL == is->website)
48 4 : ? GNUNET_PQ_query_param_null ()
49 4 : : GNUNET_PQ_query_param_string (is->website),
50 4 : (NULL == is->email)
51 4 : ? GNUNET_PQ_query_param_null ()
52 4 : : GNUNET_PQ_query_param_string (is->email),
53 4 : (NULL == is->logo)
54 4 : ? GNUNET_PQ_query_param_null ()
55 4 : : GNUNET_PQ_query_param_string (is->logo),
56 4 : (NULL == is->phone)
57 4 : ? GNUNET_PQ_query_param_null ()
58 4 : : GNUNET_PQ_query_param_string (is->phone),
59 4 : GNUNET_PQ_query_param_bool (is->phone_validated),
60 4 : GNUNET_PQ_query_param_bool (is->email_validated),
61 4 : GNUNET_PQ_query_param_string (
62 : GNUNET_TIME_round_interval2s (
63 4 : is->default_wire_transfer_rounding_interval)),
64 : GNUNET_PQ_query_param_end
65 : };
66 :
67 4 : check_connection (pg);
68 4 : PREPARE (pg,
69 : "update_instance",
70 : "UPDATE merchant_instances SET"
71 : " merchant_name=$2"
72 : ",address=$3::TEXT::JSONB"
73 : ",jurisdiction=$4::TEXT::JSONB"
74 : ",use_stefan=$5"
75 : ",default_wire_transfer_delay=$6"
76 : ",default_pay_delay=$7"
77 : ",default_refund_delay=$8"
78 : ",website=$9"
79 : ",email=$10"
80 : ",logo=$11"
81 : ",phone_number=$12"
82 : ",phone_validated=$13"
83 : ",email_validated=$14"
84 : ",default_wire_transfer_rounding_interval=($15::time_rounder_interval)"
85 : " WHERE merchant_id=$1");
86 4 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
87 : "update_instance",
88 : params);
89 : }
|