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

// MessagesUploadMediaRequest represents TL type `messages.uploadMedia#519bc2b1`.
// Upload a file and associate it to a chat (without actually sending it to the chat)
//
// See https://core.telegram.org/method/messages.uploadMedia for reference.
type MessagesUploadMediaRequest struct {
	// The chat, can be inputPeerEmpty¹ for bots and inputPeerSelf² for users.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/inputPeerEmpty
	//  2) https://core.telegram.org/constructor/inputPeerSelf
	Peer InputPeerClass
	// File uploaded in chunks as described in files »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/files
	Media InputMediaClass
}

// MessagesUploadMediaRequestTypeID is TL type id of MessagesUploadMediaRequest.
const MessagesUploadMediaRequestTypeID = 0x519bc2b1

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

func ( *MessagesUploadMediaRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Media == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesUploadMediaRequest from given interface.
func ( *MessagesUploadMediaRequest) ( interface {
	() ( InputPeerClass)
	() ( InputMediaClass)
}) {
	.Peer = .()
	.Media = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesUploadMediaRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.uploadMedia",
		ID:   MessagesUploadMediaRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Media",
			SchemaName: "media",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesUploadMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.uploadMedia#519bc2b1 as nil")
	}
	.PutID(MessagesUploadMediaRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesUploadMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.uploadMedia#519bc2b1 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.uploadMedia#519bc2b1: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.uploadMedia#519bc2b1: field peer: %w", )
	}
	if .Media == nil {
		return fmt.Errorf("unable to encode messages.uploadMedia#519bc2b1: field media is nil")
	}
	if  := .Media.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.uploadMedia#519bc2b1: field media: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesUploadMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.uploadMedia#519bc2b1 to nil")
	}
	if  := .ConsumeID(MessagesUploadMediaRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.uploadMedia#519bc2b1: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesUploadMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.uploadMedia#519bc2b1 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadMedia#519bc2b1: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := DecodeInputMedia()
		if  != nil {
			return fmt.Errorf("unable to decode messages.uploadMedia#519bc2b1: field media: %w", )
		}
		.Media = 
	}
	return nil
}

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

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

// MessagesUploadMedia invokes method messages.uploadMedia#519bc2b1 returning error if any.
// Upload a file and associate it to a chat (without actually sending it to the chat)
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 CHAT_RESTRICTED: You can't send messages in this chat, you were restricted.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 FILE_PARTS_INVALID: The number of file parts is invalid.
//	400 FILE_PART_LENGTH_INVALID: The length of a file part is invalid.
//	400 IMAGE_PROCESS_FAILED: Failure while processing image.
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 MEDIA_INVALID: Media invalid.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 PHOTO_EXT_INVALID: The extension of the photo is invalid.
//	400 PHOTO_INVALID_DIMENSIONS: The photo dimensions are invalid.
//	400 PHOTO_SAVE_FILE_INVALID: Internal issues, try again later.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//	400 WEBPAGE_CURL_FAILED: Failure while fetching the webpage with cURL.
//
// See https://core.telegram.org/method/messages.uploadMedia for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesUploadMediaRequest) (MessageMediaClass, error) {
	var  MessageMediaBox

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