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

// UploadGetCDNFileRequest represents TL type `upload.getCdnFile#395f69da`.
// Download a CDN¹ file.
//
// Links:
//  1. https://core.telegram.org/cdn
//
// See https://core.telegram.org/method/upload.getCdnFile for reference.
type UploadGetCDNFileRequest struct {
	// File token
	FileToken []byte
	// Offset of chunk to download
	Offset int64
	// Length of chunk to download
	Limit int
}

// UploadGetCDNFileRequestTypeID is TL type id of UploadGetCDNFileRequest.
const UploadGetCDNFileRequestTypeID = 0x395f69da

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *UploadGetCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.getCdnFile#395f69da as nil")
	}
	.PutID(UploadGetCDNFileRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *UploadGetCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode upload.getCdnFile#395f69da as nil")
	}
	.PutBytes(.FileToken)
	.PutLong(.Offset)
	.PutInt(.Limit)
	return nil
}

// Decode implements bin.Decoder.
func ( *UploadGetCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.getCdnFile#395f69da to nil")
	}
	if  := .ConsumeID(UploadGetCDNFileRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode upload.getCdnFile#395f69da: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *UploadGetCDNFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode upload.getCdnFile#395f69da to nil")
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getCdnFile#395f69da: field file_token: %w", )
		}
		.FileToken = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getCdnFile#395f69da: field offset: %w", )
		}
		.Offset = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode upload.getCdnFile#395f69da: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

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

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

// GetLimit returns value of Limit field.
func ( *UploadGetCDNFileRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

// UploadGetCDNFile invokes method upload.getCdnFile#395f69da returning error if any.
// Download a CDN¹ file.
//
// Links:
//  1. https://core.telegram.org/cdn
//
// See https://core.telegram.org/method/upload.getCdnFile for reference.
func ( *Client) ( context.Context,  *UploadGetCDNFileRequest) (UploadCDNFileClass, error) {
	var  UploadCDNFileBox

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