// <auto-generated/>
// ReSharper disable All

namespace MyTelegram.Schema;

///<summary>
/// See <a href="https://corefork.telegram.org/constructor/emojiStatusCollectible" />
///</summary>
[TlObject(0x7184603b)]
public sealed class TEmojiStatusCollectible : IEmojiStatus
{
    public uint ConstructorId => 0x7184603b;
    public int Flags { get; set; }
    public long CollectibleId { get; set; }
    public long DocumentId { get; set; }
    public string Title { get; set; }
    public string Slug { get; set; }
    public long PatternDocumentId { get; set; }
    public int CenterColor { get; set; }
    public int EdgeColor { get; set; }
    public int PatternColor { get; set; }
    public int TextColor { get; set; }
    public int? Until { get; set; }

    public void ComputeFlag()
    {
        if (/*Until != 0 && */Until.HasValue) { Flags = Flags.SetBit(0); }
    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(CollectibleId);
        writer.Write(DocumentId);
        writer.Write(Title);
        writer.Write(Slug);
        writer.Write(PatternDocumentId);
        writer.Write(CenterColor);
        writer.Write(EdgeColor);
        writer.Write(PatternColor);
        writer.Write(TextColor);
        if (Flags.IsBitSet(0)) { writer.Write(Until.Value); }
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        CollectibleId = buffer.ReadInt64();
        DocumentId = buffer.ReadInt64();
        Title = buffer.ReadString();
        Slug = buffer.ReadString();
        PatternDocumentId = buffer.ReadInt64();
        CenterColor = buffer.ReadInt32();
        EdgeColor = buffer.ReadInt32();
        PatternColor = buffer.ReadInt32();
        TextColor = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Until = buffer.ReadInt32(); }
    }
}