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

namespace MyTelegram.Schema;

///<summary>
/// <a href="https://corefork.telegram.org/api/business#business-introduction">Telegram Business introduction »</a>.
/// See <a href="https://corefork.telegram.org/constructor/inputBusinessIntro" />
///</summary>
[TlObject(0x9c469cd)]
public sealed class TInputBusinessIntro : IInputBusinessIntro
{
    public uint ConstructorId => 0x9c469cd;
    ///<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>
    /// Title of the introduction message
    ///</summary>
    public string Title { get; set; }

    ///<summary>
    /// Profile introduction
    ///</summary>
    public string Description { get; set; }

    ///<summary>
    /// Optional introduction <a href="https://corefork.telegram.org/api/stickers">sticker</a>.
    /// See <a href="https://corefork.telegram.org/type/InputDocument" />
    ///</summary>
    public MyTelegram.Schema.IInputDocument? Sticker { get; set; }

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

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

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