merchant

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

taler-merchant-httpd_delete-private-units-UNIT.c (3064B)


      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_unit = false;
     33   bool builtin_conflict = false;
     34 
     35   GNUNET_assert (NULL != hc->infix);
     36   qs = TALER_MERCHANTDB_delete_unit (TMH_db,
     37                                      hc->instance->settings.id,
     38                                      hc->infix,
     39                                      &no_unit,
     40                                      &builtin_conflict);
     41   switch (qs)
     42   {
     43   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
     44     break;
     45   case GNUNET_DB_STATUS_SOFT_ERROR:
     46     GNUNET_break (0);
     47     return TALER_MHD_reply_with_error (connection,
     48                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     49                                        TALER_EC_GENERIC_DB_SOFT_FAILURE,
     50                                        "delete_unit");
     51   case GNUNET_DB_STATUS_HARD_ERROR:
     52   default:
     53     GNUNET_break (0);
     54     return TALER_MHD_reply_with_error (connection,
     55                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     56                                        TALER_EC_GENERIC_DB_STORE_FAILED,
     57                                        "delete_unit");
     58   }
     59   if (no_unit)
     60     return TALER_MHD_reply_with_error (connection,
     61                                        MHD_HTTP_NOT_FOUND,
     62                                        TALER_EC_MERCHANT_GENERIC_UNIT_UNKNOWN,
     63                                        hc->infix);
     64   if (builtin_conflict)
     65     return TALER_MHD_reply_with_error (connection,
     66                                        MHD_HTTP_CONFLICT,
     67                                        TALER_EC_MERCHANT_GENERIC_UNIT_BUILTIN,
     68                                        hc->infix);
     69   return TALER_MHD_reply_static (connection,
     70                                  MHD_HTTP_NO_CONTENT,
     71                                  NULL,
     72                                  NULL,
     73                                  0);
     74 }
     75 
     76 
     77 /* end of taler-merchant-httpd_delete-private-units-UNIT.c */