LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-delete-transfers-ID.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 61.5 % 26 16
Test Date: 2025-11-28 21:09:21 Functions: 100.0 % 1 1

            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              : MHD_RESULT
      27            4 : TMH_private_delete_transfers_ID (const struct TMH_RequestHandler *rh,
      28              :                                  struct MHD_Connection *connection,
      29              :                                  struct TMH_HandlerContext *hc)
      30              : {
      31            4 :   struct TMH_MerchantInstance *mi = hc->instance;
      32              :   enum GNUNET_DB_QueryStatus qs;
      33              :   unsigned long long serial;
      34              :   char dummy;
      35              : 
      36              :   (void) rh;
      37            4 :   GNUNET_assert (NULL != mi);
      38            4 :   if (1 !=
      39            4 :       sscanf (hc->infix,
      40              :               "%llu%c",
      41              :               &serial,
      42              :               &dummy))
      43              :   {
      44            0 :     return TALER_MHD_reply_with_error (connection,
      45              :                                        MHD_HTTP_BAD_REQUEST,
      46              :                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
      47            0 :                                        hc->infix);
      48              :   }
      49            4 :   qs = TMH_db->delete_transfer (TMH_db->cls,
      50            4 :                                 mi->settings.id,
      51              :                                 serial);
      52            4 :   switch (qs)
      53              :   {
      54            0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      55            0 :     return TALER_MHD_reply_with_error (connection,
      56              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      57              :                                        TALER_EC_GENERIC_DB_COMMIT_FAILED,
      58              :                                        NULL);
      59            0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      60            0 :     GNUNET_break (0);
      61            0 :     return TALER_MHD_reply_with_error (connection,
      62              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      63              :                                        TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
      64              :                                        NULL);
      65            1 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      66            1 :     qs = TMH_db->check_transfer_exists (TMH_db->cls,
      67            1 :                                         mi->settings.id,
      68              :                                         serial);
      69            1 :     if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      70            1 :       return TALER_MHD_reply_with_error (connection,
      71              :                                          MHD_HTTP_NOT_FOUND,
      72              :                                          TALER_EC_MERCHANT_GENERIC_TRANSFER_UNKNOWN,
      73            1 :                                          hc->infix);
      74            0 :     return TALER_MHD_reply_with_error (connection,
      75              :                                        MHD_HTTP_CONFLICT,
      76              :                                        TALER_EC_MERCHANT_PRIVATE_DELETE_TRANSFERS_ALREADY_CONFIRMED,
      77            0 :                                        hc->infix);
      78            3 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      79            3 :     return TALER_MHD_reply_static (connection,
      80              :                                    MHD_HTTP_NO_CONTENT,
      81              :                                    NULL,
      82              :                                    NULL,
      83              :                                    0);
      84              :   }
      85            0 :   GNUNET_assert (0);
      86              :   return MHD_NO;
      87              : }
      88              : 
      89              : 
      90              : /* end of taler-merchant-httpd_private-delete-transfers-ID.c */
        

Generated by: LCOV version 2.0-1