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

namespace MyTelegram.Schema.Messages;

///<summary>
/// Update the <a href="https://corefork.telegram.org/api/saved-messages#tags">description of a saved message tag »</a>.
/// <para>Possible errors</para>
/// Code Type Description
/// 403 PREMIUM_ACCOUNT_REQUIRED A premium account is required to execute this action.
/// 400 REACTION_INVALID The specified reaction is invalid.
/// See <a href="https://corefork.telegram.org/method/messages.updateSavedReactionTag" />
///</summary>
[TlObject(0x60297dec)]
public sealed class RequestUpdateSavedReactionTag : IRequest<IBool>
{
    public uint ConstructorId => 0x60297dec;
    ///<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>
    /// <a href="https://corefork.telegram.org/api/reactions">Reaction</a> associated to the tag
    /// See <a href="https://corefork.telegram.org/type/Reaction" />
    ///</summary>
    public MyTelegram.Schema.IReaction Reaction { get; set; }

    ///<summary>
    /// Tag description, max 12 UTF-8 characters; to remove the description call the method without setting this flag.
    ///</summary>
    public string? Title { get; set; }

    public void ComputeFlag()
    {
        if (Title != null) { Flags = Flags.SetBit(0); }
    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Reaction);
        if (Flags.IsBitSet(0)) { writer.Write(Title); }
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        Reaction = buffer.Read<MyTelegram.Schema.IReaction>();
        if (Flags.IsBitSet(0)) { Title = buffer.ReadString(); }
    }
}
