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

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

Generated by: LCOV version 2.0-1