Line data Source code
1 : /*
2 : This file is part of TALER
3 : Copyright (C) 2022, 2023, 2024 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 exchangedb/insert_wire.c
18 : * @brief Implementation of the insert_wire function for Postgres
19 : * @author Christian Grothoff
20 : */
21 : #include "taler/taler_pq_lib.h"
22 : #include "exchange-database/insert_wire.h"
23 : #include "helper.h"
24 :
25 :
26 : enum GNUNET_DB_QueryStatus
27 21 : TALER_EXCHANGEDB_insert_wire (
28 : struct TALER_EXCHANGEDB_PostgresContext *pg,
29 : const struct TALER_FullPayto payto_uri,
30 : const char *conversion_url,
31 : const char *open_banking_gateway,
32 : const char *wire_transfer_gateway,
33 : const json_t *debit_restrictions,
34 : const json_t *credit_restrictions,
35 : struct GNUNET_TIME_Timestamp start_date,
36 : const struct TALER_MasterSignatureP *master_sig,
37 : const char *bank_label,
38 : int64_t priority)
39 : {
40 21 : struct GNUNET_PQ_QueryParam params[] = {
41 21 : GNUNET_PQ_query_param_string (payto_uri.full_payto),
42 : NULL == conversion_url
43 21 : ? GNUNET_PQ_query_param_null ()
44 21 : : GNUNET_PQ_query_param_string (conversion_url),
45 21 : TALER_PQ_query_param_json (debit_restrictions),
46 21 : TALER_PQ_query_param_json (credit_restrictions),
47 21 : GNUNET_PQ_query_param_auto_from_type (master_sig),
48 21 : GNUNET_PQ_query_param_timestamp (&start_date),
49 : NULL == bank_label
50 17 : ? GNUNET_PQ_query_param_null ()
51 21 : : GNUNET_PQ_query_param_string (bank_label),
52 21 : GNUNET_PQ_query_param_int64 (&priority),
53 : NULL == open_banking_gateway
54 21 : ? GNUNET_PQ_query_param_null ()
55 21 : : GNUNET_PQ_query_param_string (open_banking_gateway),
56 : NULL == wire_transfer_gateway
57 21 : ? GNUNET_PQ_query_param_null ()
58 21 : : GNUNET_PQ_query_param_string (wire_transfer_gateway),
59 : GNUNET_PQ_query_param_end
60 : };
61 :
62 21 : PREPARE (pg,
63 : "insert_wire",
64 : "INSERT INTO wire_accounts "
65 : "(payto_uri"
66 : ",conversion_url"
67 : ",debit_restrictions"
68 : ",credit_restrictions"
69 : ",master_sig"
70 : ",is_active"
71 : ",last_change"
72 : ",bank_label"
73 : ",priority"
74 : ",open_banking_gateway"
75 : ",wire_transfer_gateway"
76 : ") VALUES "
77 : "($1,$2,$3::TEXT::JSONB,$4::TEXT::JSONB,$5,true,$6,$7,$8,$9,$10);");
78 21 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
79 : "insert_wire",
80 : params);
81 : }
|