LCOV - code coverage report
Current view: top level - backend - taler-merchant-httpd_get-templates-ID.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 16 0
Test Date: 2025-11-06 19:31:41 Functions: 0.0 % 1 0

            Line data    Source code
       1              : /*
       2              :   This file is part of TALER
       3              :   (C) 2022-2024 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-templates-ID.c
      18              :  * @brief implement GET /templates/$ID
      19              :  * @author Priscilla HUANG
      20              :  */
      21              : #include "platform.h"
      22              : #include "taler-merchant-httpd_get-templates-ID.h"
      23              : #include <taler/taler_json_lib.h>
      24              : 
      25              : 
      26              : MHD_RESULT
      27            0 : TMH_get_templates_ID (
      28              :   const struct TMH_RequestHandler *rh,
      29              :   struct MHD_Connection *connection,
      30              :   struct TMH_HandlerContext *hc)
      31              : {
      32            0 :   struct TMH_MerchantInstance *mi = hc->instance;
      33            0 :   struct TALER_MERCHANTDB_TemplateDetails tp = { 0 };
      34              :   enum GNUNET_DB_QueryStatus qs;
      35              : 
      36            0 :   GNUNET_assert (NULL != mi);
      37            0 :   qs = TMH_db->lookup_template (TMH_db->cls,
      38            0 :                                 mi->settings.id,
      39            0 :                                 hc->infix,
      40              :                                 &tp);
      41            0 :   if (0 > qs)
      42              :   {
      43            0 :     GNUNET_break (0);
      44            0 :     return TALER_MHD_reply_with_error (
      45              :       connection,
      46              :       MHD_HTTP_INTERNAL_SERVER_ERROR,
      47              :       TALER_EC_GENERIC_DB_FETCH_FAILED,
      48              :       "lookup_template");
      49              :   }
      50            0 :   if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs)
      51              :   {
      52            0 :     return TALER_MHD_reply_with_error (
      53              :       connection,
      54              :       MHD_HTTP_NOT_FOUND,
      55              :       TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN,
      56            0 :       hc->infix);
      57              :   }
      58              :   {
      59              :     MHD_RESULT ret;
      60              : 
      61            0 :     ret = TALER_MHD_REPLY_JSON_PACK (
      62              :       connection,
      63              :       MHD_HTTP_OK,
      64              :       GNUNET_JSON_pack_allow_null (
      65              :         GNUNET_JSON_pack_object_incref ("editable_defaults",
      66              :                                         tp.editable_defaults)),
      67              :       GNUNET_JSON_pack_object_incref ("template_contract",
      68              :                                       tp.template_contract));
      69            0 :     TALER_MERCHANTDB_template_details_free (&tp);
      70            0 :     return ret;
      71              :   }
      72              : }
      73              : 
      74              : 
      75              : /* end of taler-merchant-httpd_get-templates-ID.c */
        

Generated by: LCOV version 2.0-1