namespace DocumentOperator.Application.Common.DTOs;

/// <summary>
/// Represents metadata of a single PDF attachment (embedded file).
/// Immutable value object containing file information without the actual binary data.
/// </summary>
/// <remarks>
/// Initializes a new instance of the AttachmentMetadata class.
/// </remarks>
/// <param name="fileName">Attachment file name</param>
/// <param name="mimeType">MIME type (e.g., "text/xml")</param>
/// <param name="sizeBytes">File size in bytes</param>
public sealed class AttachmentMetadata(string fileName, string mimeType, long sizeBytes)
{
    /// <summary>
    /// Gets the attachment file name (e.g., "invoice.xml", "document.pdf")
    /// </summary>
    public string FileName { get; } = fileName ?? string.Empty;

    /// <summary>
    /// Gets the MIME type of the attachment (e.g., "text/xml", "application/pdf")
    /// </summary>
    public string MimeType { get; } = mimeType ?? "application/octet-stream"; // Default MIME type if unknown

    /// <summary>
    /// Gets the attachment file size in bytes
    /// </summary>
    public long SizeBytes { get; } = sizeBytes;

    /// <summary>
    /// Gets the attachment file size in kilobytes (computed property)
    /// </summary>
    public double SizeKB => SizeBytes / 1024.0;

    /// <summary>
    /// Gets the attachment file size in megabytes (computed property)
    /// </summary>
    public double SizeMB => SizeBytes / 1024.0 / 1024.0;

    public override string ToString()
    {
        return $"{FileName} ({MimeType}, {SizeKB:F2} KB)";
    }
}
