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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Reorder installed stickersets
/// See <a href="https://corefork.telegram.org/method/messages.reorderStickerSets" />
///</summary>
[TlObject(0x78337739)]
public sealed class RequestReorderStickerSets : IRequest<IBool>
{
    public uint ConstructorId => 0x78337739;
    ///<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>
    /// Reorder mask stickersets
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Masks { get; set; }

    ///<summary>
    /// Reorder <a href="https://corefork.telegram.org/api/custom-emoji">custom emoji stickersets</a>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Emojis { get; set; }

    ///<summary>
    /// New stickerset order by stickerset IDs
    ///</summary>
    public TVector<long> Order { get; set; }

    public void ComputeFlag()
    {
        if (Masks) { Flags = Flags.SetBit(0); }
        if (Emojis) { Flags = Flags.SetBit(1); }

    }

    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)) { Masks = true; }
        if (Flags.IsBitSet(1)) { Emojis = true; }
        Order = buffer.Read<TVector<long>>();
    }
}
