pg_update_wire.c (3171B)
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/pg_update_wire.c 18 * @brief Implementation of the update_wire function for Postgres 19 * @author Christian Grothoff 20 */ 21 #include "taler/taler_pq_lib.h" 22 #include "taler/exchange-database/update_wire.h" 23 #include "helper.h" 24 25 26 enum GNUNET_DB_QueryStatus 27 TALER_EXCHANGEDB_update_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 change_date, 36 const struct TALER_MasterSignatureP *master_sig, 37 const char *bank_label, 38 int64_t priority, 39 bool enabled) 40 { 41 struct GNUNET_PQ_QueryParam params[] = { 42 GNUNET_PQ_query_param_string (payto_uri.full_payto), 43 GNUNET_PQ_query_param_bool (enabled), 44 NULL == conversion_url 45 ? GNUNET_PQ_query_param_null () 46 : GNUNET_PQ_query_param_string (conversion_url), 47 enabled 48 ? TALER_PQ_query_param_json (debit_restrictions) 49 : GNUNET_PQ_query_param_null (), 50 enabled 51 ? TALER_PQ_query_param_json (credit_restrictions) 52 : GNUNET_PQ_query_param_null (), 53 GNUNET_PQ_query_param_timestamp (&change_date), 54 NULL == master_sig 55 ? GNUNET_PQ_query_param_null () 56 : GNUNET_PQ_query_param_auto_from_type (master_sig), 57 NULL == bank_label 58 ? GNUNET_PQ_query_param_null () 59 : GNUNET_PQ_query_param_string (bank_label), 60 GNUNET_PQ_query_param_int64 (&priority), 61 NULL == open_banking_gateway 62 ? GNUNET_PQ_query_param_null () 63 : GNUNET_PQ_query_param_string (open_banking_gateway), 64 NULL == wire_transfer_gateway 65 ? GNUNET_PQ_query_param_null () 66 : GNUNET_PQ_query_param_string (wire_transfer_gateway), 67 GNUNET_PQ_query_param_end 68 }; 69 70 PREPARE (pg, 71 "update_wire", 72 "UPDATE wire_accounts" 73 " SET" 74 " is_active=$2" 75 " ,conversion_url=$3" 76 " ,debit_restrictions=$4::TEXT::JSONB" 77 " ,credit_restrictions=$5::TEXT::JSONB" 78 " ,last_change=$6" 79 " ,master_sig=$7" 80 " ,bank_label=$8" 81 " ,priority=$9" 82 " ,open_banking_gateway=$10" 83 " ,wire_transfer_gateway=$11" 84 " WHERE payto_uri=$1"); 85 return GNUNET_PQ_eval_prepared_non_select (pg->conn, 86 "update_wire", 87 params); 88 }