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

namespace MyTelegram.Schema.Bots;

///<summary>
/// Get localized name, about text and description of a bot (or of the current account, if called by a bot).
/// <para>Possible errors</para>
/// Code Type Description
/// 400 BOT_INVALID This is not a valid bot.
/// 400 LANG_CODE_INVALID The specified language code is invalid.
/// 400 USER_BOT_INVALID User accounts must provide the <code>bot</code> method parameter when calling this method. If there is no such method parameter, this method can only be invoked by bot accounts.
/// See <a href="https://corefork.telegram.org/method/bots.getBotInfo" />
///</summary>
[TlObject(0xdcd914fd)]
public sealed class RequestGetBotInfo : IRequest<MyTelegram.Schema.Bots.IBotInfo>
{
    public uint ConstructorId => 0xdcd914fd;
    ///<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>
    /// If called by a user, <strong>must</strong> contain the peer of a bot we own.
    /// See <a href="https://corefork.telegram.org/type/InputUser" />
    ///</summary>
    public MyTelegram.Schema.IInputUser? Bot { get; set; }

    ///<summary>
    /// Language code, if left empty this method will return the fallback about text and description.
    ///</summary>
    public string LangCode { get; set; }

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

    }

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

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