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

namespace MyTelegram.Schema;

///<summary>
/// See <a href="https://corefork.telegram.org/constructor/inputStorePaymentAuthCode" />
///</summary>
[TlObject(0x9bb2636d)]
public sealed class TInputStorePaymentAuthCode : IInputStorePaymentPurpose
{
    public uint ConstructorId => 0x9bb2636d;
    public int Flags { get; set; }
    public bool Restore { get; set; }
    public string PhoneNumber { get; set; }
    public string PhoneCodeHash { get; set; }
    public string Currency { get; set; }
    public long Amount { get; set; }

    public void ComputeFlag()
    {
        if (Restore) { Flags = Flags.SetBit(0); }

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(PhoneNumber);
        writer.Write(PhoneCodeHash);
        writer.Write(Currency);
        writer.Write(Amount);
    }

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Restore = true; }
        PhoneNumber = buffer.ReadString();
        PhoneCodeHash = buffer.ReadString();
        Currency = buffer.ReadString();
        Amount = buffer.ReadInt64();
    }
}