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

// MessagesGetDhConfigRequest represents TL type `messages.getDhConfig#26cf8950`.
// Returns configuration parameters for Diffie-Hellman key generation. Can also return a
// random sequence of bytes of required length.
//
// See https://core.telegram.org/method/messages.getDhConfig for reference.
type MessagesGetDhConfigRequest struct {
	// Value of the version parameter from messages.dhConfig¹, available at the client
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messages.dhConfig
	Version int
	// Length of the required random sequence
	RandomLength int
}

// MessagesGetDhConfigRequestTypeID is TL type id of MessagesGetDhConfigRequest.
const MessagesGetDhConfigRequestTypeID = 0x26cf8950

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

func ( *MessagesGetDhConfigRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Version == 0) {
		return false
	}
	if !(.RandomLength == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesGetDhConfigRequest from given interface.
func ( *MessagesGetDhConfigRequest) ( interface {
	() ( int)
	() ( int)
}) {
	.Version = .()
	.RandomLength = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesGetDhConfigRequest) () string {
	return "messages.getDhConfig"
}

// TypeInfo returns info about TL type.
func ( *MessagesGetDhConfigRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getDhConfig",
		ID:   MessagesGetDhConfigRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Version",
			SchemaName: "version",
		},
		{
			Name:       "RandomLength",
			SchemaName: "random_length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesGetDhConfigRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getDhConfig#26cf8950 as nil")
	}
	.PutID(MessagesGetDhConfigRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesGetDhConfigRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getDhConfig#26cf8950 as nil")
	}
	.PutInt(.Version)
	.PutInt(.RandomLength)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesGetDhConfigRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getDhConfig#26cf8950 to nil")
	}
	if  := .ConsumeID(MessagesGetDhConfigRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.getDhConfig#26cf8950: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesGetDhConfigRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.getDhConfig#26cf8950 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDhConfig#26cf8950: field version: %w", )
		}
		.Version = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.getDhConfig#26cf8950: field random_length: %w", )
		}
		.RandomLength = 
	}
	return nil
}

// GetVersion returns value of Version field.
func ( *MessagesGetDhConfigRequest) () ( int) {
	if  == nil {
		return
	}
	return .Version
}

// GetRandomLength returns value of RandomLength field.
func ( *MessagesGetDhConfigRequest) () ( int) {
	if  == nil {
		return
	}
	return .RandomLength
}

// MessagesGetDhConfig invokes method messages.getDhConfig#26cf8950 returning error if any.
// Returns configuration parameters for Diffie-Hellman key generation. Can also return a
// random sequence of bytes of required length.
//
// Possible errors:
//
//	400 RANDOM_LENGTH_INVALID: Random length invalid.
//
// See https://core.telegram.org/method/messages.getDhConfig for reference.
func ( *Client) ( context.Context,  *MessagesGetDhConfigRequest) (MessagesDhConfigClass, error) {
	var  MessagesDhConfigBox

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