LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_private-get-token-families.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 14 0.0 %
Date: 2025-06-23 16:22:09 Functions: 0 2 0.0 %

          Line data    Source code
       1             : /*
       2             :   This file is part of TALER
       3             :   (C) 2023 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-token-families.c
      18             :  * @brief implement GET /tokenfamilies
      19             :  * @author Christian Blättler
      20             :  */
      21             : #include "platform.h"
      22             : #include "taler-merchant-httpd_private-get-token-families.h"
      23             : 
      24             : 
      25             : 
      26             : /**
      27             :  * Add token family details to our JSON array.
      28             :  *
      29             :  * @param cls a `json_t *` JSON array to build
      30             :  * @param slug slug of the token family
      31             :  * @param name name of the token family
      32             :  * @param valid_after start time of the token family's validity period
      33             :  * @param valid_before end time of the token family's validity period
      34             :  * @param kind kind of the token family
      35             :  */
      36             : static void
      37           0 : add_token_family (void *cls,
      38             :                   const char *slug,
      39             :                   const char *name,
      40             :                   struct GNUNET_TIME_Timestamp valid_after,
      41             :                   struct GNUNET_TIME_Timestamp valid_before,
      42             :                   const char *kind)
      43             : {
      44           0 :   json_t *pa = cls;
      45             : 
      46           0 :   GNUNET_assert (0 ==
      47             :                   json_array_append_new (
      48             :                     pa,
      49             :                     GNUNET_JSON_PACK (
      50             :                       GNUNET_JSON_pack_string ("slug", slug),
      51             :                       GNUNET_JSON_pack_string ("name", name),
      52             :                       GNUNET_JSON_pack_timestamp ("valid_after", valid_after),
      53             :                       GNUNET_JSON_pack_timestamp ("valid_before", valid_before),
      54             :                       GNUNET_JSON_pack_string ("kind", kind))));
      55           0 : }
      56             : 
      57             : 
      58             : MHD_RESULT
      59           0 : TMH_private_get_tokenfamilies (const struct TMH_RequestHandler *rh,
      60             :                                struct MHD_Connection *connection,
      61             :                                struct TMH_HandlerContext *hc)
      62             : {
      63             :   json_t *families;
      64             :   enum GNUNET_DB_QueryStatus qs;
      65             : 
      66           0 :   families = json_array ();
      67           0 :   GNUNET_assert (NULL != families);
      68           0 :   qs = TMH_db->lookup_token_families (TMH_db->cls,
      69           0 :                                       hc->instance->settings.id,
      70             :                                       &add_token_family,
      71             :                                       families);
      72           0 :   if (0 > qs)
      73             :   {
      74           0 :     GNUNET_break (0);
      75           0 :     json_decref (families);
      76           0 :     return TALER_MHD_reply_with_error (connection,
      77             :                                        MHD_HTTP_INTERNAL_SERVER_ERROR,
      78             :                                        TALER_EC_GENERIC_DB_FETCH_FAILED,
      79             :                                        NULL);
      80             :   }
      81           0 :   return TALER_MHD_REPLY_JSON_PACK (connection,
      82             :                                     MHD_HTTP_OK,
      83             :                                     GNUNET_JSON_pack_array_steal ("token_families",
      84             :                                                                   families));
      85             : }
      86             : 
      87             : 
      88             : /* end of taler-merchant-httpd_private-get-token-families.c */

Generated by: LCOV version 1.16