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

namespace MyTelegram.Schema.Account;

///<summary>
/// <a href="https://corefork.telegram.org/api/business#location">Businesses »</a> may advertise their location using this method, see <a href="https://corefork.telegram.org/api/business#location">here »</a> for more info.To remove business location information invoke the method without setting any of the parameters.
/// See <a href="https://corefork.telegram.org/method/account.updateBusinessLocation" />
///</summary>
[TlObject(0x9e6b131a)]
public sealed class RequestUpdateBusinessLocation : IRequest<IBool>
{
    public uint ConstructorId => 0x9e6b131a;
    ///<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>
    /// Optional, contains a set of geographical coordinates.
    /// See <a href="https://corefork.telegram.org/type/InputGeoPoint" />
    ///</summary>
    public MyTelegram.Schema.IInputGeoPoint? GeoPoint { get; set; }

    ///<summary>
    /// Mandatory when setting/updating the location, contains a textual description of the address (max 96 UTF-8 chars).
    ///</summary>
    public string? Address { get; set; }

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

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

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