// 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{}
)

// StatsGetBroadcastStatsRequest represents TL type `stats.getBroadcastStats#ab42441a`.
// Get channel statisticsĀ¹
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// See https://core.telegram.org/method/stats.getBroadcastStats for reference.
type StatsGetBroadcastStatsRequest 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
	// The channel
	Channel InputChannelClass
}

// StatsGetBroadcastStatsRequestTypeID is TL type id of StatsGetBroadcastStatsRequest.
const StatsGetBroadcastStatsRequestTypeID = 0xab42441a

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

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

	return true
}

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

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *StatsGetBroadcastStatsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.getBroadcastStats#ab42441a as nil")
	}
	.PutID(StatsGetBroadcastStatsRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

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

// StatsGetBroadcastStats invokes method stats.getBroadcastStats#ab42441a returning error if any.
// Get channel statisticsĀ¹
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// Possible errors:
//
//	400 BROADCAST_REQUIRED: This method can only be called on a channel, please use stats.getMegagroupStats for supergroups.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//
// See https://core.telegram.org/method/stats.getBroadcastStats for reference.
func ( *Client) ( context.Context,  *StatsGetBroadcastStatsRequest) (*StatsBroadcastStats, error) {
	var  StatsBroadcastStats

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