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

namespace MyTelegram.Schema;

///<summary>
/// See <a href="https://corefork.telegram.org/constructor/inputInvoiceStarGiftUpgrade" />
///</summary>
[TlObject(0x4d818d5d)]
public sealed class TInputInvoiceStarGiftUpgrade : IInputInvoice
{
    public uint ConstructorId => 0x4d818d5d;
    public int Flags { get; set; }
    public bool KeepOriginalDetails { get; set; }
    public MyTelegram.Schema.IInputSavedStarGift Stargift { get; set; }

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

    }

    public void Serialize(IBufferWriter<byte> writer)
    {
        ComputeFlag();
        writer.Write(ConstructorId);
        writer.Write(Flags);
        writer.Write(Stargift);
    }

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