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

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (C) 2019, 2020, 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-get-products.c
      18             :  * @brief implement GET /products
      19             :  * @author Christian Grothoff
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler-merchant-httpd_private-get-products.h"
      23             : 
      24             : 
      25             : /**
      26             :  * Add product details to our JSON array.
      27             :  *
      28             :  * @param cls a `json_t *` JSON array to build
      29             :  * @param product_id ID of the product
      30             :  */
      31             : static void
      32           0 : add_product (void *cls,
      33             :              const char *product_id)
      34             : {
      35           0 :   json_t *pa = cls;
      36             : 
      37           0 :   GNUNET_assert (0 ==
      38             :                  json_array_append_new (
      39             :                    pa,
      40             :                    GNUNET_JSON_PACK (
      41             :                      GNUNET_JSON_pack_string ("product_id",
      42             :                                               product_id))));
      43           0 : }
      44             : 
      45             : 
      46             : MHD_RESULT
      47           0 : TMH_private_get_products (const struct TMH_RequestHandler *rh,
      48             :                           struct MHD_Connection *connection,
      49             :                           struct TMH_HandlerContext *hc)
      50             : {
      51             :   json_t *pa;
      52             :   enum GNUNET_DB_QueryStatus qs;
      53             : 
      54           0 :   pa = json_array ();
      55           0 :   GNUNET_assert (NULL != pa);
      56           0 :   qs = TMH_db->lookup_products (TMH_db->cls,
      57           0 :                                 hc->instance->settings.id,
      58             :                                 &add_product,
      59             :                                 pa);
      60           0 :   if (0 > qs)
      61             :   {
      62           0 :     GNUNET_break (0);
      63           0 :     json_decref (pa);
      64           0 :     return TALER_MHD_reply_with_error (connection,
      65             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      66             :                                        TALER_EC_GENERIC_DB_FETCH_FAILED,
      67             :                                        NULL);
      68             :   }
      69           0 :   return TALER_MHD_REPLY_JSON_PACK (connection,
      70             :                                     MHD_HTTP_OK,
      71             :                                     GNUNET_JSON_pack_array_steal ("products",
      72             :                                                                   pa));
      73             : }
      74             : 
      75             : 
      76             : /* end of taler-merchant-httpd_private-get-products.c */

Generated by: LCOV version 1.14