// ReSharper restore AssignNullToNotNullAttribute private static void Main(string[] args) { using (var comparisons = new Comparisons(AccountId, AuthToken)) { var identifier = Comparisons.GenerateIdentifier(); Process.Start(comparisons.SignedViewerURL(identifier, validFor: TimeSpan.FromMinutes(30), wait: true)); var comparison = comparisons.Create( Comparisons.Side.FromURL("https://api.draftable.com/static/test-documents/paper/left.pdf", "pdf"), Comparisons.Side.FromURL("https://api.draftable.com/static/test-documents/paper/right.pdf", "pdf"), identifier: identifier, expires: TimeSpan.FromMinutes(30) ); Console.WriteLine(comparison); } Console.ReadLine(); }
private static string CreateComparison(string label, Comparisons client, Func <Comparisons, Comparison> createCore) { label = $"[{label}]"; var prefix = new string(' ', label.Length); var comparison = createCore(client); var cid = comparison.Identifier; Console.WriteLine($"{label} Comparison ID: {cid}"); Console.WriteLine($"{prefix} isReady: {comparison.Ready}"); Console.WriteLine($"{prefix} Public URL: {client.PublicViewerURL(cid)}"); Console.WriteLine($"{prefix} Signed URL: {client.SignedViewerURL(cid)}"); var timeoutCount = 0; while (!comparison.Ready) { if (timeoutCount > 20) { throw new TimeoutException("Timeout exceeded while waiting for comparison to be ready."); } Task.Delay(1000).Wait(); comparison = client.Get(cid); timeoutCount++; } Console.WriteLine($"{label} Comparison ID: {cid}"); Console.WriteLine($"{prefix} isReady: {comparison.Ready}"); Console.WriteLine($"{prefix} Failed: {HasFailed(comparison)}"); Console.WriteLine($"{prefix} Error: {comparison.ErrorMessage}"); return(cid); }