merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.c (2991B)


      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 src/backend/taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.c
     18  * @brief implement DELETE /tokenfamilies/$SLUG
     19  * @author Christian Blättler
     20  */
     21 #include "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 #include "merchant-database/delete_token_family.h"
     26 
     27 
     28 /**
     29  * Handle a DELETE "/tokenfamilies/$SLUG" request.
     30  *
     31  * @param rh context of the handler
     32  * @param connection the MHD connection to handle
     33  * @param[in,out] hc context with further information about the request
     34  * @return MHD result code
     35  */
     36 enum MHD_Result
     37 TMH_private_delete_token_families_SLUG (const struct TMH_RequestHandler *rh,
     38                                         struct MHD_Connection *connection,
     39                                         struct TMH_HandlerContext *hc)
     40 {
     41   struct TMH_MerchantInstance *mi = hc->instance;
     42   enum GNUNET_DB_QueryStatus qs;
     43 
     44   (void) rh;
     45   GNUNET_assert (NULL != mi);
     46   GNUNET_assert (NULL != hc->infix);
     47   qs = TALER_MERCHANTDB_delete_token_family (TMH_db,
     48                                              mi->settings.id,
     49                                              hc->infix);
     50   switch (qs)
     51   {
     52   case GNUNET_DB_STATUS_HARD_ERROR:
     53     GNUNET_break (0);
     54     return TALER_MHD_reply_with_error (
     55       connection,
     56       MHD_HTTP_INTERNAL_SERVER_ERROR,
     57       TALER_EC_GENERIC_DB_STORE_FAILED,
     58       "delete_token_family");
     59   case GNUNET_DB_STATUS_SOFT_ERROR:
     60     GNUNET_break (0);
     61     return TALER_MHD_reply_with_error (
     62       connection,
     63       MHD_HTTP_INTERNAL_SERVER_ERROR,
     64       TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
     65       "delete_token_family (soft)");
     66   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
     67     return TALER_MHD_reply_with_error (
     68       connection,
     69       MHD_HTTP_NOT_FOUND,
     70       TALER_EC_MERCHANT_GENERIC_TOKEN_FAMILY_UNKNOWN,
     71       hc->infix);
     72   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     73     return TALER_MHD_reply_static (connection,
     74                                    MHD_HTTP_NO_CONTENT,
     75                                    NULL,
     76                                    NULL,
     77                                    0);
     78   }
     79   GNUNET_assert (0);
     80   return MHD_NO;
     81 }
     82 
     83 
     84 /* end of taler-merchant-httpd_delete-private-tokenfamilies-TOKEN_FAMILY_SLUG.c */