using System.Text.Json;
using System.Text.Json.Serialization;
using Confluent.Kafka;

namespace Kafka.Lib.Auth;

public class LogOutMessageType : IMessageType
{
    public List<string?>? Tokens { get; set; }
    public string? UserName { get; set; }

    public string? Id { get; set; }

    public string EventType { get; init; } = "Logout";

    [JsonIgnore]
    public string Text
    {
        get => JsonSerializer.Serialize(this);
        set
        {
            if (string.IsNullOrEmpty(value))
            {
                var obj = JsonSerializer.Deserialize<LogOutMessageType>(value);

                if (obj != null)
                {
                    Tokens = obj.Tokens;
                    UserName = obj.UserName;
                    Id = obj.Id;
                }
            }

        }
    }
}