// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// StatsGetMessageStatsRequest represents TL type `stats.getMessageStats#b6e0a3f5`.
// Get message statisticsĀ¹
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// See https://core.telegram.org/method/stats.getMessageStats for reference.
type StatsGetMessageStatsRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to enable dark theme for graph colors
	Dark bool
	// Channel ID
	Channel InputChannelClass
	// Message ID
	MsgID int
}

// StatsGetMessageStatsRequestTypeID is TL type id of StatsGetMessageStatsRequest.
const StatsGetMessageStatsRequestTypeID = 0xb6e0a3f5

// Ensuring interfaces in compile-time for StatsGetMessageStatsRequest.
var (
	_ bin.Encoder     = &StatsGetMessageStatsRequest{}
	_ bin.Decoder     = &StatsGetMessageStatsRequest{}
	_ bin.BareEncoder = &StatsGetMessageStatsRequest{}
	_ bin.BareDecoder = &StatsGetMessageStatsRequest{}
)

func ( *StatsGetMessageStatsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Dark == false) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.MsgID == 0) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *StatsGetMessageStatsRequest) () string {
	if  == nil {
		return "StatsGetMessageStatsRequest(nil)"
	}
	type  StatsGetMessageStatsRequest
	return fmt.Sprintf("StatsGetMessageStatsRequest%+v", (*))
}

// FillFrom fills StatsGetMessageStatsRequest from given interface.
func ( *StatsGetMessageStatsRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
	() ( int)
}) {
	.Dark = .()
	.Channel = .()
	.MsgID = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*StatsGetMessageStatsRequest) () uint32 {
	return StatsGetMessageStatsRequestTypeID
}

// TypeName returns name of type in TL schema.
func (*StatsGetMessageStatsRequest) () string {
	return "stats.getMessageStats"
}

// TypeInfo returns info about TL type.
func ( *StatsGetMessageStatsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stats.getMessageStats",
		ID:   StatsGetMessageStatsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Dark",
			SchemaName: "dark",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "MsgID",
			SchemaName: "msg_id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StatsGetMessageStatsRequest) () {
	if !(.Dark == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *StatsGetMessageStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getMessageStats#b6e0a3f5 as nil")
	}
	.PutID(StatsGetMessageStatsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsGetMessageStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getMessageStats#b6e0a3f5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.getMessageStats#b6e0a3f5: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode stats.getMessageStats#b6e0a3f5: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.getMessageStats#b6e0a3f5: field channel: %w", )
	}
	.PutInt(.MsgID)
	return nil
}

// Decode implements bin.Decoder.
func ( *StatsGetMessageStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getMessageStats#b6e0a3f5 to nil")
	}
	if  := .ConsumeID(StatsGetMessageStatsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode stats.getMessageStats#b6e0a3f5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StatsGetMessageStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.getMessageStats#b6e0a3f5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.getMessageStats#b6e0a3f5: field flags: %w", )
		}
	}
	.Dark = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getMessageStats#b6e0a3f5: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode stats.getMessageStats#b6e0a3f5: field msg_id: %w", )
		}
		.MsgID = 
	}
	return nil
}

// SetDark sets value of Dark conditional field.
func ( *StatsGetMessageStatsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Dark = true
	} else {
		.Flags.Unset(0)
		.Dark = false
	}
}

// GetDark returns value of Dark conditional field.
func ( *StatsGetMessageStatsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetChannel returns value of Channel field.
func ( *StatsGetMessageStatsRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

// GetMsgID returns value of MsgID field.
func ( *StatsGetMessageStatsRequest) () ( int) {
	if  == nil {
		return
	}
	return .MsgID
}

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *StatsGetMessageStatsRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// StatsGetMessageStats invokes method stats.getMessageStats#b6e0a3f5 returning error if any.
// Get message statisticsĀ¹
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// Possible errors:
//
//	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 https://core.telegram.org/method/stats.getMessageStats for reference.
func ( *Client) ( context.Context,  *StatsGetMessageStatsRequest) (*StatsMessageStats, error) {
	var  StatsMessageStats

	if  := .rpc.Invoke(, , &);  != nil {
		return nil, 
	}
	return &, nil
}