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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Featured stickersets
/// See <a href="https://corefork.telegram.org/constructor/messages.featuredStickers" />
///</summary>
[TlObject(0xbe382906)]
public sealed class TFeaturedStickers : IFeaturedStickers
{
    public uint ConstructorId => 0xbe382906;
    ///<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 this is a premium stickerset
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Premium { 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; }

    ///<summary>
    /// Total number of featured stickers
    ///</summary>
    public int Count { get; set; }

    ///<summary>
    /// Featured stickersets
    ///</summary>
    public TVector<MyTelegram.Schema.IStickerSetCovered> Sets { get; set; }

    ///<summary>
    /// IDs of new featured stickersets
    ///</summary>
    public TVector<long> Unread { get; set; }

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

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Premium = true; }
        Hash = buffer.ReadInt64();
        Count = buffer.ReadInt32();
        Sets = buffer.Read<TVector<MyTelegram.Schema.IStickerSetCovered>>();
        Unread = buffer.Read<TVector<long>>();
    }
}