using System.Text.Json.Serialization;
using System.Collections.Generic;
public class SiftCreateOrderResponse
[JsonPropertyName("status")]
public long Status { get; set; } = default;
[JsonPropertyName("error_message")]
public string ErrorMessage { get; set; } = default;
[JsonPropertyName("score_response")]
public ScoreResponse ScoreResponse { get; set; } = new();
public class ScoreResponse
[JsonPropertyName("status")]
public long Status { get; set; } = default;
[JsonPropertyName("error_message")]
public string ErrorMessage { get; set; } = default;
[JsonPropertyName("workflow_statuses")]
public List<WorkflowStatus> WorkflowStatuses { get; set; } = new();
public class WorkflowStatus
[JsonPropertyName("entity")]
public WorkflowEntity Entity { get; set; } = new();
[JsonPropertyName("history")]
public List<WorkflowStatusHistory> Histories { get; set; } = new();
public class WorkflowEntity
public string Id { get; set; } = default;
[JsonPropertyName("type")]
public string Type { get; set; } = default;
public class WorkflowStatusHistory
[JsonPropertyName("app")]
public string App { get; set; } = default;
[JsonPropertyName("name")]
public string Name { get; set; } = default;
[JsonPropertyName("state")]
public string State { get; set; } = default;
[JsonPropertyName("config")]
public WorkflagStatusHistoryConfig Config { get; set; } = new();
public class WorkflagStatusHistoryConfig
[JsonPropertyName("decision_id")]
public string DecisionId { get; set; } = default;
public static void Main()
var response = JsonSerializer.Deserialize<SiftCreateOrderResponse>("""{"status": 0,"error_message": "OK","time": 1716472711,"request": "{\"$type\":\"$create_order\",\"$api_key\":\"a2d37bf2********\",\"$user_id\":\"355fffec-7d74-4f40-9bfd-0477b40123fa\",\"$session_id\":\"1716472511094\",\"$ip\":\"61.246.254.84\",\"$order_id\":\"86971050\",\"$user_email\":\"akshay22395@gmail.com\",\"$amount\":2963290000,\"$currency_code\":\"INR\",\"$shipping_address\":{\"$name\":\"Akshay Kumar\",\"$address_1\":\"TTFTF\",\"$address_2\":\"Y\",\"$city\":\"Gurugram\",\"$country\":\"IN\",\"$phone\":\"7830888053\",\"$zipcode\":\"122008\"},\"$billing_address\":{\"$name\":\"Akshay Kumar\",\"$address_1\":\"TTFTF\",\"$address_2\":\"Y\",\"$city\":\"Gurugram\",\"$country\":\"IN\",\"$phone\":\"\",\"$zipcode\":\"122008\"},\"$payment_methods\":[{\"$payment_type\":\"$store_credit\"}],\"$shipping_method\":\"$physical\",\"$items\":[{\"$item_id\":\"5864775\",\"$product_title\":\"IC CURRENT TRANSMITTER 8VSSOP\",\"$price\":176329000,\"$currency_code\":\"INR\",\"$quantity\":10,\"$sku\":\"5864775\",\"$brand\":\"Texas Instruments\",\"$manufacturer\":\"Texas Instruments\",\"$category\":\"INTERFACE IC MISC\"}]}","score_response": {"status": 0,"error_message": "OK","scores": {"payment_abuse": {"score": 0.8271500468254089,"reasons": [{"name": "Estimated email address age","value": "1.24 hours"}]}},"user_id": "355fffec-7d74-4f40-9bfd-0477b40123fa","latest_labels": {},"workflow_statuses": [{"id": "v5ibh75a7zpaa2","config": {"id": "zhho43qaaa","version": "1716472425229"},"config_display_name": "New Create Order - User","abuse_types": ["payment_abuse"],"state": "running","entity": {"id": "355fffec-7d74-4f40-9bfd-0477b40123fa","type": "user"},"history": [{"app": "decision","name": "Watch User","state": "running","config": {"decision_id": "watch_user_payment_abuse"}},{"app": "user","name": "Entity","state": "finished","config": {}},{"app": "event","name": "Event","state": "finished","config": {}}]}]}}""");
var multiHistResponse = JsonSerializer.Deserialize<SiftCreateOrderResponse>("""{"status": 0,"error_message": "OK","time": 1716472711,"request": "{\"$type\":\"$create_order\",\"$api_key\":\"a2d37bf2********\",\"$user_id\":\"355fffec-7d74-4f40-9bfd-0477b40123fa\",\"$session_id\":\"1716472511094\",\"$ip\":\"61.246.254.84\",\"$order_id\":\"86971050\",\"$user_email\":\"akshay22395@gmail.com\",\"$amount\":2963290000,\"$currency_code\":\"INR\",\"$shipping_address\":{\"$name\":\"Akshay Kumar\",\"$address_1\":\"TTFTF\",\"$address_2\":\"Y\",\"$city\":\"Gurugram\",\"$country\":\"IN\",\"$phone\":\"7830888053\",\"$zipcode\":\"122008\"},\"$billing_address\":{\"$name\":\"Akshay Kumar\",\"$address_1\":\"TTFTF\",\"$address_2\":\"Y\",\"$city\":\"Gurugram\",\"$country\":\"IN\",\"$phone\":\"\",\"$zipcode\":\"122008\"},\"$payment_methods\":[{\"$payment_type\":\"$store_credit\"}],\"$shipping_method\":\"$physical\",\"$items\":[{\"$item_id\":\"5864775\",\"$product_title\":\"IC CURRENT TRANSMITTER 8VSSOP\",\"$price\":176329000,\"$currency_code\":\"INR\",\"$quantity\":10,\"$sku\":\"5864775\",\"$brand\":\"Texas Instruments\",\"$manufacturer\":\"Texas Instruments\",\"$category\":\"INTERFACE IC MISC\"}]}","score_response": {"status": 0,"error_message": "OK","scores": {"payment_abuse": {"score": 0.8271500468254089,"reasons": [{"name": "Estimated email address age","value": "1.24 hours"}]}},"user_id": "355fffec-7d74-4f40-9bfd-0477b40123fa","latest_labels": {},"workflow_statuses": [{"id": "v5ibh75a7zpaa2","config": {"id": "zhho43qaaa","version": "1716472425229"},"config_display_name": "New Create Order - User","abuse_types": ["payment_abuse"],"state": "running","entity": {"id": "355fffec-7d74-4f40-9bfd-0477b40123fa","type": "user"},"history": [{"app": "decision","name": "Watch User","state": "running","config": {"decision_id": "watch_user_payment_abuse"}},{"app": "decision","name": "Order Looks OK","state": "running","config": {"decision_id": "order_looks_ok_payment_abuse"}},{"app": "user","name": "Entity","state": "finished","config": {}},{"app": "event","name": "Event","state": "finished","config": {}}]}]}}""");
foreach (var history in response.ScoreResponse.WorkflowStatuses
.SelectMany(x => x.Histories)
.Where(x => string.Compare(x.App, "decision", StringComparison.OrdinalIgnoreCase) == 0
&& string.Compare(x.State, "running", StringComparison.OrdinalIgnoreCase) == 0
&& !string.IsNullOrWhiteSpace(x.Config.DecisionId))
Console.WriteLine(history.Config.DecisionId);
foreach (var history in multiHistResponse.ScoreResponse.WorkflowStatuses
.SelectMany(x => x.Histories)
.Where(x => string.Compare(x.App, "decision", StringComparison.OrdinalIgnoreCase) == 0
&& string.Compare(x.State, "running", StringComparison.OrdinalIgnoreCase) == 0
&& !string.IsNullOrWhiteSpace(x.Config.DecisionId))
Console.WriteLine(history.Config.DecisionId);
Console.WriteLine("Hello World");