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

namespace MyTelegram.Schema.Premium;

///<summary>
/// Apply one or more <a href="https://corefork.telegram.org/api/boost">boosts »</a> to a peer.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 BOOSTS_EMPTY No boost slots were specified.
/// 400 PEER_ID_INVALID The provided peer id is invalid.
/// 400 SLOTS_EMPTY The specified slot list is empty.
/// See <a href="https://corefork.telegram.org/method/premium.applyBoost" />
///</summary>
[TlObject(0x6b7da746)]
public sealed class RequestApplyBoost : IRequest<MyTelegram.Schema.Premium.IMyBoosts>
{
    public uint ConstructorId => 0x6b7da746;
    ///<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>
    /// Which <a href="https://corefork.telegram.org/api/boost">boost slots</a> to assign to this peer.
    ///</summary>
    public TVector<int>? Slots { get; set; }

    ///<summary>
    /// The peer to boost.
    /// See <a href="https://corefork.telegram.org/type/InputPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputPeer Peer { get; set; }

    public void ComputeFlag()
    {
        if (Slots?.Count > 0) { Flags = Flags.SetBit(0); }

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Slots = buffer.Read<TVector<int>>(); }
        Peer = buffer.Read<MyTelegram.Schema.IInputPeer>();
    }
}
