diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-get-templates-ID.c')
-rw-r--r-- | src/backend/taler-merchant-httpd_private-get-templates-ID.c | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/backend/taler-merchant-httpd_private-get-templates-ID.c b/src/backend/taler-merchant-httpd_private-get-templates-ID.c index 953582ca..35fdd1d0 100644 --- a/src/backend/taler-merchant-httpd_private-get-templates-ID.c +++ b/src/backend/taler-merchant-httpd_private-get-templates-ID.c @@ -23,18 +23,11 @@ #include <taler/taler_json_lib.h> -/** - * Handle a GET "/templates/$ID" request. - * - * @param rh context of the handler - * @param connection the MHD connection to handle - * @param[in,out] hc context with further information about the request - * @return MHD result code - */ MHD_RESULT -TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, - struct MHD_Connection *connection, - struct TMH_HandlerContext *hc) +TMH_private_get_templates_ID ( + const struct TMH_RequestHandler *rh, + struct MHD_Connection *connection, + struct TMH_HandlerContext *hc) { struct TMH_MerchantInstance *mi = hc->instance; struct TALER_MERCHANTDB_TemplateDetails tp = { 0 }; @@ -48,17 +41,19 @@ TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, if (0 > qs) { GNUNET_break (0); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_INTERNAL_SERVER_ERROR, - TALER_EC_GENERIC_DB_FETCH_FAILED, - "lookup_template"); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_INTERNAL_SERVER_ERROR, + TALER_EC_GENERIC_DB_FETCH_FAILED, + "lookup_template"); } - if (0 == qs) + if (GNUNET_DB_STATUS_SUCCESS_NO_RESULTS == qs) { - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_NOT_FOUND, - TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, - hc->infix); + return TALER_MHD_reply_with_error ( + connection, + MHD_HTTP_NOT_FOUND, + TALER_EC_MERCHANT_GENERIC_TEMPLATE_UNKNOWN, + hc->infix); } { MHD_RESULT ret; @@ -66,16 +61,20 @@ TMH_private_get_templates_ID (const struct TMH_RequestHandler *rh, ret = TALER_MHD_REPLY_JSON_PACK ( connection, MHD_HTTP_OK, + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_string ("required_currency", + tp.required_currency)), + GNUNET_JSON_pack_allow_null ( + GNUNET_JSON_pack_object_incref ("editable_defaults", + tp.editable_defaults)), GNUNET_JSON_pack_string ("template_description", tp.template_description), GNUNET_JSON_pack_allow_null ( - GNUNET_JSON_pack_string ("image", - tp.image)), - GNUNET_JSON_pack_object_steal ("template_contract", - tp.template_contract)); - GNUNET_free (tp.template_description); - GNUNET_free (tp.image); - + GNUNET_JSON_pack_string ("otp_id", + tp.otp_id)), + GNUNET_JSON_pack_object_incref ("template_contract", + tp.template_contract)); + TALER_MERCHANTDB_template_details_free (&tp); return ret; } } |