using System.Text.Json.Nodes; using Febe.Core.Collection; using Febe.Core.Collection.Requests; namespace Febe.Tests.Collection.Support; /// /// The shipped Instagram catalog as tappa S4 will leave it for some operations: their headers and fields with a /// «pending» source dropped and the operation configured. Only for the tests of the site client contract, which need /// an Instagram operation the guard lets through; the shipped file keeps them not configured (rule 9). /// public static class SettledCatalog { /// The operations whose variables the shapes show whole (only the headers and fields wait for S4). public static IReadOnlyList KnownVariables { get; } = [ "PolarisProfileReelsTabContentQuery", "PolarisProfileTaggedTabContentQuery", "PolarisProfileStoryHighlightsTrayContentQuery", "media-info", ]; /// The Instagram catalog with (by default ) settled. public static RequestCatalog Instagram(params string[] names) { var settle = names.Length == 0 ? KnownVariables : names; var file = JsonNode.Parse(SiteMap.ReadEmbeddedText("richieste.instagram.json"))!.AsObject(); foreach (var operation in file["operations"]!.AsArray().Select(o => o!.AsObject())) { if (!settle.Contains(operation["name"]!.GetValue())) { continue; } foreach (var part in new[] { "headers", "body" }) { if (operation[part] is JsonObject sources) { foreach (var key in sources.Where(s => s.Value?.GetValue() == "pending").Select(s => s.Key).ToList()) { sources.Remove(key); } } } operation["configured"] = true; operation.Remove("reason"); } return RequestCatalog.Parse(file.ToJsonString(), "richieste.instagram.json (sistemato per le prove)"); } }