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

// MessagesSendEncryptedFileRequest represents TL type `messages.sendEncryptedFile#5559481d`.
// Sends a message with a file attachment to a secret chat
//
// See https://core.telegram.org/method/messages.sendEncryptedFile for reference.
type MessagesSendEncryptedFileRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to send the file without triggering a notification
	Silent bool
	// Secret chat ID
	Peer InputEncryptedChat
	// Unique client message ID necessary to prevent message resending
	RandomID int64
	// TL-serialization of DecryptedMessage¹ type, encrypted with a key generated during
	// chat initialization
	//
	// Links:
	//  1) https://core.telegram.org/type/DecryptedMessage
	Data []byte
	// File attachment for the secret chat
	File InputEncryptedFileClass
}

// MessagesSendEncryptedFileRequestTypeID is TL type id of MessagesSendEncryptedFileRequest.
const MessagesSendEncryptedFileRequestTypeID = 0x5559481d

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

func ( *MessagesSendEncryptedFileRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.Peer.Zero()) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.Data == nil) {
		return false
	}
	if !(.File == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendEncryptedFileRequest from given interface.
func ( *MessagesSendEncryptedFileRequest) ( interface {
	() ( bool)
	() ( InputEncryptedChat)
	() ( int64)
	() ( []byte)
	() ( InputEncryptedFileClass)
}) {
	.Silent = .()
	.Peer = .()
	.RandomID = .()
	.Data = .()
	.File = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSendEncryptedFileRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendEncryptedFile",
		ID:   MessagesSendEncryptedFileRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
		{
			Name:       "File",
			SchemaName: "file",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSendEncryptedFileRequest) () {
	if !(.Silent == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSendEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendEncryptedFile#5559481d as nil")
	}
	.PutID(MessagesSendEncryptedFileRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendEncryptedFile#5559481d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendEncryptedFile#5559481d: field flags: %w", )
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendEncryptedFile#5559481d: field peer: %w", )
	}
	.PutLong(.RandomID)
	.PutBytes(.Data)
	if .File == nil {
		return fmt.Errorf("unable to encode messages.sendEncryptedFile#5559481d: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendEncryptedFile#5559481d: field file: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSendEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendEncryptedFile#5559481d to nil")
	}
	if  := .ConsumeID(MessagesSendEncryptedFileRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.sendEncryptedFile#5559481d: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendEncryptedFileRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendEncryptedFile#5559481d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedFile#5559481d: field flags: %w", )
		}
	}
	.Silent = .Flags.Has(0)
	{
		if  := .Peer.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedFile#5559481d: field peer: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedFile#5559481d: field random_id: %w", )
		}
		.RandomID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedFile#5559481d: field data: %w", )
		}
		.Data = 
	}
	{
		,  := DecodeInputEncryptedFile()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendEncryptedFile#5559481d: field file: %w", )
		}
		.File = 
	}
	return nil
}

// SetSilent sets value of Silent conditional field.
func ( *MessagesSendEncryptedFileRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Silent = true
	} else {
		.Flags.Unset(0)
		.Silent = false
	}
}

// GetSilent returns value of Silent conditional field.
func ( *MessagesSendEncryptedFileRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetRandomID returns value of RandomID field.
func ( *MessagesSendEncryptedFileRequest) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// GetData returns value of Data field.
func ( *MessagesSendEncryptedFileRequest) () ( []byte) {
	if  == nil {
		return
	}
	return .Data
}

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

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

// MessagesSendEncryptedFile invokes method messages.sendEncryptedFile#5559481d returning error if any.
// Sends a message with a file attachment to a secret chat
//
// Possible errors:
//
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 DATA_TOO_LONG: Data too long.
//	400 ENCRYPTION_DECLINED: The secret chat was declined.
//	400 FILE_EMTPY: An empty file was provided.
//	400 MD5_CHECKSUM_INVALID: The MD5 checksums do not match.
//	400 MSG_WAIT_FAILED: A waiting call returned an error.
//
// See https://core.telegram.org/method/messages.sendEncryptedFile for reference.
func ( *Client) ( context.Context,  *MessagesSendEncryptedFileRequest) (MessagesSentEncryptedMessageClass, error) {
	var  MessagesSentEncryptedMessageBox

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