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

namespace MyTelegram.Schema.Account;

///<summary>
/// Update our <a href="https://corefork.telegram.org/api/profile#birthday">birthday, see here »</a> for more info.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 BIRTHDAY_INVALID An invalid age was specified, must be between 0 and 150 years.
/// See <a href="https://corefork.telegram.org/method/account.updateBirthday" />
///</summary>
[TlObject(0xcc6e0c11)]
public sealed class RequestUpdateBirthday : IRequest<IBool>
{
    public uint ConstructorId => 0xcc6e0c11;
    ///<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>
    /// Birthday.
    /// See <a href="https://corefork.telegram.org/type/Birthday" />
    ///</summary>
    public MyTelegram.Schema.IBirthday? Birthday { get; set; }

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

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

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