summaryrefslogtreecommitdiff
path: root/src/bank-lib/bank_api_admin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bank-lib/bank_api_admin.c')
-rw-r--r--src/bank-lib/bank_api_admin.c52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/bank-lib/bank_api_admin.c b/src/bank-lib/bank_api_admin.c
index 77b1a38e4..f12ab6ee2 100644
--- a/src/bank-lib/bank_api_admin.c
+++ b/src/bank-lib/bank_api_admin.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2015--2020 Taler Systems SA
+ Copyright (C) 2015--2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -16,7 +16,7 @@
*/
/**
* @file bank-lib/bank_api_admin.c
- * @brief Implementation of the /admin/ requests of the bank's HTTP API
+ * @brief Implementation of the /admin/add-incoming requests of the bank's HTTP API
* @author Christian Grothoff
*/
#include "platform.h"
@@ -27,7 +27,7 @@
/**
- * @brief An admin/add-incoming Handle
+ * @brief An /admin/add-incoming Handle
*/
struct TALER_BANK_AdminAddIncomingHandle
{
@@ -74,25 +74,25 @@ handle_admin_add_incoming_finished (void *cls,
const void *response)
{
struct TALER_BANK_AdminAddIncomingHandle *aai = cls;
- uint64_t row_id = UINT64_MAX;
- struct GNUNET_TIME_Timestamp timestamp;
- enum TALER_ErrorCode ec;
const json_t *j = response;
+ struct TALER_BANK_AdminAddIncomingResponse ir = {
+ .http_status = response_code,
+ .response = response
+ };
aai->job = NULL;
- timestamp = GNUNET_TIME_UNIT_FOREVER_TS;
switch (response_code)
{
case 0:
- ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ ir.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
case MHD_HTTP_OK:
{
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_uint64 ("row_id",
- &row_id),
+ &ir.details.ok.serial_id),
GNUNET_JSON_spec_timestamp ("timestamp",
- &timestamp),
+ &ir.details.ok.timestamp),
GNUNET_JSON_spec_end ()
};
@@ -102,42 +102,41 @@ handle_admin_add_incoming_finished (void *cls,
NULL, NULL))
{
GNUNET_break_op (0);
- response_code = 0;
- ec = TALER_EC_GENERIC_INVALID_RESPONSE;
+ ir.http_status = 0;
+ ir.ec = TALER_EC_GENERIC_INVALID_RESPONSE;
break;
}
- ec = TALER_EC_NONE;
}
break;
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the bank is buggy
(or API version conflict); just pass JSON reply to the application */
GNUNET_break_op (0);
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_FORBIDDEN:
/* Access denied */
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_UNAUTHORIZED:
/* Nothing really to verify, bank says the password is invalid; we should
pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_NOT_FOUND:
/* Nothing really to verify, maybe account really does not exist.
We should pass the JSON reply to the application */
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_CONFLICT:
/* Nothing to verify, we used the same wire subject
twice? */
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
default:
/* unexpected response code */
@@ -145,15 +144,11 @@ handle_admin_add_incoming_finished (void *cls,
"Unexpected response code %u\n",
(unsigned int) response_code);
GNUNET_break (0);
- ec = TALER_JSON_get_error_code (j);
+ ir.ec = TALER_JSON_get_error_code (j);
break;
}
aai->cb (aai->cb_cls,
- response_code,
- ec,
- row_id,
- timestamp,
- j);
+ &ir);
TALER_BANK_admin_add_incoming_cancel (aai);
}
@@ -215,9 +210,10 @@ TALER_BANK_admin_add_incoming (
"Requesting administrative transaction at `%s' for reserve %s\n",
aai->request_url,
TALER_B2S (reserve_pub));
- aai->post_ctx.headers = curl_slist_append
- (aai->post_ctx.headers,
- "Content-Type: application/json");
+ aai->post_ctx.headers
+ = curl_slist_append (
+ aai->post_ctx.headers,
+ "Content-Type: application/json");
eh = curl_easy_init ();
if ( (NULL == eh) ||