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

namespace MyTelegram.Schema;

///<summary>
/// See <a href="https://corefork.telegram.org/constructor/inputEmojiStatusCollectible" />
///</summary>
[TlObject(0x7141dbf)]
public sealed class TInputEmojiStatusCollectible : IEmojiStatus
{
    public uint ConstructorId => 0x7141dbf;
    public int Flags { get; set; }
    public long CollectibleId { 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);
        if (Flags.IsBitSet(0)) { writer.Write(Until.Value); }
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        CollectibleId = buffer.ReadInt64();
        if (Flags.IsBitSet(0)) { Until = buffer.ReadInt32(); }
    }
}