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

namespace MyTelegram.Schema;

///<summary>
/// A preview of the webpage is currently being generated
/// See <a href="https://corefork.telegram.org/constructor/webPagePending" />
///</summary>
[TlObject(0xb0d13e47)]
public sealed class TWebPagePending : IWebPage
{
    public uint ConstructorId => 0xb0d13e47;
    ///<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>
    /// ID of preview
    ///</summary>
    public long Id { get; set; }

    ///<summary>
    /// URL of the webpage
    ///</summary>
    public string? Url { get; set; }

    ///<summary>
    /// When was the processing started
    ///</summary>
    public int Date { get; set; }

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

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        Id = buffer.ReadInt64();
        if (Flags.IsBitSet(0)) { Url = buffer.ReadString(); }
        Date = buffer.ReadInt32();
    }
}