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

// UploadGetCDNFileHashesRequest represents TL type `upload.getCdnFileHashes#91dc3f31`.
// Get SHA256 hashes for verifying downloaded CDN¹ files
//
// Links:
//  1. https://core.telegram.org/cdn
//
// See https://core.telegram.org/method/upload.getCdnFileHashes for reference.
type UploadGetCDNFileHashesRequest struct {
	// File
	FileToken []byte
	// Offset from which to start getting hashes
	Offset int64
}

// UploadGetCDNFileHashesRequestTypeID is TL type id of UploadGetCDNFileHashesRequest.
const UploadGetCDNFileHashesRequestTypeID = 0x91dc3f31

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

func ( *UploadGetCDNFileHashesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.FileToken == nil) {
		return false
	}
	if !(.Offset == 0) {
		return false
	}

	return true
}

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

// FillFrom fills UploadGetCDNFileHashesRequest from given interface.
func ( *UploadGetCDNFileHashesRequest) ( interface {
	() ( []byte)
	() ( int64)
}) {
	.FileToken = .()
	.Offset = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *UploadGetCDNFileHashesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "upload.getCdnFileHashes",
		ID:   UploadGetCDNFileHashesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "FileToken",
			SchemaName: "file_token",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UploadGetCDNFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.getCdnFileHashes#91dc3f31 as nil")
	}
	.PutID(UploadGetCDNFileHashesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UploadGetCDNFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.getCdnFileHashes#91dc3f31 as nil")
	}
	.PutBytes(.FileToken)
	.PutLong(.Offset)
	return nil
}

// Decode implements bin.Decoder.
func ( *UploadGetCDNFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.getCdnFileHashes#91dc3f31 to nil")
	}
	if  := .ConsumeID(UploadGetCDNFileHashesRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode upload.getCdnFileHashes#91dc3f31: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UploadGetCDNFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.getCdnFileHashes#91dc3f31 to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getCdnFileHashes#91dc3f31: field file_token: %w", )
		}
		.FileToken = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getCdnFileHashes#91dc3f31: field offset: %w", )
		}
		.Offset = 
	}
	return nil
}

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

// GetOffset returns value of Offset field.
func ( *UploadGetCDNFileHashesRequest) () ( int64) {
	if  == nil {
		return
	}
	return .Offset
}

// UploadGetCDNFileHashes invokes method upload.getCdnFileHashes#91dc3f31 returning error if any.
// Get SHA256 hashes for verifying downloaded CDN¹ files
//
// Links:
//  1. https://core.telegram.org/cdn
//
// Possible errors:
//
//	400 CDN_METHOD_INVALID: You can't call this method in a 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.getCdnFileHashes for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *UploadGetCDNFileHashesRequest) ([]FileHash, error) {
	var  FileHashVector

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