taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.c (2907B)
1 /* 2 This file is part of TALER 3 (C) 2023 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 taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.c 18 * @brief implement DELETE /tokenfamilies/$SLUG 19 * @author Christian Blättler 20 */ 21 #include "taler/platform.h" 22 #include "taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.h" 23 #include <gnunet/gnunet_db_lib.h> 24 #include <taler/taler_json_lib.h> 25 26 27 /** 28 * Handle a DELETE "/tokenfamilies/$SLUG" 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 MHD_RESULT 36 TMH_private_delete_token_families_SLUG (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 = TMH_db->delete_token_family (TMH_db->cls, 47 mi->settings.id, 48 hc->infix); 49 switch (qs) 50 { 51 case GNUNET_DB_STATUS_HARD_ERROR: 52 GNUNET_break (0); 53 return TALER_MHD_reply_with_error ( 54 connection, 55 MHD_HTTP_INTERNAL_SERVER_ERROR, 56 TALER_EC_GENERIC_DB_STORE_FAILED, 57 "delete_token_family"); 58 case GNUNET_DB_STATUS_SOFT_ERROR: 59 GNUNET_break (0); 60 return TALER_MHD_reply_with_error ( 61 connection, 62 MHD_HTTP_INTERNAL_SERVER_ERROR, 63 TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE, 64 "delete_token_family (soft)"); 65 case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS: 66 return TALER_MHD_reply_with_error ( 67 connection, 68 MHD_HTTP_NOT_FOUND, 69 TALER_EC_MERCHANT_GENERIC_TOKEN_FAMILY_UNKNOWN, 70 hc->infix); 71 case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT: 72 return TALER_MHD_reply_static (connection, 73 MHD_HTTP_NO_CONTENT, 74 NULL, 75 NULL, 76 0); 77 } 78 GNUNET_assert (0); 79 return MHD_NO; 80 } 81 82 83 /* end of taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.c */