using System.Text.Json.Serialization;

namespace MarcusLaw.OutlookAddin.Core.Models
{
    public sealed class EmailAddressMatch
    {
        // EspoCRM's /EmailAddress/search payload uses "entityId" + "entityName"
        // (newer builds) or sometimes "id" + "entityType" (older). Accept both
        // by exposing parallel JSON-bound shadow setters that write the same
        // primary field.

        [JsonPropertyName("id")]
        public string Id { get; set; } = string.Empty;

        [JsonPropertyName("entityId")]
        public string EntityIdAlias { set => Id = value; get => Id; }

        [JsonPropertyName("name")]
        public string? Name { get; set; }

        [JsonPropertyName("entityType")]
        public string EntityType { get; set; } = string.Empty;

        [JsonPropertyName("entityName")]
        public string EntityNameAlias { set => EntityType = value; get => EntityType; }

        [JsonPropertyName("emailAddress")]
        public string? EmailAddress { get; set; }
    }
}
