introduce TALER_JSON_pack_ec
This commit is contained in:
parent
f1f0bf637b
commit
d45774ccec
@ -69,11 +69,7 @@ reply_melt_insufficient_funds (
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_CONFLICT,
|
||||
GNUNET_JSON_pack_string ("hint",
|
||||
TALER_ErrorCode_get_hint (
|
||||
TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS)),
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS),
|
||||
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_MELT_INSUFFICIENT_FUNDS),
|
||||
GNUNET_JSON_pack_data_auto ("coin_pub",
|
||||
coin_pub),
|
||||
TALER_JSON_pack_amount ("original_value",
|
||||
|
@ -387,10 +387,7 @@ refreshes_reveal_transaction (void *cls,
|
||||
*mhd_ret = TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_CONFLICT,
|
||||
GNUNET_JSON_pack_string ("hint",
|
||||
TALER_ErrorCode_get_hint (
|
||||
TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION)),
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
TALER_JSON_pack_ec (
|
||||
TALER_EC_EXCHANGE_REFRESHES_REVEAL_COMMITMENT_VIOLATION),
|
||||
GNUNET_JSON_pack_data_auto ("rc_expected",
|
||||
&rc_expected));
|
||||
|
@ -233,11 +233,7 @@ refund_transaction (void *cls,
|
||||
MHD_HTTP_PRECONDITION_FAILED,
|
||||
TALER_JSON_pack_amount ("detail",
|
||||
&ref->refund_amount),
|
||||
GNUNET_JSON_pack_string ("hint",
|
||||
TALER_ErrorCode_get_hint (
|
||||
TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT)),
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT),
|
||||
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_REFUND_INCONSISTENT_AMOUNT),
|
||||
GNUNET_JSON_pack_array_steal ("history",
|
||||
TEH_RESPONSE_compile_transaction_history (
|
||||
&refund->coin.coin_pub,
|
||||
@ -332,10 +328,7 @@ refund_transaction (void *cls,
|
||||
MHD_HTTP_CONFLICT,
|
||||
GNUNET_JSON_pack_string ("detail",
|
||||
"total amount refunded exceeds total amount deposited for this coin"),
|
||||
GNUNET_JSON_pack_string ("hint",
|
||||
TALER_ErrorCode_get_hint (
|
||||
TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT)),
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
TALER_JSON_pack_ec (
|
||||
TALER_EC_EXCHANGE_REFUND_CONFLICT_DEPOSIT_INSUFFICIENT),
|
||||
GNUNET_JSON_pack_array_steal ("history",
|
||||
TEH_RESPONSE_compile_transaction_history (
|
||||
|
@ -450,8 +450,7 @@ TEH_RESPONSE_reply_unknown_denom_pub_hash (
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_NOT_FOUND,
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN),
|
||||
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_GENERIC_DENOMINATION_KEY_UNKNOWN),
|
||||
GNUNET_JSON_pack_time_abs ("timestamp",
|
||||
now),
|
||||
GNUNET_JSON_pack_data_auto ("exchange_pub",
|
||||
@ -501,8 +500,7 @@ TEH_RESPONSE_reply_expired_denom_pub_hash (
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_GONE,
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
ec),
|
||||
TALER_JSON_pack_ec (ec),
|
||||
GNUNET_JSON_pack_string ("oper",
|
||||
oper),
|
||||
GNUNET_JSON_pack_time_abs ("timestamp",
|
||||
@ -550,10 +548,7 @@ TEH_RESPONSE_reply_coin_insufficient_funds (
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_CONFLICT,
|
||||
GNUNET_JSON_pack_string ("hint",
|
||||
TALER_ErrorCode_get_hint (ec)),
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
ec),
|
||||
TALER_JSON_pack_ec (ec),
|
||||
GNUNET_JSON_pack_array_steal ("history",
|
||||
history));
|
||||
}
|
||||
|
@ -81,11 +81,7 @@ reply_withdraw_insufficient_funds (
|
||||
return TALER_MHD_REPLY_JSON_PACK (
|
||||
connection,
|
||||
MHD_HTTP_CONFLICT,
|
||||
GNUNET_JSON_pack_string ("hint",
|
||||
TALER_ErrorCode_get_hint (
|
||||
TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS)),
|
||||
GNUNET_JSON_pack_uint64 ("code",
|
||||
TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS),
|
||||
TALER_JSON_pack_ec (TALER_EC_EXCHANGE_WITHDRAW_INSUFFICIENT_FUNDS),
|
||||
TALER_JSON_pack_amount ("balance",
|
||||
&balance),
|
||||
GNUNET_JSON_pack_array_steal ("history",
|
||||
|
@ -79,6 +79,16 @@ TALER_JSON_pack_time_abs_nbo (const char *name,
|
||||
struct GNUNET_TIME_AbsoluteNBO at);
|
||||
|
||||
|
||||
/**
|
||||
* Put an error code into a JSON reply, including
|
||||
* both the numeric value and the hint.
|
||||
*
|
||||
* @param ec error code to encode using canonical field names
|
||||
*/
|
||||
#define TALER_JSON_pack_ec(ec) \
|
||||
GNUNET_JSON_pack_string ("hint", TALER_ErrorCode_get_hint (ec)), \
|
||||
GNUNET_JSON_pack_uint64 ("code", ec)
|
||||
|
||||
/**
|
||||
* Generate packer instruction for a JSON field of type
|
||||
* absolute time creating a human-readable timestamp.
|
||||
|
Loading…
Reference in New Issue
Block a user