LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-post-groups.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 17 0
Test Date: 2025-12-29 21:26:17 Functions: 0.0 % 1 0

            Line data    Source code
       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 merchant/backend/taler-merchant-httpd_private-post-groups.c
      20              :  * @brief implementation of POST /private/groups
      21              :  * @author Christian Grothoff
      22              :  */
      23              : #include "platform.h"
      24              : #include "taler-merchant-httpd_private-post-groups.h"
      25              : #include <taler/taler_json_lib.h>
      26              : 
      27              : 
      28              : MHD_RESULT
      29            0 : TMH_private_post_groups (const struct TMH_RequestHandler *rh,
      30              :                          struct MHD_Connection *connection,
      31              :                          struct TMH_HandlerContext *hc)
      32              : {
      33              :   const char *group_name;
      34              :   const char *description;
      35              :   enum GNUNET_DB_QueryStatus qs;
      36              :   uint64_t group_id;
      37              :   struct GNUNET_JSON_Specification spec[] = {
      38            0 :     GNUNET_JSON_spec_string ("group_name",
      39              :                              &group_name),
      40            0 :     GNUNET_JSON_spec_string ("description",
      41              :                              &description),
      42            0 :     GNUNET_JSON_spec_end ()
      43              :   };
      44              : 
      45              :   (void) rh;
      46              :   {
      47              :     enum GNUNET_GenericReturnValue res;
      48              : 
      49            0 :     res = TALER_MHD_parse_json_data (connection,
      50            0 :                                      hc->request_body,
      51              :                                      spec);
      52            0 :     if (GNUNET_OK != res)
      53              :     {
      54            0 :       GNUNET_break_op (0);
      55              :       return (GNUNET_NO == res)
      56              :              ? MHD_YES
      57            0 :              : MHD_NO;
      58              :     }
      59              :   }
      60              : 
      61            0 :   qs = TMH_db->insert_product_group (TMH_db->cls,
      62            0 :                                      hc->instance->settings.id,
      63              :                                      group_name,
      64              :                                      description,
      65              :                                      &group_id);
      66            0 :   if (qs < 0)
      67              :   {
      68            0 :     GNUNET_break (0);
      69            0 :     return TALER_MHD_reply_with_error (connection,
      70              :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      71              :                                        TALER_EC_GENERIC_DB_STORE_FAILED,
      72              :                                        "insert_product_group");
      73              :   }
      74            0 :   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      75              :   {
      76              :     /* Zero will be returned on conflict */
      77            0 :     return TALER_MHD_reply_with_error (connection,
      78              :                                        MHD_HTTP_CONFLICT,
      79              :                                        TALER_EC_MERCHANT_PRIVATE_PRODUCT_GROUP_CONFLICTING_NAME,
      80              :                                        group_name);
      81              :   }
      82              : 
      83            0 :   return TALER_MHD_REPLY_JSON_PACK (
      84              :     connection,
      85              :     MHD_HTTP_OK,
      86              :     GNUNET_JSON_pack_uint64 ("group_serial_id",
      87              :                              group_id));
      88              : }
        

Generated by: LCOV version 2.0-1