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

namespace MyTelegram.Schema.Stats;

///<summary>
/// Get <a href="https://corefork.telegram.org/api/stats">message statistics</a>
/// <para>Possible errors</para>
/// Code Type Description
/// 400 CHANNEL_INVALID The provided channel is invalid.
/// 400 CHAT_ADMIN_REQUIRED You must be an admin in this chat to do this.
/// 400 MESSAGE_ID_INVALID The provided message id is invalid.
/// 400 PEER_ID_INVALID The provided peer id is invalid.
/// See <a href="https://corefork.telegram.org/method/stats.getMessageStats" />
///</summary>
[TlObject(0xb6e0a3f5)]
public sealed class RequestGetMessageStats : IRequest<MyTelegram.Schema.Stats.IMessageStats>
{
    public uint ConstructorId => 0xb6e0a3f5;
    ///<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; }

    ///<summary>
    /// Channel ID
    /// See <a href="https://corefork.telegram.org/type/InputChannel" />
    ///</summary>
    public MyTelegram.Schema.IInputChannel Channel { get; set; }

    ///<summary>
    /// Message ID
    ///</summary>
    public int MsgId { get; set; }

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

    }

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

    public void Deserialize(ref ReadOnlyMemory<byte> buffer)
    {
        Flags = buffer.ReadInt32();
        if (Flags.IsBitSet(0)) { Dark = true; }
        Channel = buffer.Read<MyTelegram.Schema.IInputChannel>();
        MsgId = buffer.ReadInt32();
    }
}
