taler-merchant-httpd_delete-private-units-UNIT.c (3422B)
1 /* 2 This file is part of TALER 3 (C) 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 Affero 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/backend/taler-merchant-httpd_delete-private-units-UNIT.c 18 * @brief implement DELETE /private/units/$UNIT 19 * @author Bohdan Potuzhnyi 20 */ 21 #include "platform.h" 22 #include "taler-merchant-httpd_delete-private-units-UNIT.h" 23 #include "merchant-database/delete_unit.h" 24 25 26 enum MHD_Result 27 TMH_private_delete_units_ID (const struct TMH_RequestHandler *rh, 28 struct MHD_Connection *connection, 29 struct TMH_HandlerContext *hc) 30 { 31 enum GNUNET_DB_QueryStatus qs; 32 bool no_instance = false; 33 bool no_unit = false; 34 bool builtin_conflict = false; 35 36 GNUNET_assert (NULL != hc->infix); 37 qs = TALER_MERCHANTDB_delete_unit (TMH_db, 38 hc->instance->settings.id, 39 hc->infix, 40 &no_instance, 41 &no_unit, 42 &builtin_conflict); 43 switch (qs) 44 { 45 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 46 break; 47 case GNUNET_DB_STATUS_SOFT_ERROR: 48 GNUNET_break (0); 49 return TALER_MHD_reply_with_error (connection, 50 MHD_HTTP_INTERNAL_SERVER_ERROR, 51 TALER_EC_GENERIC_DB_SOFT_FAILURE, 52 "delete_unit"); 53 case GNUNET_DB_STATUS_HARD_ERROR: 54 default: 55 GNUNET_break (0); 56 return TALER_MHD_reply_with_error (connection, 57 MHD_HTTP_INTERNAL_SERVER_ERROR, 58 TALER_EC_GENERIC_DB_STORE_FAILED, 59 "delete_unit"); 60 } 61 if (no_instance) 62 return TALER_MHD_reply_with_error (connection, 63 MHD_HTTP_NOT_FOUND, 64 TALER_EC_MERCHANT_GENERIC_INSTANCE_UNKNOWN, 65 hc->instance->settings.id); 66 if (no_unit) 67 return TALER_MHD_reply_with_error (connection, 68 MHD_HTTP_NOT_FOUND, 69 TALER_EC_MERCHANT_GENERIC_UNIT_UNKNOWN, 70 hc->infix); 71 if (builtin_conflict) 72 return TALER_MHD_reply_with_error (connection, 73 MHD_HTTP_CONFLICT, 74 TALER_EC_MERCHANT_GENERIC_UNIT_BUILTIN, 75 hc->infix); 76 return TALER_MHD_reply_static (connection, 77 MHD_HTTP_NO_CONTENT, 78 NULL, 79 NULL, 80 0); 81 } 82 83 84 /* end of taler-merchant-httpd_delete-private-units-UNIT.c */