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 src/backenddb/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_pq_lib.h>
24 : #include "merchant-database/update_instance.h"
25 : #include "helper.h"
26 :
27 :
28 : enum GNUNET_DB_QueryStatus
29 6 : TALER_MERCHANTDB_update_instance (
30 : struct TALER_MERCHANTDB_PostgresContext *pg,
31 : const struct TALER_MERCHANTDB_InstanceSettings *is)
32 : {
33 6 : struct GNUNET_PQ_QueryParam params[] = {
34 6 : GNUNET_PQ_query_param_string (is->id),
35 6 : GNUNET_PQ_query_param_string (is->name),
36 6 : TALER_PQ_query_param_json (is->address),
37 6 : TALER_PQ_query_param_json (is->jurisdiction),
38 6 : GNUNET_PQ_query_param_bool (is->use_stefan),
39 6 : GNUNET_PQ_query_param_relative_time (
40 : &is->default_wire_transfer_delay),
41 6 : GNUNET_PQ_query_param_relative_time (
42 : &is->default_pay_delay),
43 6 : GNUNET_PQ_query_param_relative_time (
44 : &is->default_refund_delay),
45 6 : (NULL == is->website)
46 6 : ? GNUNET_PQ_query_param_null ()
47 6 : : GNUNET_PQ_query_param_string (is->website),
48 6 : (NULL == is->email)
49 6 : ? GNUNET_PQ_query_param_null ()
50 6 : : GNUNET_PQ_query_param_string (is->email),
51 6 : (NULL == is->logo)
52 6 : ? GNUNET_PQ_query_param_null ()
53 6 : : GNUNET_PQ_query_param_string (is->logo),
54 6 : (NULL == is->phone)
55 6 : ? GNUNET_PQ_query_param_null ()
56 6 : : GNUNET_PQ_query_param_string (is->phone),
57 6 : GNUNET_PQ_query_param_bool (is->phone_validated),
58 6 : GNUNET_PQ_query_param_bool (is->email_validated),
59 6 : GNUNET_PQ_query_param_string (
60 : GNUNET_TIME_round_interval2s (
61 6 : is->default_wire_transfer_rounding_interval)),
62 : GNUNET_PQ_query_param_end
63 : };
64 :
65 6 : PREPARE (pg,
66 : "update_instance",
67 : "UPDATE merchant.merchant_instances SET"
68 : " merchant_name=$2"
69 : ",address=$3::TEXT::JSONB"
70 : ",jurisdiction=$4::TEXT::JSONB"
71 : ",use_stefan=$5"
72 : ",default_wire_transfer_delay=$6"
73 : ",default_pay_delay=$7"
74 : ",default_refund_delay=$8"
75 : ",website=$9"
76 : ",email=$10"
77 : ",logo=$11"
78 : ",phone_number=$12"
79 : ",phone_validated=$13"
80 : ",email_validated=$14"
81 : ",default_wire_transfer_rounding_interval=($15::merchant.time_rounder_interval)"
82 : " WHERE merchant_id=$1");
83 6 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
84 : "update_instance",
85 : params);
86 : }
|