using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using MarcusLaw.OutlookAddin.Core.Json;

namespace MarcusLaw.OutlookAddin.Core.Models
{
    public sealed class CaseEntity
    {
        [JsonPropertyName("id")]
        public string Id { get; set; } = string.Empty;

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

        // EspoCRM serializes the case number as a JSON number on some
        // installs (auto-increment column) and as a string on others
        // (custom case-code formatter). Accept both.
        [JsonPropertyName("number")]
        [JsonConverter(typeof(FlexibleStringConverter))]
        public string? Number { get; set; }

        [JsonPropertyName("status")]
        public string? Status { get; set; }

        // Marcus-Law custom field on Case — court file/docket number.
        // Field name guessed from EspoCRM "c-prefixed PascalCase" convention;
        // adjust if the admin used a different name.
        [JsonPropertyName("cCourtCaseNumber")]
        [JsonConverter(typeof(FlexibleStringConverter))]
        public string? CourtCaseNumber { get; set; }

        [JsonPropertyName("accountId")]
        public string? AccountId { get; set; }

        [JsonPropertyName("contactsIds")]
        public List<string> ContactsIds { get; set; } = new List<string>();

        [JsonPropertyName("createdAt")]
        public DateTimeOffset? CreatedAt { get; set; }

        // Set by Marcus-Law's NetworkStorageIntegration hook on first
        // Document save. Empty until a document has been written through
        // EspoCRM. When empty we compute it client-side from number +
        // primary contact name.
        [JsonPropertyName("networkStorageFolderPath")]
        public string? NetworkStorageFolderPath { get; set; }
    }
}
