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

// MessagesUploadEncryptedFileRequest represents TL type `messages.uploadEncryptedFile#5057c497`.
// Upload encrypted file and associate it to a secret chat
//
// See https://core.telegram.org/method/messages.uploadEncryptedFile for reference.
type MessagesUploadEncryptedFileRequest struct {
	// The secret chat to associate the file to
	Peer InputEncryptedChat
	// The file
	File InputEncryptedFileClass
}

// MessagesUploadEncryptedFileRequestTypeID is TL type id of MessagesUploadEncryptedFileRequest.
const MessagesUploadEncryptedFileRequestTypeID = 0x5057c497

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

func ( *MessagesUploadEncryptedFileRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.File == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesUploadEncryptedFileRequest from given interface.
func ( *MessagesUploadEncryptedFileRequest) ( interface {
	() ( InputEncryptedChat)
	() ( InputEncryptedFileClass)
}) {
	.Peer = .()
	.File = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesUploadEncryptedFileRequest) () string {
	return "messages.uploadEncryptedFile"
}

// TypeInfo returns info about TL type.
func ( *MessagesUploadEncryptedFileRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.uploadEncryptedFile",
		ID:   MessagesUploadEncryptedFileRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "File",
			SchemaName: "file",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesUploadEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.uploadEncryptedFile#5057c497 as nil")
	}
	.PutID(MessagesUploadEncryptedFileRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesUploadEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.uploadEncryptedFile#5057c497 as nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.uploadEncryptedFile#5057c497: field peer: %w", )
	}
	if .File == nil {
		return fmt.Errorf("unable to encode messages.uploadEncryptedFile#5057c497: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.uploadEncryptedFile#5057c497: field file: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesUploadEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.uploadEncryptedFile#5057c497 to nil")
	}
	if  := .ConsumeID(MessagesUploadEncryptedFileRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.uploadEncryptedFile#5057c497: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesUploadEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.uploadEncryptedFile#5057c497 to nil")
	}
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.uploadEncryptedFile#5057c497: field peer: %w", )
		}
	}
	{
		,  := DecodeInputEncryptedFile()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadEncryptedFile#5057c497: field file: %w", )
		}
		.File = 
	}
	return nil
}

// GetPeer returns value of Peer field.
func ( *MessagesUploadEncryptedFileRequest) () ( InputEncryptedChat) {
	if  == nil {
		return
	}
	return .Peer
}

// GetFile returns value of File field.
func ( *MessagesUploadEncryptedFileRequest) () ( InputEncryptedFileClass) {
	if  == nil {
		return
	}
	return .File
}

// GetFileAsNotEmpty returns mapped value of File field.
func ( *MessagesUploadEncryptedFileRequest) () (NotEmptyInputEncryptedFile, bool) {
	return .File.AsNotEmpty()
}

// MessagesUploadEncryptedFile invokes method messages.uploadEncryptedFile#5057c497 returning error if any.
// Upload encrypted file and associate it to a secret chat
//
// See https://core.telegram.org/method/messages.uploadEncryptedFile for reference.
func ( *Client) ( context.Context,  *MessagesUploadEncryptedFileRequest) (EncryptedFileClass, error) {
	var  EncryptedFileBox

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