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 *prepared_transfer_url,
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 == prepared_transfer_url
57 21 : ? GNUNET_PQ_query_param_null ()
58 21 : : GNUNET_PQ_query_param_string (prepared_transfer_url),
59 : GNUNET_PQ_query_param_end
60 : };
61 : // FIXME: Also rename the wire_transfer_gateway column to prepared_transfer_url
62 : // via schema migration.
63 21 : PREPARE (pg,
64 : "insert_wire",
65 : "INSERT INTO wire_accounts "
66 : "(payto_uri"
67 : ",conversion_url"
68 : ",debit_restrictions"
69 : ",credit_restrictions"
70 : ",master_sig"
71 : ",is_active"
72 : ",last_change"
73 : ",bank_label"
74 : ",priority"
75 : ",open_banking_gateway"
76 : ",wire_transfer_gateway"
77 : ") VALUES "
78 : "($1,$2,$3::TEXT::JSONB,$4::TEXT::JSONB,$5,true,$6,$7,$8,$9,$10);");
79 21 : return GNUNET_PQ_eval_prepared_non_select (pg->conn,
80 : "insert_wire",
81 : params);
82 : }
|