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

namespace MyTelegram.Schema.Channels;

///<summary>
/// Reorder pinned forum topics
/// <para>Possible errors</para>
/// Code Type Description
/// 400 CHANNEL_INVALID The provided channel is invalid.
/// See <a href="https://corefork.telegram.org/method/channels.reorderPinnedForumTopics" />
///</summary>
[TlObject(0x2950a18f)]
public sealed class RequestReorderPinnedForumTopics : IRequest<MyTelegram.Schema.IUpdates>
{
    public uint ConstructorId => 0x2950a18f;
    ///<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 not set, the order of only the topics present both server-side and in <code>order</code> will be changed (i.e. mentioning topics not pinned server-side in <code>order</code> will not pin them, and not mentioning topics pinned server-side will not unpin them).  <br>If set, the entire server-side pinned topic list will be replaced with <code>order</code> (i.e. mentioning topics not pinned server-side in <code>order</code> will pin them, and not mentioning topics pinned server-side will unpin them)
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Force { get; set; }

    ///<summary>
    /// Supergroup ID
    /// See <a href="https://corefork.telegram.org/type/InputChannel" />
    ///</summary>
    public MyTelegram.Schema.IInputChannel Channel { get; set; }

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/forum">Topic IDs »</a>
    ///</summary>
    public TVector<int> 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(Channel);
        writer.Write(Order);
    }

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