LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-delete-transfers-ID.c (source / functions) Hit Total Coverage
Test: GNU Taler merchant coverage report Lines: 10 26 38.5 %
Date: 2021-08-30 06:54:17 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (C) 2021 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-transfers-ID.c
      18             :  * @brief implement DELETE /transfers/$ID
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler-merchant-httpd_private-delete-transfers-ID.h"
      23             : #include <taler/taler_json_lib.h>
      24             : 
      25             : 
      26             : /**
      27             :  * Handle a DELETE "/private/transfers/$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           1 : TMH_private_delete_transfers_ID (const struct TMH_RequestHandler *rh,
      36             :                                  struct MHD_Connection *connection,
      37             :                                  struct TMH_HandlerContext *hc)
      38             : {
      39           1 :   struct TMH_MerchantInstance *mi = hc->instance;
      40             :   enum GNUNET_DB_QueryStatus qs;
      41             :   unsigned long long serial;
      42             :   char dummy;
      43             : 
      44           1 :   GNUNET_assert (NULL != mi);
      45           1 :   if (1 !=
      46           1 :       sscanf (hc->infix,
      47             :               "%llu%c",
      48             :               &serial,
      49             :               &dummy))
      50             :   {
      51           0 :     return TALER_MHD_reply_with_error (connection,
      52             :                                        MHD_HTTP_BAD_REQUEST,
      53             :                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
      54           0 :                                        hc->infix);
      55             :   }
      56           1 :   qs = TMH_db->delete_transfer (TMH_db->cls,
      57           1 :                                 mi->settings.id,
      58             :                                 serial);
      59           1 :   switch (qs)
      60             :   {
      61           0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      62           0 :     return TALER_MHD_reply_with_error (connection,
      63             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      64             :                                        TALER_EC_GENERIC_DB_COMMIT_FAILED,
      65             :                                        NULL);
      66           0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      67           0 :     GNUNET_break (0);
      68           0 :     return TALER_MHD_reply_with_error (connection,
      69             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      70             :                                        TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
      71             :                                        NULL);
      72           0 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      73           0 :     qs = TMH_db->check_transfer_exists (TMH_db->cls,
      74           0 :                                         mi->settings.id,
      75             :                                         serial);
      76           0 :     if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      77           0 :       return TALER_MHD_reply_with_error (connection,
      78             :                                          MHD_HTTP_NOT_FOUND,
      79             :                                          TALER_EC_MERCHANT_GENERIC_TRANSFER_UNKNOWN,
      80           0 :                                          hc->infix);
      81           0 :     return TALER_MHD_reply_with_error (connection,
      82             :                                        MHD_HTTP_CONFLICT,
      83             :                                        TALER_EC_MERCHANT_PRIVATE_DELETE_TRANSFERS_ALREADY_CONFIRMED,
      84           0 :                                        hc->infix);
      85           1 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      86           1 :     return TALER_MHD_reply_static (connection,
      87             :                                    MHD_HTTP_NO_CONTENT,
      88             :                                    NULL,
      89             :                                    NULL,
      90             :                                    0);
      91             :   }
      92           0 :   GNUNET_assert (0);
      93             :   return MHD_NO;
      94             : }
      95             : 
      96             : 
      97             : /* end of taler-merchant-httpd_private-delete-transfers-ID.c */

Generated by: LCOV version 1.14