LCOV - code coverage report
Current view: top level - util - base_terms_serialize.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 2 2
Test Date: 2026-09-11 17:45:24 Functions: 100.0 % 1 1

            Line data    Source code
       1              : /*
       2              :   This file is part of GNU Taler
       3              :   Copyright (C) 2024, 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 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 src/util/base_terms_serialize.c
      18              :  * @brief shared logic for contract base terms serialization
      19              :  * @author Iván Ávalos
      20              :  * @author Christian Grothoff
      21              :  */
      22              : #include "platform.h"
      23              : #include <gnunet/gnunet_json_lib.h>
      24              : #include <gnunet/gnunet_common.h>
      25              : #include <taler/taler_json_lib.h>
      26              : #include <jansson.h>
      27              : #include "taler/taler_util.h"
      28              : #include "taler/taler_merchant_util.h"
      29              : 
      30              : 
      31              : /**
      32              :  * Serialize contract base terms into JSON object.
      33              :  *
      34              :  * @param[in] ct base contract terms to serialize
      35              :  * @return JSON representation of @a ct; NULL on error
      36              :  */
      37              : json_t *
      38          108 : TALER_MERCHANT_base_terms_serialize (
      39              :   const struct TALER_MERCHANT_ContractBaseTerms *ct)
      40              : {
      41          108 :   return GNUNET_JSON_PACK (
      42              :     GNUNET_JSON_pack_uint64 ("version",
      43              :                              ct->version),
      44              :     GNUNET_JSON_pack_string ("summary",
      45              :                              ct->summary),
      46              :     GNUNET_JSON_pack_allow_null (
      47              :       GNUNET_JSON_pack_object_incref ("summary_i18n",
      48              :                                       ct->summary_i18n)),
      49              :     GNUNET_JSON_pack_allow_null (
      50              :       GNUNET_JSON_pack_string ("public_reorder_url",
      51              :                                ct->public_reorder_url)),
      52              :     GNUNET_JSON_pack_allow_null (
      53              :       GNUNET_JSON_pack_string ("fulfillment_url",
      54              :                                ct->fulfillment_url)),
      55              :     GNUNET_JSON_pack_allow_null (
      56              :       GNUNET_JSON_pack_string ("fulfillment_message",
      57              :                                ct->fulfillment_message)),
      58              :     GNUNET_JSON_pack_allow_null (
      59              :       GNUNET_JSON_pack_object_incref ("fulfillment_message_i18n",
      60              :                                       ct->fulfillment_message_i18n)),
      61              :     GNUNET_JSON_pack_allow_null (
      62              :       GNUNET_JSON_pack_object_incref ("delivery_location",
      63              :                                       ct->delivery_location)),
      64              :     GNUNET_JSON_pack_allow_null (
      65              :       GNUNET_JSON_pack_timestamp ("delivery_date",
      66              :                                   ct->delivery_date)),
      67              :     GNUNET_JSON_pack_allow_null (
      68              :       GNUNET_JSON_pack_time_rel ("auto_refund",
      69              :                                  ct->auto_refund)),
      70              :     GNUNET_JSON_pack_allow_null (
      71              :       GNUNET_JSON_pack_object_incref ("extra",
      72              :                                       ct->extra)),
      73              :     GNUNET_JSON_pack_allow_null (
      74              :       GNUNET_JSON_pack_array_incref ("amount_external",
      75              :                                      ct->amount_external)),
      76              :     GNUNET_JSON_pack_allow_null (
      77              :       GNUNET_JSON_pack_uint64 ("minimum_age",
      78              :                                ct->minimum_age)),
      79              :     GNUNET_JSON_pack_conditional (
      80              :       0 != ct->default_money_pot,
      81              :       GNUNET_JSON_pack_uint64 ("order_default_money_pot",
      82              :                                ct->default_money_pot)),
      83              :     GNUNET_JSON_pack_conditional (
      84              :       ! GNUNET_TIME_absolute_is_never (ct->max_pickup_time.abs_time),
      85              :       GNUNET_JSON_pack_timestamp ("max_pickup_time",
      86              :                                   ct->max_pickup_time)));
      87              : }
        

Generated by: LCOV version 2.0-1