using AdsTrackingService.Domain.SeedWork;

namespace AdsTrackingService.Domain.AggregatesModel.AttributionAggregate;

/// <summary>
/// EN: Attribution aggregate root - links conversions to ads.
/// VI: Attribution aggregate root - liên kết conversion với quảng cáo.
/// </summary>
public class Attribution : Entity, IAggregateRoot
{
    private Guid _conversionId;
    private Guid _adId;
    private Guid _campaignId;
    private AttributionModel _model;
    private decimal _attributedValue;
    private DateTime _attributedAt;

    public Guid ConversionId => _conversionId;
    public Guid AdId => _adId;
    public Guid CampaignId => _campaignId;
    public AttributionModel Model => _model;
    public decimal AttributedValue => _attributedValue;
    public DateTime AttributedAt => _attributedAt;

    protected Attribution() { }

    public Attribution(Guid conversionId, Guid adId, Guid campaignId, AttributionModel model, decimal attributedValue)
    {
        Id = Guid.NewGuid();
        _conversionId = conversionId;
        _adId = adId;
        _campaignId = campaignId;
        _model = model;
        _attributedValue = attributedValue;
        _attributedAt = DateTime.UtcNow;
    }
}

/// <summary>
/// EN: Attribution model enumeration.
/// VI: Enum mô hình attribution.
/// </summary>
public enum AttributionModel
{
    LastClick = 1,
    FirstClick = 2,
    Linear = 3,
    TimeDecay = 4
}
