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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Get all archived stickers
/// See <a href="https://corefork.telegram.org/method/messages.getArchivedStickers" />
///</summary>
[TlObject(0x57f17692)]
public sealed class RequestGetArchivedStickers : IRequest<MyTelegram.Schema.Messages.IArchivedStickers>
{
    public uint ConstructorId => 0x57f17692;
    ///<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>
    /// Get <a href="https://corefork.telegram.org/api/stickers#mask-stickers">mask stickers</a>
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Masks { get; set; }

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

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/offsets">Offsets for pagination, for more info click here</a>
    ///</summary>
    public long OffsetId { get; set; }

    ///<summary>
    /// Maximum number of results to return, <a href="https://corefork.telegram.org/api/offsets">see pagination</a>
    ///</summary>
    public int Limit { 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(OffsetId);
        writer.Write(Limit);
    }

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