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

namespace MyTelegram.Schema.Payments;

///<summary>
/// Get <a href="https://corefork.telegram.org/api/stars">Telegram Star revenue statistics »</a>.
/// <para>Possible errors</para>
/// Code Type Description
/// 400 PEER_ID_INVALID The provided peer id is invalid.
/// See <a href="https://corefork.telegram.org/method/payments.getStarsRevenueStats" />
///</summary>
[TlObject(0xd91ffad6)]
public sealed class RequestGetStarsRevenueStats : IRequest<MyTelegram.Schema.Payments.IStarsRevenueStats>
{
    public uint ConstructorId => 0xd91ffad6;
    ///<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>
    /// Whether to enable dark theme for graph colors
    /// See <a href="https://corefork.telegram.org/type/true" />
    ///</summary>
    public bool Dark { get; set; }
    public bool Ton { get; set; }

    ///<summary>
    /// Get statistics for the specified bot, channel or ourselves (<a href="https://corefork.telegram.org/constructor/inputPeerSelf">inputPeerSelf</a>).
    /// See <a href="https://corefork.telegram.org/type/InputPeer" />
    ///</summary>
    public MyTelegram.Schema.IInputPeer Peer { get; set; }

    public void ComputeFlag()
    {
        if (Dark) { Flags = Flags.SetBit(0); }
        if (Ton) { Flags = Flags.SetBit(1); }

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Dark = true; }
        if (Flags.IsBitSet(1)) { Ton = true; }
        Peer = buffer.Read<MyTelegram.Schema.IInputPeer>();
    }
}
