add logic to parse AML decisions response
This commit is contained in:
parent
f60b09f8ef
commit
a703171f08
@ -123,12 +123,14 @@ parse_kyc_attributes (const json_t *kyc_attributes,
|
|||||||
json_array_foreach (kyc_attributes, idx, obj)
|
json_array_foreach (kyc_attributes, idx, obj)
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_KycHistoryDetail *kyc = &kyc_attributes_ar[idx];
|
struct TALER_EXCHANGE_KycHistoryDetail *kyc = &kyc_attributes_ar[idx];
|
||||||
json_t *attributes;
|
json_t *attributes = NULL;
|
||||||
struct GNUNET_JSON_Specification spec[] = {
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
GNUNET_JSON_spec_timestamp ("collection_time",
|
GNUNET_JSON_spec_timestamp ("collection_time",
|
||||||
&kyc->collection_time),
|
&kyc->collection_time),
|
||||||
GNUNET_JSON_spec_json ("attributes",
|
GNUNET_JSON_spec_mark_optional (
|
||||||
&attributes),
|
GNUNET_JSON_spec_json ("attributes",
|
||||||
|
&attributes),
|
||||||
|
NULL),
|
||||||
GNUNET_JSON_spec_string ("provider_section",
|
GNUNET_JSON_spec_string ("provider_section",
|
||||||
&kyc->provider_section),
|
&kyc->provider_section),
|
||||||
GNUNET_JSON_spec_end ()
|
GNUNET_JSON_spec_end ()
|
||||||
@ -187,10 +189,10 @@ parse_decision_ok (struct TALER_EXCHANGE_LookupAmlDecision *lh,
|
|||||||
lr.details.success.aml_history_length = json_array_size (aml_history);
|
lr.details.success.aml_history_length = json_array_size (aml_history);
|
||||||
lr.details.success.kyc_attributes_length = json_array_size (kyc_attributes);
|
lr.details.success.kyc_attributes_length = json_array_size (kyc_attributes);
|
||||||
{
|
{
|
||||||
struct TALER_EXCHANGE_AmlDecisionDetail aml_history_ar
|
struct TALER_EXCHANGE_AmlDecisionDetail aml_history_ar[
|
||||||
[GNUNET_NZL (lr.details.success.aml_history_length)];
|
GNUNET_NZL (lr.details.success.aml_history_length)];
|
||||||
struct TALER_EXCHANGE_KycHistoryDetail kyc_attributes_ar
|
struct TALER_EXCHANGE_KycHistoryDetail kyc_attributes_ar[
|
||||||
[lr.details.success.kyc_attributes_length];
|
lr.details.success.kyc_attributes_length];
|
||||||
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
|
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
|
||||||
|
|
||||||
lr.details.success.aml_history = aml_history_ar;
|
lr.details.success.aml_history = aml_history_ar;
|
||||||
|
@ -63,6 +63,49 @@ struct TALER_EXCHANGE_LookupAmlDecisions
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse AML decision summary array.
|
||||||
|
*
|
||||||
|
* @param decisions JSON array with AML decision summaries
|
||||||
|
* @param[out] decision_ar where to write the result
|
||||||
|
* @return #GNUNET_OK on success
|
||||||
|
*/
|
||||||
|
static enum GNUNET_GenericReturnValue
|
||||||
|
parse_aml_decisions (const json_t *decisions,
|
||||||
|
struct TALER_EXCHANGE_AmlDecisionSummary *decision_ar)
|
||||||
|
{
|
||||||
|
json_t *obj;
|
||||||
|
size_t idx;
|
||||||
|
|
||||||
|
json_array_foreach (decisions, idx, obj)
|
||||||
|
{
|
||||||
|
struct TALER_EXCHANGE_AmlDecisionSummary *decision = &decision_ar[idx];
|
||||||
|
uint32_t state32;
|
||||||
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
|
GNUNET_JSON_spec_timestamp ("last_decision_time",
|
||||||
|
&decision->last_decision_time),
|
||||||
|
GNUNET_JSON_spec_fixed_auto ("h_payto",
|
||||||
|
&decision->h_payto),
|
||||||
|
GNUNET_JSON_spec_uint32 ("current_state",
|
||||||
|
&state32),
|
||||||
|
GNUNET_JSON_spec_end ()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (GNUNET_OK !=
|
||||||
|
GNUNET_JSON_parse (obj,
|
||||||
|
spec,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
decision->current_state = (enum TALER_AmlDecisionState) state32;
|
||||||
|
}
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse the provided decision data from the "200 OK" response.
|
* Parse the provided decision data from the "200 OK" response.
|
||||||
*
|
*
|
||||||
@ -78,10 +121,39 @@ parse_decisions_ok (struct TALER_EXCHANGE_LookupAmlDecisions *lh,
|
|||||||
.hr.reply = json,
|
.hr.reply = json,
|
||||||
.hr.http_status = MHD_HTTP_OK
|
.hr.http_status = MHD_HTTP_OK
|
||||||
};
|
};
|
||||||
int ret = GNUNET_SYSERR;
|
json_t *records;
|
||||||
|
struct GNUNET_JSON_Specification spec[] = {
|
||||||
|
GNUNET_JSON_spec_json ("records",
|
||||||
|
&records),
|
||||||
|
GNUNET_JSON_spec_end ()
|
||||||
|
};
|
||||||
|
|
||||||
GNUNET_break (0); // FIXME: parse response!
|
if (GNUNET_OK !=
|
||||||
return ret;
|
GNUNET_JSON_parse (json,
|
||||||
|
spec,
|
||||||
|
NULL,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
GNUNET_break_op (0);
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
}
|
||||||
|
lr.details.success.decisions_length = json_array_size (records);
|
||||||
|
{
|
||||||
|
struct TALER_EXCHANGE_AmlDecisionSummary decisions[
|
||||||
|
GNUNET_NZL (lr.details.success.decisions_length)];
|
||||||
|
enum GNUNET_GenericReturnValue ret = GNUNET_SYSERR;
|
||||||
|
|
||||||
|
lr.details.success.decisions = decisions;
|
||||||
|
ret = parse_aml_decisions (records,
|
||||||
|
decisions);
|
||||||
|
if (GNUNET_OK == ret)
|
||||||
|
{
|
||||||
|
lh->decisions_cb (lh->decisions_cb_cls,
|
||||||
|
&lr);
|
||||||
|
lh->decisions_cb = NULL;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user