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

// BotsCheckDownloadFileParamsRequest represents TL type `bots.checkDownloadFileParams#50077589`.
// Check if a mini app¹ can request the download of a specific file: called when
// handling web_app_request_file_download events »²
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//  2. https://core.telegram.org/api/web-events#web-app-request-file-download
//
// See https://core.telegram.org/method/bots.checkDownloadFileParams for reference.
type BotsCheckDownloadFileParamsRequest struct {
	// The bot that owns the mini app¹ that requested the download
	//
	// Links:
	//  1) https://core.telegram.org/api/bots/webapps
	Bot InputUserClass
	// The filename from the web_app_request_file_download event »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/web-events#web-app-request-file-download
	FileName string
	// The url from the web_app_request_file_download event »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/web-events#web-app-request-file-download
	URL string
}

// BotsCheckDownloadFileParamsRequestTypeID is TL type id of BotsCheckDownloadFileParamsRequest.
const BotsCheckDownloadFileParamsRequestTypeID = 0x50077589

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

func ( *BotsCheckDownloadFileParamsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.FileName == "") {
		return false
	}
	if !(.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills BotsCheckDownloadFileParamsRequest from given interface.
func ( *BotsCheckDownloadFileParamsRequest) ( interface {
	() ( InputUserClass)
	() ( string)
	() ( string)
}) {
	.Bot = .()
	.FileName = .()
	.URL = .()
}

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

// TypeName returns name of type in TL schema.
func (*BotsCheckDownloadFileParamsRequest) () string {
	return "bots.checkDownloadFileParams"
}

// TypeInfo returns info about TL type.
func ( *BotsCheckDownloadFileParamsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "bots.checkDownloadFileParams",
		ID:   BotsCheckDownloadFileParamsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Bot",
			SchemaName: "bot",
		},
		{
			Name:       "FileName",
			SchemaName: "file_name",
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *BotsCheckDownloadFileParamsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.checkDownloadFileParams#50077589 as nil")
	}
	.PutID(BotsCheckDownloadFileParamsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *BotsCheckDownloadFileParamsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode bots.checkDownloadFileParams#50077589 as nil")
	}
	if .Bot == nil {
		return fmt.Errorf("unable to encode bots.checkDownloadFileParams#50077589: field bot is nil")
	}
	if  := .Bot.Encode();  != nil {
		return fmt.Errorf("unable to encode bots.checkDownloadFileParams#50077589: field bot: %w", )
	}
	.PutString(.FileName)
	.PutString(.URL)
	return nil
}

// Decode implements bin.Decoder.
func ( *BotsCheckDownloadFileParamsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.checkDownloadFileParams#50077589 to nil")
	}
	if  := .ConsumeID(BotsCheckDownloadFileParamsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode bots.checkDownloadFileParams#50077589: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *BotsCheckDownloadFileParamsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode bots.checkDownloadFileParams#50077589 to nil")
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode bots.checkDownloadFileParams#50077589: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.checkDownloadFileParams#50077589: field file_name: %w", )
		}
		.FileName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode bots.checkDownloadFileParams#50077589: field url: %w", )
		}
		.URL = 
	}
	return nil
}

// GetBot returns value of Bot field.
func ( *BotsCheckDownloadFileParamsRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .Bot
}

// GetFileName returns value of FileName field.
func ( *BotsCheckDownloadFileParamsRequest) () ( string) {
	if  == nil {
		return
	}
	return .FileName
}

// GetURL returns value of URL field.
func ( *BotsCheckDownloadFileParamsRequest) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// BotsCheckDownloadFileParams invokes method bots.checkDownloadFileParams#50077589 returning error if any.
// Check if a mini app¹ can request the download of a specific file: called when
// handling web_app_request_file_download events »²
//
// Links:
//  1. https://core.telegram.org/api/bots/webapps
//  2. https://core.telegram.org/api/web-events#web-app-request-file-download
//
// Possible errors:
//
//	400 BOT_INVALID: This is not a valid bot.
//
// See https://core.telegram.org/method/bots.checkDownloadFileParams for reference.
func ( *Client) ( context.Context,  *BotsCheckDownloadFileParamsRequest) (bool, error) {
	var  BoolBox

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