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

namespace MyTelegram.Schema;

///<summary>
/// The order of stickersets was changed
/// See <a href="https://corefork.telegram.org/constructor/updateStickerSetsOrder" />
///</summary>
[TlObject(0xbb2d201)]
public sealed class TUpdateStickerSetsOrder : IUpdate
{
    public uint ConstructorId => 0xbb2d201;
    ///<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>
    /// Whether the updated stickers are mask stickers
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Masks { get; set; }

    ///<summary>
    /// Whether the updated stickers are custom emoji stickers
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Emojis { get; set; }

    ///<summary>
    /// New sticker order by sticker ID
    ///</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>>();
    }
}