merchant

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

taler-merchant-httpd_delete-private-reports-REPORT_ID.c (2769B)


      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 src/backend/taler-merchant-httpd_delete-private-reports-REPORT_ID.c
     20  * @brief implementation of DELETE /private/reports/$REPORT_ID
     21  * @author Christian Grothoff
     22  */
     23 #include "platform.h"
     24 #include "taler-merchant-httpd_delete-private-reports-REPORT_ID.h"
     25 #include <taler/taler_json_lib.h>
     26 #include "merchant-database/delete_report.h"
     27 
     28 
     29 enum MHD_Result
     30 TMH_private_delete_report (const struct TMH_RequestHandler *rh,
     31                            struct MHD_Connection *connection,
     32                            struct TMH_HandlerContext *hc)
     33 {
     34   const char *report_id_str = hc->infix;
     35   unsigned long long report_id;
     36   enum GNUNET_DB_QueryStatus qs;
     37   char dummy;
     38 
     39   (void) rh;
     40 
     41   if (1 !=
     42       sscanf (report_id_str,
     43               "%llu%c",
     44               &report_id,
     45               &dummy))
     46   {
     47     GNUNET_break_op (0);
     48     return TALER_MHD_reply_with_error (connection,
     49                                        MHD_HTTP_BAD_REQUEST,
     50                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
     51                                        "report_id");
     52   }
     53 
     54   qs = TALER_MERCHANTDB_delete_report (TMH_db,
     55                                        hc->instance->settings.id,
     56                                        (uint64_t) report_id);
     57   if (qs < 0)
     58   {
     59     GNUNET_break_op (0);
     60     return TALER_MHD_reply_with_error (connection,
     61                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
     62                                        TALER_EC_GENERIC_DB_STORE_FAILED,
     63                                        "delete_report");
     64   }
     65   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
     66   {
     67     return TALER_MHD_reply_with_error (connection,
     68                                        MHD_HTTP_NOT_FOUND,
     69                                        TALER_EC_MERCHANT_GENERIC_REPORT_UNKNOWN,
     70                                        report_id_str);
     71   }
     72   return TALER_MHD_reply_static (connection,
     73                                  MHD_HTTP_NO_CONTENT,
     74                                  NULL,
     75                                  NULL,
     76                                  0);
     77 }