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

namespace MyTelegram.Schema;

///<summary>
/// A new <a href="https://corefork.telegram.org/api/folders">folder</a> was added
/// See <a href="https://corefork.telegram.org/constructor/updateDialogFilter" />
///</summary>
[TlObject(0x26ffde7d)]
public sealed class TUpdateDialogFilter : IUpdate
{
    public uint ConstructorId => 0x26ffde7d;
    ///<summary>
    /// Flags, see <a href="https://corefork.telegram.org/mtproto/TL-combinators#conditional-fields">TL conditional fields</a>
    ///</summary>
    public int Flags { get; set; }

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/folders">Folder</a> ID
    ///</summary>
    public int Id { get; set; }

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/folders">Folder</a> info
    /// See <a href="https://corefork.telegram.org/type/DialogFilter" />
    ///</summary>
    public MyTelegram.Schema.IDialogFilter? Filter { get; set; }

    public void ComputeFlag()
    {
        if (Filter != null) { Flags = Flags.SetBit(0); }
    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        Id = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Filter = buffer.Read<MyTelegram.Schema.IDialogFilter>(); }
    }
}