using System; using System.Collections.Generic; using System.Text.Json.Serialization; namespace JobTrackerApi.Models { public class Correspondence { public int Id { get; set; } public int JobApplicationId { get; set; } [JsonIgnore] public JobApplication JobApplication { get; set; } = null!; public string From { get; set; } = ""; // "Me" or "Company" public string? Direction { get; set; } // inbound, outbound, internal, unknown public string? Subject { get; set; } public string? Channel { get; set; } // e.g. Email, Call, Note public string? ExternalMessageId { get; set; } public string? ExternalThreadId { get; set; } public string? ExternalFrom { get; set; } public string? ExternalTo { get; set; } public string? ExternalLabelsJson { get; set; } public string? AttachmentMetadataJson { get; set; } public string Content { get; set; } = ""; public DateTime Date { get; set; } = DateTime.Now; [JsonIgnore] public IReadOnlyList ExternalLabels => string.IsNullOrWhiteSpace(ExternalLabelsJson) ? Array.Empty() : (System.Text.Json.JsonSerializer.Deserialize>(ExternalLabelsJson) ?? new List()); [JsonIgnore] public IReadOnlyList AttachmentMetadata => string.IsNullOrWhiteSpace(AttachmentMetadataJson) ? Array.Empty() : (System.Text.Json.JsonSerializer.Deserialize>(AttachmentMetadataJson) ?? new List()); } public sealed class CorrespondenceAttachmentMetadata { public string? FileName { get; set; } public string? MimeType { get; set; } public long? SizeBytes { get; set; } public string? GmailAttachmentId { get; set; } public bool Inline { get; set; } } }