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

namespace MyTelegram.Schema.Auth;

///<summary>
/// An account with this phone number doesn't exist on telegram: the user has to <a href="https://corefork.telegram.org/api/auth">enter basic information and sign up</a>
/// See <a href="https://corefork.telegram.org/constructor/auth.authorizationSignUpRequired" />
///</summary>
[TlObject(0x44747e9a)]
public sealed class TAuthorizationSignUpRequired : IAuthorization
{
    public uint ConstructorId => 0x44747e9a;
    ///<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>
    /// Telegram's terms of service: the user must read and accept the terms of service before signing up to telegram
    /// See <a href="https://corefork.telegram.org/type/help.TermsOfService" />
    ///</summary>
    public MyTelegram.Schema.Help.ITermsOfService? TermsOfService { get; set; }

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

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

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