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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Apply changes to multiple stickersets
/// See <a href="https://corefork.telegram.org/method/messages.toggleStickerSets" />
///</summary>
[TlObject(0xb5052fea)]
public sealed class RequestToggleStickerSets : IRequest<IBool>
{
    public uint ConstructorId => 0xb5052fea;
    ///<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>
    /// Uninstall the specified stickersets
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Uninstall { get; set; }

    ///<summary>
    /// Archive the specified stickersets
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Archive { get; set; }

    ///<summary>
    /// Unarchive the specified stickersets
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Unarchive { get; set; }

    ///<summary>
    /// Stickersets to act upon
    ///</summary>
    public TVector<MyTelegram.Schema.IInputStickerSet> Stickersets { get; set; }

    public void ComputeFlag()
    {
        if (Uninstall) { Flags = Flags.SetBit(0); }
        if (Archive) { Flags = Flags.SetBit(1); }
        if (Unarchive) { Flags = Flags.SetBit(2); }

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Uninstall = true; }
        if (Flags.IsBitSet(1)) { Archive = true; }
        if (Flags.IsBitSet(2)) { Unarchive = true; }
        Stickersets = buffer.Read<TVector<MyTelegram.Schema.IInputStickerSet>>();
    }
}
