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

// MessagesUploadImportedMediaRequest represents TL type `messages.uploadImportedMedia#2a862092`.
// Upload a media file associated with an imported chat, click here for more info »¹.
//
// Links:
//  1. https://core.telegram.org/api/import
//
// See https://core.telegram.org/method/messages.uploadImportedMedia for reference.
type MessagesUploadImportedMediaRequest struct {
	// The Telegram chat where the media will be imported
	Peer InputPeerClass
	// Identifier of a history import session¹, returned by messages.initHistoryImport²
	//
	// Links:
	//  1) https://core.telegram.org/api/import
	//  2) https://core.telegram.org/method/messages.initHistoryImport
	ImportID int64
	// File name
	FileName string
	// Media metadata
	Media InputMediaClass
}

// MessagesUploadImportedMediaRequestTypeID is TL type id of MessagesUploadImportedMediaRequest.
const MessagesUploadImportedMediaRequestTypeID = 0x2a862092

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

func ( *MessagesUploadImportedMediaRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ImportID == 0) {
		return false
	}
	if !(.FileName == "") {
		return false
	}
	if !(.Media == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesUploadImportedMediaRequest from given interface.
func ( *MessagesUploadImportedMediaRequest) ( interface {
	() ( InputPeerClass)
	() ( int64)
	() ( string)
	() ( InputMediaClass)
}) {
	.Peer = .()
	.ImportID = .()
	.FileName = .()
	.Media = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesUploadImportedMediaRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.uploadImportedMedia",
		ID:   MessagesUploadImportedMediaRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ImportID",
			SchemaName: "import_id",
		},
		{
			Name:       "FileName",
			SchemaName: "file_name",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesUploadImportedMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.uploadImportedMedia#2a862092 as nil")
	}
	.PutID(MessagesUploadImportedMediaRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesUploadImportedMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.uploadImportedMedia#2a862092 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.uploadImportedMedia#2a862092: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.uploadImportedMedia#2a862092: field peer: %w", )
	}
	.PutLong(.ImportID)
	.PutString(.FileName)
	if .Media == nil {
		return fmt.Errorf("unable to encode messages.uploadImportedMedia#2a862092: field media is nil")
	}
	if  := .Media.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.uploadImportedMedia#2a862092: field media: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesUploadImportedMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.uploadImportedMedia#2a862092 to nil")
	}
	if  := .ConsumeID(MessagesUploadImportedMediaRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.uploadImportedMedia#2a862092: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesUploadImportedMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.uploadImportedMedia#2a862092 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadImportedMedia#2a862092: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadImportedMedia#2a862092: field import_id: %w", )
		}
		.ImportID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadImportedMedia#2a862092: field file_name: %w", )
		}
		.FileName = 
	}
	{
		,  := DecodeInputMedia()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadImportedMedia#2a862092: field media: %w", )
		}
		.Media = 
	}
	return nil
}

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

// GetImportID returns value of ImportID field.
func ( *MessagesUploadImportedMediaRequest) () ( int64) {
	if  == nil {
		return
	}
	return .ImportID
}

// GetFileName returns value of FileName field.
func ( *MessagesUploadImportedMediaRequest) () ( string) {
	if  == nil {
		return
	}
	return .FileName
}

// GetMedia returns value of Media field.
func ( *MessagesUploadImportedMediaRequest) () ( InputMediaClass) {
	if  == nil {
		return
	}
	return .Media
}

// MessagesUploadImportedMedia invokes method messages.uploadImportedMedia#2a862092 returning error if any.
// Upload a media file associated with an imported chat, click here for more info »¹.
//
// Links:
//  1. https://core.telegram.org/api/import
//
// Possible errors:
//
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//
// See https://core.telegram.org/method/messages.uploadImportedMedia for reference.
func ( *Client) ( context.Context,  *MessagesUploadImportedMediaRequest) (MessageMediaClass, error) {
	var  MessageMediaBox

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