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

// MessagesEditMessageRequest represents TL type `messages.editMessage#48f71778`.
// Edit message
//
// See https://core.telegram.org/method/messages.editMessage for reference.
type MessagesEditMessageRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Disable webpage preview
	NoWebpage bool
	// If set, any eventual webpage preview will be shown on top of the message instead of at
	// the bottom.
	InvertMedia bool
	// Where was the message sent
	Peer InputPeerClass
	// ID of the message to edit
	ID int
	// New message
	//
	// Use SetMessage and GetMessage helpers.
	Message string
	// New attached media
	//
	// Use SetMedia and GetMedia helpers.
	Media InputMediaClass
	// Reply markup for inline keyboards
	//
	// Use SetReplyMarkup and GetReplyMarkup helpers.
	ReplyMarkup ReplyMarkupClass
	// Message entities for styled text¹
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	//
	// Use SetEntities and GetEntities helpers.
	Entities []MessageEntityClass
	// Scheduled message date for scheduled messages¹
	//
	// Links:
	//  1) https://core.telegram.org/api/scheduled-messages
	//
	// Use SetScheduleDate and GetScheduleDate helpers.
	ScheduleDate int
}

// MessagesEditMessageRequestTypeID is TL type id of MessagesEditMessageRequest.
const MessagesEditMessageRequestTypeID = 0x48f71778

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

func ( *MessagesEditMessageRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.NoWebpage == false) {
		return false
	}
	if !(.InvertMedia == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Message == "") {
		return false
	}
	if !(.Media == nil) {
		return false
	}
	if !(.ReplyMarkup == nil) {
		return false
	}
	if !(.Entities == nil) {
		return false
	}
	if !(.ScheduleDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesEditMessageRequest from given interface.
func ( *MessagesEditMessageRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( int)
	() ( string,  bool)
	() ( InputMediaClass,  bool)
	() ( ReplyMarkupClass,  bool)
	() ( []MessageEntityClass,  bool)
	() ( int,  bool)
}) {
	.NoWebpage = .()
	.InvertMedia = .()
	.Peer = .()
	.ID = .()
	if ,  := .();  {
		.Message = 
	}

	if ,  := .();  {
		.Media = 
	}

	if ,  := .();  {
		.ReplyMarkup = 
	}

	if ,  := .();  {
		.Entities = 
	}

	if ,  := .();  {
		.ScheduleDate = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesEditMessageRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.editMessage",
		ID:   MessagesEditMessageRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "NoWebpage",
			SchemaName: "no_webpage",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "InvertMedia",
			SchemaName: "invert_media",
			Null:       !.Flags.Has(16),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "Media",
			SchemaName: "media",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "ReplyMarkup",
			SchemaName: "reply_markup",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Entities",
			SchemaName: "entities",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ScheduleDate",
			SchemaName: "schedule_date",
			Null:       !.Flags.Has(15),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesEditMessageRequest) () {
	if !(.NoWebpage == false) {
		.Flags.Set(1)
	}
	if !(.InvertMedia == false) {
		.Flags.Set(16)
	}
	if !(.Message == "") {
		.Flags.Set(11)
	}
	if !(.Media == nil) {
		.Flags.Set(14)
	}
	if !(.ReplyMarkup == nil) {
		.Flags.Set(2)
	}
	if !(.Entities == nil) {
		.Flags.Set(3)
	}
	if !(.ScheduleDate == 0) {
		.Flags.Set(15)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesEditMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editMessage#48f71778 as nil")
	}
	.PutID(MessagesEditMessageRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesEditMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editMessage#48f71778 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editMessage#48f71778: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.editMessage#48f71778: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editMessage#48f71778: field peer: %w", )
	}
	.PutInt(.ID)
	if .Flags.Has(11) {
		.PutString(.Message)
	}
	if .Flags.Has(14) {
		if .Media == nil {
			return fmt.Errorf("unable to encode messages.editMessage#48f71778: field media is nil")
		}
		if  := .Media.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.editMessage#48f71778: field media: %w", )
		}
	}
	if .Flags.Has(2) {
		if .ReplyMarkup == nil {
			return fmt.Errorf("unable to encode messages.editMessage#48f71778: field reply_markup is nil")
		}
		if  := .ReplyMarkup.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.editMessage#48f71778: field reply_markup: %w", )
		}
	}
	if .Flags.Has(3) {
		.PutVectorHeader(len(.Entities))
		for ,  := range .Entities {
			if  == nil {
				return fmt.Errorf("unable to encode messages.editMessage#48f71778: field entities element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode messages.editMessage#48f71778: field entities element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(15) {
		.PutInt(.ScheduleDate)
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesEditMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.editMessage#48f71778 to nil")
	}
	if  := .ConsumeID(MessagesEditMessageRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.editMessage#48f71778: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesEditMessageRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.editMessage#48f71778 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field flags: %w", )
		}
	}
	.NoWebpage = .Flags.Has(1)
	.InvertMedia = .Flags.Has(16)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(11) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field message: %w", )
		}
		.Message = 
	}
	if .Flags.Has(14) {
		,  := DecodeInputMedia()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field media: %w", )
		}
		.Media = 
	}
	if .Flags.Has(2) {
		,  := DecodeReplyMarkup()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field reply_markup: %w", )
		}
		.ReplyMarkup = 
	}
	if .Flags.Has(3) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field entities: %w", )
		}

		if  > 0 {
			.Entities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode messages.editMessage#48f71778: field entities: %w", )
			}
			.Entities = append(.Entities, )
		}
	}
	if .Flags.Has(15) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editMessage#48f71778: field schedule_date: %w", )
		}
		.ScheduleDate = 
	}
	return nil
}

// SetNoWebpage sets value of NoWebpage conditional field.
func ( *MessagesEditMessageRequest) ( bool) {
	if  {
		.Flags.Set(1)
		.NoWebpage = true
	} else {
		.Flags.Unset(1)
		.NoWebpage = false
	}
}

// GetNoWebpage returns value of NoWebpage conditional field.
func ( *MessagesEditMessageRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetInvertMedia sets value of InvertMedia conditional field.
func ( *MessagesEditMessageRequest) ( bool) {
	if  {
		.Flags.Set(16)
		.InvertMedia = true
	} else {
		.Flags.Unset(16)
		.InvertMedia = false
	}
}

// GetInvertMedia returns value of InvertMedia conditional field.
func ( *MessagesEditMessageRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(16)
}

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

// GetID returns value of ID field.
func ( *MessagesEditMessageRequest) () ( int) {
	if  == nil {
		return
	}
	return .ID
}

// SetMessage sets value of Message conditional field.
func ( *MessagesEditMessageRequest) ( string) {
	.Flags.Set(11)
	.Message = 
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func ( *MessagesEditMessageRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(11) {
		return , false
	}
	return .Message, true
}

// SetMedia sets value of Media conditional field.
func ( *MessagesEditMessageRequest) ( InputMediaClass) {
	.Flags.Set(14)
	.Media = 
}

// GetMedia returns value of Media conditional field and
// boolean which is true if field was set.
func ( *MessagesEditMessageRequest) () ( InputMediaClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(14) {
		return , false
	}
	return .Media, true
}

// SetReplyMarkup sets value of ReplyMarkup conditional field.
func ( *MessagesEditMessageRequest) ( ReplyMarkupClass) {
	.Flags.Set(2)
	.ReplyMarkup = 
}

// GetReplyMarkup returns value of ReplyMarkup conditional field and
// boolean which is true if field was set.
func ( *MessagesEditMessageRequest) () ( ReplyMarkupClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .ReplyMarkup, true
}

// SetEntities sets value of Entities conditional field.
func ( *MessagesEditMessageRequest) ( []MessageEntityClass) {
	.Flags.Set(3)
	.Entities = 
}

// GetEntities returns value of Entities conditional field and
// boolean which is true if field was set.
func ( *MessagesEditMessageRequest) () ( []MessageEntityClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Entities, true
}

// SetScheduleDate sets value of ScheduleDate conditional field.
func ( *MessagesEditMessageRequest) ( int) {
	.Flags.Set(15)
	.ScheduleDate = 
}

// GetScheduleDate returns value of ScheduleDate conditional field and
// boolean which is true if field was set.
func ( *MessagesEditMessageRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(15) {
		return , false
	}
	return .ScheduleDate, true
}

// MapEntities returns field Entities wrapped in MessageEntityClassArray helper.
func ( *MessagesEditMessageRequest) () ( MessageEntityClassArray,  bool) {
	if !.Flags.Has(3) {
		return , false
	}
	return MessageEntityClassArray(.Entities), true
}

// MessagesEditMessage invokes method messages.editMessage#48f71778 returning error if any.
// Edit message
//
// Possible errors:
//
//	400 BOT_DOMAIN_INVALID: Bot domain invalid.
//	400 BOT_INVALID: This is not a valid bot.
//	400 BUTTON_DATA_INVALID: The data of one or more of the buttons you provided is invalid.
//	400 BUTTON_TYPE_INVALID: The type of one or more of the buttons you provided is invalid.
//	400 BUTTON_URL_INVALID: Button URL invalid.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_FORWARDS_RESTRICTED: You can't forward messages from a protected chat.
//	403 CHAT_SEND_GIFS_FORBIDDEN: You can't send gifs in this chat.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 DOCUMENT_INVALID: The specified document is invalid.
//	400 ENTITIES_TOO_LONG: You provided too many styled message entities.
//	400 ENTITY_BOUNDS_INVALID: A specified entity offset or length is invalid, see here » for info on how to properly compute the entity offset/length.
//	400 FILE_PARTS_INVALID: The number of file parts is invalid.
//	400 IMAGE_PROCESS_FAILED: Failure while processing image.
//	403 INLINE_BOT_REQUIRED: Only the inline bot can edit message.
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 MEDIA_CAPTION_TOO_LONG: The caption is too long.
//	400 MEDIA_EMPTY: The provided media object is invalid.
//	400 MEDIA_GROUPED_INVALID: You tried to send media of different types in an album.
//	400 MEDIA_INVALID: Media invalid.
//	400 MEDIA_NEW_INVALID: The new media is invalid.
//	400 MEDIA_PREV_INVALID: Previous media invalid.
//	400 MEDIA_TTL_INVALID: The specified media TTL is invalid.
//	403 MESSAGE_AUTHOR_REQUIRED: Message author required.
//	400 MESSAGE_EDIT_TIME_EXPIRED: You can't edit this message anymore, too much time has passed since its creation.
//	400 MESSAGE_EMPTY: The provided message is empty.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//	400 MESSAGE_NOT_MODIFIED: The provided message data is identical to the previous message data, the message wasn't modified.
//	400 MESSAGE_TOO_LONG: The provided message is too long.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	500 MSG_WAIT_FAILED: A waiting call returned an error.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 REPLY_MARKUP_INVALID: The provided reply markup is invalid.
//	400 SCHEDULE_DATE_INVALID: Invalid schedule date provided.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//
// See https://core.telegram.org/method/messages.editMessage for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesEditMessageRequest) (UpdatesClass, error) {
	var  UpdatesBox

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