mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 11:24:45 +08:00
taking request and response both for detail extraction
This commit is contained in:
@ -806,8 +806,13 @@ where
|
||||
}
|
||||
};
|
||||
|
||||
let values: Vec<&serde_json::Value> = [Some(&serialized_request), serialized_response.as_ref()]
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect();
|
||||
|
||||
let infra = extract_mapped_fields(
|
||||
&serialized_request,
|
||||
&values,
|
||||
state.enhancement.as_ref(),
|
||||
state.infra_components.as_ref(),
|
||||
);
|
||||
@ -2341,7 +2346,7 @@ pub fn get_payment_link_status(
|
||||
}
|
||||
|
||||
pub fn extract_mapped_fields(
|
||||
value: &serde_json::Value,
|
||||
values: &[&serde_json::Value],
|
||||
mapping: Option<&HashMap<String, String>>,
|
||||
existing_enhancement: Option<&serde_json::Value>,
|
||||
) -> Option<serde_json::Value> {
|
||||
@ -2357,9 +2362,19 @@ pub fn extract_mapped_fields(
|
||||
};
|
||||
|
||||
for (dot_path, output_key) in mapping {
|
||||
if let Some(extracted_value) = extract_field_by_dot_path(value, dot_path) {
|
||||
let mut extracted_value = None;
|
||||
|
||||
// Try to extract from values in order of priority
|
||||
for value in values {
|
||||
if let Some(found_value) = extract_field_by_dot_path(value, dot_path) {
|
||||
extracted_value = Some(found_value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(value) = extracted_value {
|
||||
if let Some(obj) = enhancement.as_object_mut() {
|
||||
obj.insert(output_key.clone(), extracted_value);
|
||||
obj.insert(output_key.clone(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user