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

namespace MyTelegram.Schema.Messages;

///<summary>
/// See <a href="https://corefork.telegram.org/method/messages.getSavedDialogsByID" />
///</summary>
[TlObject(0x6f6f9c96)]
public sealed class RequestGetSavedDialogsByID : IRequest<MyTelegram.Schema.Messages.ISavedDialogs>
{
    public uint ConstructorId => 0x6f6f9c96;
    public int Flags { get; set; }
    public MyTelegram.Schema.IInputPeer? ParentPeer { get; set; }
    public TVector<MyTelegram.Schema.IInputPeer> Ids { get; set; }

    public void ComputeFlag()
    {
        if (ParentPeer != null) { Flags = Flags.SetBit(1); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        if (Flags.IsBitSet(1)) { writer.Write(ParentPeer); }
        writer.Write(Ids);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(1)) { ParentPeer = buffer.Read<MyTelegram.Schema.IInputPeer>(); }
        Ids = buffer.Read<TVector<MyTelegram.Schema.IInputPeer>>();
    }
}
