namespace IceImportDAL.DTO.MenuWebServiceDispatcher; // Result of IMenuWebServiceDispatcher's Invoke* calls — carries the resolved Url and the exact // PayloadJson that was actually sent, so callers can build a full audit record // (ICEIMPORT.TICEIMPORTRUNROWRESULT.POSTDATA) alongside whatever business outcome they derive from // ResponseBody, instead of only getting back a bare response string with no trace of what was // called or with what. public class WebServiceCallResultDTO { public bool Success { get; set; } public string? Url { get; set; } public string? PayloadJson { get; set; } public string? ResponseBody { get; set; } public string? ErrorMessage { get; set; } // TICEIMPORTRUNROWRESULT.POSTDATA's exact content — Url and PayloadJson combined into one JSON // envelope. PayloadJson is embedded as a raw JSON value (via JsonRawValue), not a JSON string, so // the payload reads as a nested object rather than a double-escaped string. public string ToPostDataJson() { var payloadRaw = string.IsNullOrWhiteSpace(PayloadJson) ? "null" : PayloadJson; return $"{{\"Url\":{System.Text.Json.JsonSerializer.Serialize(Url)},\"Payload\":{payloadRaw}}}"; } public static WebServiceCallResultDTO Ok(string? url, string? payloadJson, string? responseBody) => new() { Success = true, Url = url, PayloadJson = payloadJson, ResponseBody = responseBody }; public static WebServiceCallResultDTO Fail(string? url, string? payloadJson, string errorMessage, string? responseBody = null) => new() { Success = false, Url = url, PayloadJson = payloadJson, ErrorMessage = errorMessage, ResponseBody = responseBody }; }