LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-delete-orders-ID.c (source / functions) Hit Total Coverage
Test: GNU Taler merchant coverage report Lines: 26 32 81.2 %
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) 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-orders-ID.c
      18             :  * @brief implement DELETE /orders/$ID
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler-merchant-httpd_private-delete-orders-ID.h"
      23             : #include <taler/taler_json_lib.h>
      24             : 
      25             : 
      26             : /**
      27             :  * Handle a DELETE "/orders/$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           3 : TMH_private_delete_orders_ID (const struct TMH_RequestHandler *rh,
      36             :                               struct MHD_Connection *connection,
      37             :                               struct TMH_HandlerContext *hc)
      38             : {
      39           3 :   struct TMH_MerchantInstance *mi = hc->instance;
      40             :   enum GNUNET_DB_QueryStatus qs;
      41             : 
      42           3 :   GNUNET_assert (NULL != mi);
      43           3 :   qs = TMH_db->delete_order (TMH_db->cls,
      44           3 :                              mi->settings.id,
      45           3 :                              hc->infix);
      46           3 :   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      47           2 :     qs = TMH_db->delete_contract_terms (TMH_db->cls,
      48           2 :                                         mi->settings.id,
      49           2 :                                         hc->infix,
      50             :                                         TMH_legal_expiration);
      51           3 :   switch (qs)
      52             :   {
      53           0 :   case GNUNET_DB_STATUS_HARD_ERROR:
      54           0 :     return TALER_MHD_reply_with_error (connection,
      55             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      56             :                                        TALER_EC_GENERIC_DB_COMMIT_FAILED,
      57             :                                        NULL);
      58           0 :   case GNUNET_DB_STATUS_SOFT_ERROR:
      59           0 :     GNUNET_break (0);
      60           0 :     return TALER_MHD_reply_with_error (connection,
      61             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      62             :                                        TALER_EC_GENERIC_INTERNAL_INVARIANT_FAILURE,
      63             :                                        NULL);
      64           2 :   case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
      65             :     {
      66             :       struct GNUNET_HashCode unused;
      67             : 
      68           2 :       qs = TMH_db->lookup_order (TMH_db->cls,
      69           2 :                                  mi->settings.id,
      70           2 :                                  hc->infix,
      71             :                                  NULL,
      72             :                                  &unused,
      73             :                                  NULL);
      74             :     }
      75           2 :     if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      76             :     {
      77             :       uint64_t order_serial;
      78             : 
      79           2 :       qs = TMH_db->lookup_contract_terms (TMH_db->cls,
      80           2 :                                           mi->settings.id,
      81           2 :                                           hc->infix,
      82             :                                           NULL,
      83             :                                           &order_serial,
      84             :                                           NULL);
      85             :     }
      86           2 :     if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      87           1 :       return TALER_MHD_reply_with_error (connection,
      88             :                                          MHD_HTTP_NOT_FOUND,
      89             :                                          TALER_EC_MERCHANT_GENERIC_ORDER_UNKNOWN,
      90           1 :                                          hc->infix);
      91           1 :     return TALER_MHD_reply_with_error (connection,
      92             :                                        MHD_HTTP_CONFLICT,
      93             :                                        TALER_EC_MERCHANT_PRIVATE_DELETE_ORDERS_AWAITING_PAYMENT,
      94           1 :                                        hc->infix);
      95           1 :   case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
      96           1 :     return TALER_MHD_reply_static (connection,
      97             :                                    MHD_HTTP_NO_CONTENT,
      98             :                                    NULL,
      99             :                                    NULL,
     100             :                                    0);
     101             :   }
     102           0 :   GNUNET_assert (0);
     103             :   return MHD_NO;
     104             : }
     105             : 
     106             : 
     107             : /* end of taler-merchant-httpd_private-delete-orders-ID.c */

Generated by: LCOV version 1.14