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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Reorder pinned <a href="https://corefork.telegram.org/api/saved-messages">saved message dialogs »</a>.
/// See <a href="https://corefork.telegram.org/method/messages.reorderPinnedSavedDialogs" />
///</summary>
[TlObject(0x8b716587)]
public sealed class RequestReorderPinnedSavedDialogs : IRequest<IBool>
{
    public uint ConstructorId => 0x8b716587;
    ///<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>
    /// If set, dialogs pinned server-side but not present in the <code>order</code> field will be unpinned.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Force { get; set; }

    ///<summary>
    /// New dialog order
    ///</summary>
    public TVector<MyTelegram.Schema.IInputDialogPeer> Order { get; set; }

    public void ComputeFlag()
    {
        if (Force) { Flags = Flags.SetBit(0); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Order);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Force = true; }
        Order = buffer.Read<TVector<MyTelegram.Schema.IInputDialogPeer>>();
    }
}
