using AdsManagerService.Domain.SeedWork;

namespace AdsManagerService.Domain.AggregatesModel.CampaignAggregate;

/// <summary>
/// EN: Campaign objective enumeration (Awareness, Traffic, Conversion).
/// VI: Enum mục tiêu chiến dịch (Nhận diện, Traffic, Chuyển đổi).
/// </summary>
public class CampaignObjective : Enumeration
{
    /// <summary>
    /// EN: Brand awareness objective - maximize reach and impressions.
    /// VI: Mục tiêu nhận diện thương hiệu - tối đa hóa reach và impressions.
    /// </summary>
    public static readonly CampaignObjective Awareness = new(1, nameof(Awareness).ToLowerInvariant());

    /// <summary>
    /// EN: Traffic objective - drive clicks to website/app.
    /// VI: Mục tiêu traffic - tăng click vào website/app.
    /// </summary>
    public static readonly CampaignObjective Traffic = new(2, nameof(Traffic).ToLowerInvariant());

    /// <summary>
    /// EN: Conversion objective - optimize for purchases/leads.
    /// VI: Mục tiêu chuyển đổi - tối ưu cho mua hàng/đăng ký.
    /// </summary>
    public static readonly CampaignObjective Conversion = new(3, nameof(Conversion).ToLowerInvariant());

    /// <summary>
    /// EN: App installs objective.
    /// VI: Mục tiêu cài đặt app.
    /// </summary>
    public static readonly CampaignObjective AppInstalls = new(4, "app_installs");

    /// <summary>
    /// EN: Video views objective.
    /// VI: Mục tiêu xem video.
    /// </summary>
    public static readonly CampaignObjective VideoViews = new(5, "video_views");

    /// <summary>
    /// EN: Lead generation objective.
    /// VI: Mục tiêu thu thập lead.
    /// </summary>
    public static readonly CampaignObjective LeadGeneration = new(6, "lead_generation");

    public CampaignObjective(int id, string name) : base(id, name)
    {
    }

    public static IEnumerable<CampaignObjective> List() =>
        new[] { Awareness, Traffic, Conversion, AppInstalls, VideoViews, LeadGeneration };

    public static CampaignObjective FromName(string name) =>
        List().FirstOrDefault(s => string.Equals(s.Name, name, StringComparison.CurrentCultureIgnoreCase))
        ?? throw new ArgumentException($"Invalid campaign objective: {name}");

    public static CampaignObjective From(int id) =>
        List().FirstOrDefault(s => s.Id == id)
        ?? throw new ArgumentException($"Invalid campaign objective id: {id}");
}
