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

// StatsLoadAsyncGraphRequest represents TL type `stats.loadAsyncGraph#621d5fa0`.
// Load channel statistics graph¹ asynchronously
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// See https://core.telegram.org/method/stats.loadAsyncGraph for reference.
type StatsLoadAsyncGraphRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Graph token from statsGraphAsync¹ constructor
	//
	// Links:
	//  1) https://core.telegram.org/constructor/statsGraphAsync
	Token string
	// Zoom value, if required
	//
	// Use SetX and GetX helpers.
	X int64
}

// StatsLoadAsyncGraphRequestTypeID is TL type id of StatsLoadAsyncGraphRequest.
const StatsLoadAsyncGraphRequestTypeID = 0x621d5fa0

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

func ( *StatsLoadAsyncGraphRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Token == "") {
		return false
	}
	if !(.X == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StatsLoadAsyncGraphRequest from given interface.
func ( *StatsLoadAsyncGraphRequest) ( interface {
	() ( string)
	() ( int64,  bool)
}) {
	.Token = .()
	if ,  := .();  {
		.X = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *StatsLoadAsyncGraphRequest) () tdp.Type {
	 := tdp.Type{
		Name: "stats.loadAsyncGraph",
		ID:   StatsLoadAsyncGraphRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Token",
			SchemaName: "token",
		},
		{
			Name:       "X",
			SchemaName: "x",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *StatsLoadAsyncGraphRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.loadAsyncGraph#621d5fa0 as nil")
	}
	.PutID(StatsLoadAsyncGraphRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StatsLoadAsyncGraphRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode stats.loadAsyncGraph#621d5fa0 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode stats.loadAsyncGraph#621d5fa0: field flags: %w", )
	}
	.PutString(.Token)
	if .Flags.Has(0) {
		.PutLong(.X)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StatsLoadAsyncGraphRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode stats.loadAsyncGraph#621d5fa0 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode stats.loadAsyncGraph#621d5fa0: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode stats.loadAsyncGraph#621d5fa0: field token: %w", )
		}
		.Token = 
	}
	if .Flags.Has(0) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode stats.loadAsyncGraph#621d5fa0: field x: %w", )
		}
		.X = 
	}
	return nil
}

// GetToken returns value of Token field.
func ( *StatsLoadAsyncGraphRequest) () ( string) {
	if  == nil {
		return
	}
	return .Token
}

// SetX sets value of X conditional field.
func ( *StatsLoadAsyncGraphRequest) ( int64) {
	.Flags.Set(0)
	.X = 
}

// GetX returns value of X conditional field and
// boolean which is true if field was set.
func ( *StatsLoadAsyncGraphRequest) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .X, true
}

// StatsLoadAsyncGraph invokes method stats.loadAsyncGraph#621d5fa0 returning error if any.
// Load channel statistics graph¹ asynchronously
//
// Links:
//  1. https://core.telegram.org/api/stats
//
// Possible errors:
//
//	400 GRAPH_EXPIRED_RELOAD: This graph has expired, please obtain a new graph token.
//	400 GRAPH_INVALID_RELOAD: Invalid graph token provided, please reload the stats and provide the updated token.
//	400 GRAPH_OUTDATED_RELOAD: The graph is outdated, please get a new async token using stats.getBroadcastStats.
//
// See https://core.telegram.org/method/stats.loadAsyncGraph for reference.
func ( *Client) ( context.Context,  *StatsLoadAsyncGraphRequest) (StatsGraphClass, error) {
	var  StatsGraphBox

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