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

namespace MyTelegram.Schema;

///<summary>
/// A stickerset was just moved to top, <a href="https://corefork.telegram.org/api/stickers#recent-stickersets">see here for more info »</a>
/// See <a href="https://corefork.telegram.org/constructor/updateMoveStickerSetToTop" />
///</summary>
[TlObject(0x86fccf85)]
public sealed class TUpdateMoveStickerSetToTop : IUpdate
{
    public uint ConstructorId => 0x86fccf85;
    ///<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>
    /// This update is referring to a <a href="https://corefork.telegram.org/api/stickers#mask-stickers">mask stickerset</a>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Masks { get; set; }

    ///<summary>
    /// This update is referring to a <a href="https://corefork.telegram.org/api/custom-emoji">custom emoji stickerset</a>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Emojis { get; set; }

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/stickers">Stickerset</a> ID
    ///</summary>
    public long Stickerset { 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(Stickerset);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Masks = true; }
        if (Flags.IsBitSet(1)) { Emojis = true; }
        Stickerset = buffer.ReadInt64();
    }
}