taler-merchant-httpd_delete-private-templates-TEMPLATE_ID.c (3116B)
1 /* 2 This file is part of TALER 3 (C) 2022 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-templates-TEMPLATE_ID.c 18 * @brief implement DELETE /templates/$ID 19 * @author Priscilla HUANG 20 */ 21 #include "platform.h" 22 #include "taler-merchant-httpd_delete-private-templates-TEMPLATE_ID.h" 23 #include <taler/taler_json_lib.h> 24 #include "merchant-database/delete_template.h" 25 26 27 /** 28 * Handle a DELETE "/templates/$ID" request. 29 * 30 * @param rh context of the handler 31 * @param connection the MHD connection to handle 32 * @param[in,out] hc context with further information about the request 33 * @return MHD result code 34 */ 35 enum MHD_Result 36 TMH_private_delete_templates_ID (const struct TMH_RequestHandler *rh, 37 struct MHD_Connection *connection, 38 struct TMH_HandlerContext *hc) 39 { 40 struct TMH_MerchantInstance *mi = hc->instance; 41 enum GNUNET_DB_QueryStatus qs; 42 43 (void) rh; 44 GNUNET_assert (NULL != mi); 45 GNUNET_assert (NULL != hc->infix); 46 qs = TALER_MERCHANTDB_delete_template (TMH_db, 47 mi->settings.id, 48 hc->infix); 49 switch (qs) 50 { 51 case GNUNET_DB_STATUS_HARD_ERROR: 52 return TALER_MHD_reply_with_error (connection, 53 MHD_HTTP_INTERNAL_SERVER_ERROR, 54 TALER_EC_GENERIC_DB_STORE_FAILED, 55 "delete_template"); 56 case GNUNET_DB_STATUS_SOFT_ERROR: 57 GNUNET_break (0); 58 return TALER_MHD_reply_with_error (connection, 59 MHD_HTTP_INTERNAL_SERVER_ERROR, 60 TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, 61 "delete_template (soft)"); 62 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 63 return TALER_MHD_reply_with_error (connection, 64 MHD_HTTP_NOT_FOUND, 65 TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, 66 hc->infix); 67 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 68 return TALER_MHD_reply_static (connection, 69 MHD_HTTP_NO_CONTENT, 70 NULL, 71 NULL, 72 0); 73 } 74 GNUNET_assert (0); 75 return MHD_NO; 76 } 77 78 79 /* end of taler-merchant-httpd_delete-private-templates-TEMPLATE_ID.c */