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

namespace MyTelegram.Schema;

///<summary>
/// Represents the location of a <a href="https://corefork.telegram.org/api/business#location">Telegram Business »</a>.
/// See <a href="https://corefork.telegram.org/constructor/businessLocation" />
///</summary>
[TlObject(0xac5c1af7)]
public sealed class TBusinessLocation : IBusinessLocation
{
    public uint ConstructorId => 0xac5c1af7;
    ///<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>
    /// Geographical coordinates (optional).
    /// See <a href="https://corefork.telegram.org/type/GeoPoint" />
    ///</summary>
    public MyTelegram.Schema.IGeoPoint? GeoPoint { get; set; }

    ///<summary>
    /// Textual description of the address (mandatory).
    ///</summary>
    public string Address { get; set; }

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

    }

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

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