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

namespace MyTelegram.Schema;

///<summary>
/// All reactions or all non-custom reactions are allowed
/// See <a href="https://corefork.telegram.org/constructor/chatReactionsAll" />
///</summary>
[TlObject(0x52928bca)]
public sealed class TChatReactionsAll : IChatReactions
{
    public uint ConstructorId => 0x52928bca;
    ///<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 to allow custom reactions
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool AllowCustom { get; set; }

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

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

    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { AllowCustom = true; }
    }
}