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

namespace MyTelegram.Schema;

///<summary>
/// Info about a sent inline webview message
/// See <a href="https://corefork.telegram.org/constructor/webViewMessageSent" />
///</summary>
[TlObject(0xc94511c)]
public sealed class TWebViewMessageSent : IWebViewMessageSent
{
    public uint ConstructorId => 0xc94511c;
    ///<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>
    /// Message ID
    /// See <a href="https://corefork.telegram.org/type/InputBotInlineMessageID" />
    ///</summary>
    public MyTelegram.Schema.IInputBotInlineMessageID? MsgId { get; set; }

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

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

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