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

namespace MyTelegram.Schema.Payments;

///<summary>
/// See <a href="https://corefork.telegram.org/constructor/payments.suggestedStarRefBots" />
///</summary>
[TlObject(0xb4d5d859)]
public sealed class TSuggestedStarRefBots : ISuggestedStarRefBots
{
    public uint ConstructorId => 0xb4d5d859;
    ///<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>
    /// &nbsp;
    ///</summary>
    public int Count { get; set; }

    ///<summary>
    /// &nbsp;
    ///</summary>
    public TVector<MyTelegram.Schema.IStarRefProgram> SuggestedBots { get; set; }

    ///<summary>
    /// &nbsp;
    ///</summary>
    public TVector<MyTelegram.Schema.IUser> Users { get; set; }

    ///<summary>
    /// &nbsp;
    ///</summary>
    public string? NextOffset { get; set; }

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

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        Count = buffer.ReadInt32();
        SuggestedBots = buffer.Read<TVector<MyTelegram.Schema.IStarRefProgram>>();
        Users = buffer.Read<TVector<MyTelegram.Schema.IUser>>();
        if (Flags.IsBitSet(0)) { NextOffset = buffer.ReadString(); }
    }
}