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

// UploadGetFileHashesRequest represents TL type `upload.getFileHashes#9156982a`.
// Get SHA256 hashes for verifying downloaded files
//
// See https://core.telegram.org/method/upload.getFileHashes for reference.
type UploadGetFileHashesRequest struct {
	// File
	Location InputFileLocationClass
	// Offset from which to get file hashes
	Offset int64
}

// UploadGetFileHashesRequestTypeID is TL type id of UploadGetFileHashesRequest.
const UploadGetFileHashesRequestTypeID = 0x9156982a

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

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

	return true
}

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

// FillFrom fills UploadGetFileHashesRequest from given interface.
func ( *UploadGetFileHashesRequest) ( interface {
	() ( InputFileLocationClass)
	() ( int64)
}) {
	.Location = .()
	.Offset = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *UploadGetFileHashesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "upload.getFileHashes",
		ID:   UploadGetFileHashesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Location",
			SchemaName: "location",
		},
		{
			Name:       "Offset",
			SchemaName: "offset",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *UploadGetFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.getFileHashes#9156982a as nil")
	}
	.PutID(UploadGetFileHashesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UploadGetFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.getFileHashes#9156982a as nil")
	}
	if .Location == nil {
		return fmt.Errorf("unable to encode upload.getFileHashes#9156982a: field location is nil")
	}
	if  := .Location.Encode();  != nil {
		return fmt.Errorf("unable to encode upload.getFileHashes#9156982a: field location: %w", )
	}
	.PutLong(.Offset)
	return nil
}

// Decode implements bin.Decoder.
func ( *UploadGetFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.getFileHashes#9156982a to nil")
	}
	if  := .ConsumeID(UploadGetFileHashesRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode upload.getFileHashes#9156982a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UploadGetFileHashesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.getFileHashes#9156982a to nil")
	}
	{
		,  := DecodeInputFileLocation()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getFileHashes#9156982a: field location: %w", )
		}
		.Location = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getFileHashes#9156982a: field offset: %w", )
		}
		.Offset = 
	}
	return nil
}

// GetLocation returns value of Location field.
func ( *UploadGetFileHashesRequest) () ( InputFileLocationClass) {
	if  == nil {
		return
	}
	return .Location
}

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

// UploadGetFileHashes invokes method upload.getFileHashes#9156982a returning error if any.
// Get SHA256 hashes for verifying downloaded files
//
// Possible errors:
//
//	400 LOCATION_INVALID: The provided location is invalid.
//
// See https://core.telegram.org/method/upload.getFileHashes for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *UploadGetFileHashesRequest) ([]FileHash, error) {
	var  FileHashVector

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