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

namespace MyTelegram.Schema;

///<summary>
/// Used to fetch info about a <a href="https://corefork.telegram.org/api/stars#balance-and-transaction-history">Telegram Star transaction »</a>.
/// See <a href="https://corefork.telegram.org/constructor/inputStarsTransaction" />
///</summary>
[TlObject(0x206ae6d1)]
public sealed class TInputStarsTransaction : IInputStarsTransaction
{
    public uint ConstructorId => 0x206ae6d1;
    ///<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>
    /// If set, fetches info about the refund transaction for this transaction.
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Refund { get; set; }

    ///<summary>
    /// Transaction ID.
    ///</summary>
    public string Id { get; set; }

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

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Refund = true; }
        Id = buffer.ReadString();
    }
}