using System.Net; namespace StellaOps.Concelier.Connector.Common.Fetch; /// /// Result of fetching raw response content without persisting a document. /// public sealed record SourceFetchContentResult { private SourceFetchContentResult( HttpStatusCode statusCode, byte[]? content, bool notModified, string? etag, DateTimeOffset? lastModified, string? contentType, int attempts, IReadOnlyDictionary? headers) { StatusCode = statusCode; Content = content; IsNotModified = notModified; ETag = etag; LastModified = lastModified; ContentType = contentType; Attempts = attempts; Headers = headers; } public HttpStatusCode StatusCode { get; } public byte[]? Content { get; } public bool IsSuccess => Content is not null; public bool IsNotModified { get; } public string? ETag { get; } public DateTimeOffset? LastModified { get; } public string? ContentType { get; } public int Attempts { get; } public IReadOnlyDictionary? Headers { get; } public static SourceFetchContentResult Success( HttpStatusCode statusCode, byte[] content, string? etag, DateTimeOffset? lastModified, string? contentType, int attempts, IReadOnlyDictionary? headers) => new(statusCode, content, notModified: false, etag, lastModified, contentType, attempts, headers); public static SourceFetchContentResult NotModified(HttpStatusCode statusCode, int attempts) => new(statusCode, null, notModified: true, etag: null, lastModified: null, contentType: null, attempts, headers: null); public static SourceFetchContentResult Skipped(HttpStatusCode statusCode, int attempts) => new(statusCode, null, notModified: false, etag: null, lastModified: null, contentType: null, attempts, headers: null); }