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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Search for stickersets
/// See <a href="https://corefork.telegram.org/method/messages.searchStickerSets" />
///</summary>
[TlObject(0x35705b8a)]
public sealed class RequestSearchStickerSets : IRequest<MyTelegram.Schema.Messages.IFoundStickerSets>
{
    public uint ConstructorId => 0x35705b8a;
    ///<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>
    /// Exclude featured stickersets from results
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool ExcludeFeatured { get; set; }

    ///<summary>
    /// Query string
    ///</summary>
    public string Q { get; set; }

    ///<summary>
    /// <a href="https://corefork.telegram.org/api/offsets#hash-generation">Hash used for caching, for more info click here</a>.
    ///</summary>
    public long Hash { get; set; }

    public void ComputeFlag()
    {
        if (ExcludeFeatured) { Flags = Flags.SetBit(0); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Q);
        writer.Write(Hash);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { ExcludeFeatured = true; }
        Q = buffer.ReadString();
        Hash = buffer.ReadInt64();
    }
}
