LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-delete-reserves-ID.c (source / functions) Hit Total Coverage
Test: GNU Taler merchant coverage report Lines: 0 28 0.0 %
Date: 2022-08-25 06:17:04 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (C) 2020 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_private-delete-reserves-ID.c
      18             :  * @brief implement DELETE /reserves/$ID
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler-merchant-httpd_private-delete-reserves-ID.h"
      23             : #include <taler/taler_json_lib.h>
      24             : 
      25             : 
      26             : /**
      27             :  * Handle a DELETE "/reserves/$ID" request.
      28             :  *
      29             :  * @param rh context of the handler
      30             :  * @param connection the MHD connection to handle
      31             :  * @param[in,out] hc context with further information about the request
      32             :  * @return MHD result code
      33             :  */
      34             : MHD_RESULT
      35           0 : TMH_private_delete_reserves_ID (const struct TMH_RequestHandler *rh,
      36             :                                 struct MHD_Connection *connection,
      37             :                                 struct TMH_HandlerContext *hc)
      38             : {
      39           0 :   struct TMH_MerchantInstance *mi = hc->instance;
      40             :   enum GNUNET_DB_QueryStatus qs;
      41             :   struct TALER_ReservePublicKeyP reserve_pub;
      42             :   const char *purge;
      43             : 
      44             :   (void) rh;
      45           0 :   if (GNUNET_OK !=
      46           0 :       GNUNET_STRINGS_string_to_data (hc->infix,
      47           0 :                                      strlen (hc->infix),
      48             :                                      &reserve_pub,
      49             :                                      sizeof (reserve_pub)))
      50             :   {
      51           0 :     GNUNET_break_op (0);
      52           0 :     return TALER_MHD_reply_with_error (connection,
      53             :                                        MHD_HTTP_BAD_REQUEST,
      54             :                                        TALER_EC_MERCHANT_GENERIC_RESERVE_PUB_MALFORMED,
      55           0 :                                        hc->infix);
      56             :   }
      57           0 :   purge = MHD_lookup_connection_value (connection,
      58             :                                        MHD_GET_ARGUMENT_KIND,
      59             :                                        "purge");
      60           0 :   GNUNET_assert (NULL != mi);
      61           0 :   if ( (NULL != purge) &&
      62           0 :        (0 == strcasecmp (purge,
      63             :                          "yes")) )
      64           0 :     qs = TMH_db->purge_reserve (TMH_db->cls,
      65           0 :                                 mi->settings.id,
      66             :                                 &reserve_pub);
      67             :   else
      68           0 :     qs = TMH_db->delete_reserve (TMH_db->cls,
      69           0 :                                  mi->settings.id,
      70             :                                  &reserve_pub);
      71           0 :   switch (qs)
      72             :   {
      73           0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      74           0 :     return TALER_MHD_reply_with_error (connection,
      75             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      76             :                                        TALER_EC_GENERIC_DB_STORE_FAILED,
      77             :                                        NULL);
      78           0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      79           0 :     GNUNET_break (0);
      80           0 :     return TALER_MHD_reply_with_error (connection,
      81             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      82             :                                        TALER_EC_GENERIC_DB_SOFT_FAILURE,
      83             :                                        "Serialization error for single SQL statement");
      84           0 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      85           0 :     return TALER_MHD_reply_with_error (connection,
      86             :                                        MHD_HTTP_NOT_FOUND,
      87             :                                        TALER_EC_MERCHANT_PRIVATE_DELETE_RESERVES_NO_SUCH_RESERVE,
      88           0 :                                        hc->infix);
      89           0 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      90           0 :     return TALER_MHD_reply_static (connection,
      91             :                                    MHD_HTTP_NO_CONTENT,
      92             :                                    NULL,
      93             :                                    NULL,
      94             :                                    0);
      95             :   }
      96           0 :   GNUNET_assert (0);
      97             :   return MHD_NO;
      98             : }
      99             : 
     100             : 
     101             : /* end of taler-merchant-httpd_private-delete-reserves-ID.c */

Generated by: LCOV version 1.14