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

namespace MyTelegram.Schema;

///<summary>
/// Empty draft
/// See <a href="https://corefork.telegram.org/constructor/draftMessageEmpty" />
///</summary>
[TlObject(0x1b0c841a)]
public sealed class TDraftMessageEmpty : IDraftMessage,IEmpty
{
    public uint ConstructorId => 0x1b0c841a;
    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags { get; set; }

    public IInputMedia? Media { get; set; }

    ///<summary>
    /// When was the draft last updated
    ///</summary>
    public int? Date { get; set; }

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

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        if (Flags.IsBitSet(0)) { writer.Write(Date.Value); }
    }

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