merchant

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

taler-merchant-httpd_delete-private-groups-GROUP_ID.c (2704B)


      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 Affero General Public License for more
     12   details.
     13 
     14   You should have received a copy of the GNU Affero General Public License
     15   along with TALER; see the file COPYING.  If not, see
     16   <http://www.gnu.org/licenses/>
     17 */
     18 /**
     19  * @file taler-merchant-httpd_delete-private-groups-GROUP_ID.c
     20  * @brief implementation of DELETE /private/groups/$GROUP_ID
     21  * @author Christian Grothoff
     22  */
     23 #include "taler/platform.h"
     24 #include "taler-merchant-httpd_delete-private-groups-GROUP_ID.h"
     25 #include <taler/taler_json_lib.h>
     26 
     27 
     28 MHD_RESULT
     29 TMH_private_delete_group (const struct TMH_RequestHandler *rh,
     30                           struct MHD_Connection *connection,
     31                           struct TMH_HandlerContext *hc)
     32 {
     33   const char *group_id_str = hc->infix;
     34   unsigned long long group_id;
     35   enum GNUNET_DB_QueryStatus qs;
     36   char dummy;
     37 
     38   (void) rh;
     39   if (1 != sscanf (group_id_str,
     40                    "%llu%c",
     41                    &group_id,
     42                    &dummy))
     43   {
     44     GNUNET_break_op (0);
     45     return TALER_MHD_reply_with_error (connection,
     46                                        MHD_HTTP_BAD_REQUEST,
     47                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
     48                                        "group_id");
     49   }
     50   qs = TMH_db->delete_product_group (TMH_db->cls,
     51                                      hc->instance->settings.id,
     52                                      group_id);
     53 
     54   if (qs < 0)
     55   {
     56     GNUNET_break (0);
     57     return TALER_MHD_reply_with_error (connection,
     58                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     59                                        TALER_EC_GENERIC_DB_STORE_FAILED,
     60                                        "delete_product_group");
     61   }
     62   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
     63   {
     64     return TALER_MHD_reply_with_error (connection,
     65                                        MHD_HTTP_NOT_FOUND,
     66                                        TALER_EC_MERCHANT_GENERIC_PRODUCT_GROUP_UNKNOWN,
     67                                        group_id_str);
     68   }
     69   return TALER_MHD_reply_static (connection,
     70                                  MHD_HTTP_NO_CONTENT,
     71                                  NULL,
     72                                  NULL,
     73                                  0);
     74 }