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

// UploadReuploadCDNFileRequest represents TL type `upload.reuploadCdnFile#9b2754a8`.
// Request a reupload of a certain file to a CDN DC¹.
//
// Links:
//  1. https://core.telegram.org/cdn
//
// See https://core.telegram.org/method/upload.reuploadCdnFile for reference.
type UploadReuploadCDNFileRequest struct {
	// File token
	FileToken []byte
	// Request token
	RequestToken []byte
}

// UploadReuploadCDNFileRequestTypeID is TL type id of UploadReuploadCDNFileRequest.
const UploadReuploadCDNFileRequestTypeID = 0x9b2754a8

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

func ( *UploadReuploadCDNFileRequest) () bool {
	if  == nil {
		return true
	}
	if !(.FileToken == nil) {
		return false
	}
	if !(.RequestToken == nil) {
		return false
	}

	return true
}

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

// FillFrom fills UploadReuploadCDNFileRequest from given interface.
func ( *UploadReuploadCDNFileRequest) ( interface {
	() ( []byte)
	() ( []byte)
}) {
	.FileToken = .()
	.RequestToken = .()
}

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

// TypeName returns name of type in TL schema.
func (*UploadReuploadCDNFileRequest) () string {
	return "upload.reuploadCdnFile"
}

// TypeInfo returns info about TL type.
func ( *UploadReuploadCDNFileRequest) () tdp.Type {
	 := tdp.Type{
		Name: "upload.reuploadCdnFile",
		ID:   UploadReuploadCDNFileRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FileToken",
			SchemaName: "file_token",
		},
		{
			Name:       "RequestToken",
			SchemaName: "request_token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UploadReuploadCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.reuploadCdnFile#9b2754a8 as nil")
	}
	.PutID(UploadReuploadCDNFileRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UploadReuploadCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.reuploadCdnFile#9b2754a8 as nil")
	}
	.PutBytes(.FileToken)
	.PutBytes(.RequestToken)
	return nil
}

// Decode implements bin.Decoder.
func ( *UploadReuploadCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.reuploadCdnFile#9b2754a8 to nil")
	}
	if  := .ConsumeID(UploadReuploadCDNFileRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode upload.reuploadCdnFile#9b2754a8: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UploadReuploadCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.reuploadCdnFile#9b2754a8 to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode upload.reuploadCdnFile#9b2754a8: field file_token: %w", )
		}
		.FileToken = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode upload.reuploadCdnFile#9b2754a8: field request_token: %w", )
		}
		.RequestToken = 
	}
	return nil
}

// GetFileToken returns value of FileToken field.
func ( *UploadReuploadCDNFileRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .FileToken
}

// GetRequestToken returns value of RequestToken field.
func ( *UploadReuploadCDNFileRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .RequestToken
}

// UploadReuploadCDNFile invokes method upload.reuploadCdnFile#9b2754a8 returning error if any.
// Request a reupload of a certain file to a CDN DC¹.
//
// Links:
//  1. https://core.telegram.org/cdn
//
// Possible errors:
//
//	400 CDN_METHOD_INVALID: You can't call this method in a CDN DC.
//	500 CDN_UPLOAD_TIMEOUT: A server-side timeout occurred while reuploading the file to the CDN DC.
//	400 FILE_TOKEN_INVALID: The specified file token is invalid.
//	400 RSA_DECRYPT_FAILED: Internal RSA decryption failed.
//
// See https://core.telegram.org/method/upload.reuploadCdnFile for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *UploadReuploadCDNFileRequest) ([]FileHash, error) {
	var  FileHashVector

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