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

// MessagesSendMultiMediaRequest represents TL type `messages.sendMultiMedia#456e8987`.
// Send an album or grouped media¹
//
// Links:
//  1. https://core.telegram.org/api/files#albums-grouped-media
//
// See https://core.telegram.org/method/messages.sendMultiMedia for reference.
type MessagesSendMultiMediaRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to send the album silently (no notification triggered)
	Silent bool
	// Send in background?
	Background bool
	// Whether to clear drafts¹
	//
	// Links:
	//  1) https://core.telegram.org/api/drafts
	ClearDraft bool
	// Only for bots, disallows forwarding and saving of the messages, even if the
	// destination chat doesn't have content protection¹ enabled
	//
	// Links:
	//  1) https://telegram.org/blog/protected-content-delete-by-date-and-more
	Noforwards bool
	// Whether to move used stickersets to top, see here for more info on this flag »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers#recent-stickersets
	UpdateStickersetsOrder bool
	// If set, any eventual webpage preview will be shown on top of the message instead of at
	// the bottom.
	InvertMedia bool
	// The destination chat
	Peer InputPeerClass
	// If set, indicates that the message should be sent in reply to the specified message or
	// story.
	//
	// Use SetReplyTo and GetReplyTo helpers.
	ReplyTo InputReplyToClass
	// The medias to send: note that they must be separately uploaded using messages
	// uploadMedia¹ first, using raw inputMediaUploaded* constructors is not supported.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.uploadMedia
	MultiMedia []InputSingleMedia
	// Scheduled message date for scheduled messages
	//
	// Use SetScheduleDate and GetScheduleDate helpers.
	ScheduleDate int
	// Send this message as the specified peer
	//
	// Use SetSendAs and GetSendAs helpers.
	SendAs InputPeerClass
}

// MessagesSendMultiMediaRequestTypeID is TL type id of MessagesSendMultiMediaRequest.
const MessagesSendMultiMediaRequestTypeID = 0x456e8987

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

func ( *MessagesSendMultiMediaRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Silent == false) {
		return false
	}
	if !(.Background == false) {
		return false
	}
	if !(.ClearDraft == false) {
		return false
	}
	if !(.Noforwards == false) {
		return false
	}
	if !(.UpdateStickersetsOrder == false) {
		return false
	}
	if !(.InvertMedia == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.ReplyTo == nil) {
		return false
	}
	if !(.MultiMedia == nil) {
		return false
	}
	if !(.ScheduleDate == 0) {
		return false
	}
	if !(.SendAs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesSendMultiMediaRequest from given interface.
func ( *MessagesSendMultiMediaRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( InputPeerClass)
	() ( InputReplyToClass,  bool)
	() ( []InputSingleMedia)
	() ( int,  bool)
	() ( InputPeerClass,  bool)
}) {
	.Silent = .()
	.Background = .()
	.ClearDraft = .()
	.Noforwards = .()
	.UpdateStickersetsOrder = .()
	.InvertMedia = .()
	.Peer = .()
	if ,  := .();  {
		.ReplyTo = 
	}

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesSendMultiMediaRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.sendMultiMedia",
		ID:   MessagesSendMultiMediaRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Silent",
			SchemaName: "silent",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Background",
			SchemaName: "background",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ClearDraft",
			SchemaName: "clear_draft",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Noforwards",
			SchemaName: "noforwards",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "UpdateStickersetsOrder",
			SchemaName: "update_stickersets_order",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "InvertMedia",
			SchemaName: "invert_media",
			Null:       !.Flags.Has(16),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "ReplyTo",
			SchemaName: "reply_to",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "MultiMedia",
			SchemaName: "multi_media",
		},
		{
			Name:       "ScheduleDate",
			SchemaName: "schedule_date",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "SendAs",
			SchemaName: "send_as",
			Null:       !.Flags.Has(13),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesSendMultiMediaRequest) () {
	if !(.Silent == false) {
		.Flags.Set(5)
	}
	if !(.Background == false) {
		.Flags.Set(6)
	}
	if !(.ClearDraft == false) {
		.Flags.Set(7)
	}
	if !(.Noforwards == false) {
		.Flags.Set(14)
	}
	if !(.UpdateStickersetsOrder == false) {
		.Flags.Set(15)
	}
	if !(.InvertMedia == false) {
		.Flags.Set(16)
	}
	if !(.ReplyTo == nil) {
		.Flags.Set(0)
	}
	if !(.ScheduleDate == 0) {
		.Flags.Set(10)
	}
	if !(.SendAs == nil) {
		.Flags.Set(13)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesSendMultiMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendMultiMedia#456e8987 as nil")
	}
	.PutID(MessagesSendMultiMediaRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesSendMultiMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.sendMultiMedia#456e8987 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field peer: %w", )
	}
	if .Flags.Has(0) {
		if .ReplyTo == nil {
			return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field reply_to is nil")
		}
		if  := .ReplyTo.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field reply_to: %w", )
		}
	}
	.PutVectorHeader(len(.MultiMedia))
	for ,  := range .MultiMedia {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field multi_media element with index %d: %w", , )
		}
	}
	if .Flags.Has(10) {
		.PutInt(.ScheduleDate)
	}
	if .Flags.Has(13) {
		if .SendAs == nil {
			return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field send_as is nil")
		}
		if  := .SendAs.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.sendMultiMedia#456e8987: field send_as: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesSendMultiMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendMultiMedia#456e8987 to nil")
	}
	if  := .ConsumeID(MessagesSendMultiMediaRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesSendMultiMediaRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.sendMultiMedia#456e8987 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field flags: %w", )
		}
	}
	.Silent = .Flags.Has(5)
	.Background = .Flags.Has(6)
	.ClearDraft = .Flags.Has(7)
	.Noforwards = .Flags.Has(14)
	.UpdateStickersetsOrder = .Flags.Has(15)
	.InvertMedia = .Flags.Has(16)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field peer: %w", )
		}
		.Peer = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputReplyTo()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field reply_to: %w", )
		}
		.ReplyTo = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field multi_media: %w", )
		}

		if  > 0 {
			.MultiMedia = make([]InputSingleMedia, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  InputSingleMedia
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field multi_media: %w", )
			}
			.MultiMedia = append(.MultiMedia, )
		}
	}
	if .Flags.Has(10) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field schedule_date: %w", )
		}
		.ScheduleDate = 
	}
	if .Flags.Has(13) {
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.sendMultiMedia#456e8987: field send_as: %w", )
		}
		.SendAs = 
	}
	return nil
}

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

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

// SetBackground sets value of Background conditional field.
func ( *MessagesSendMultiMediaRequest) ( bool) {
	if  {
		.Flags.Set(6)
		.Background = true
	} else {
		.Flags.Unset(6)
		.Background = false
	}
}

// GetBackground returns value of Background conditional field.
func ( *MessagesSendMultiMediaRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// SetClearDraft sets value of ClearDraft conditional field.
func ( *MessagesSendMultiMediaRequest) ( bool) {
	if  {
		.Flags.Set(7)
		.ClearDraft = true
	} else {
		.Flags.Unset(7)
		.ClearDraft = false
	}
}

// GetClearDraft returns value of ClearDraft conditional field.
func ( *MessagesSendMultiMediaRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetNoforwards sets value of Noforwards conditional field.
func ( *MessagesSendMultiMediaRequest) ( bool) {
	if  {
		.Flags.Set(14)
		.Noforwards = true
	} else {
		.Flags.Unset(14)
		.Noforwards = false
	}
}

// GetNoforwards returns value of Noforwards conditional field.
func ( *MessagesSendMultiMediaRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(14)
}

// SetUpdateStickersetsOrder sets value of UpdateStickersetsOrder conditional field.
func ( *MessagesSendMultiMediaRequest) ( bool) {
	if  {
		.Flags.Set(15)
		.UpdateStickersetsOrder = true
	} else {
		.Flags.Unset(15)
		.UpdateStickersetsOrder = false
	}
}

// GetUpdateStickersetsOrder returns value of UpdateStickersetsOrder conditional field.
func ( *MessagesSendMultiMediaRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(15)
}

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

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

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

// SetReplyTo sets value of ReplyTo conditional field.
func ( *MessagesSendMultiMediaRequest) ( InputReplyToClass) {
	.Flags.Set(0)
	.ReplyTo = 
}

// GetReplyTo returns value of ReplyTo conditional field and
// boolean which is true if field was set.
func ( *MessagesSendMultiMediaRequest) () ( InputReplyToClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .ReplyTo, true
}

// GetMultiMedia returns value of MultiMedia field.
func ( *MessagesSendMultiMediaRequest) () ( []InputSingleMedia) {
	if  == nil {
		return
	}
	return .MultiMedia
}

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

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

// SetSendAs sets value of SendAs conditional field.
func ( *MessagesSendMultiMediaRequest) ( InputPeerClass) {
	.Flags.Set(13)
	.SendAs = 
}

// GetSendAs returns value of SendAs conditional field and
// boolean which is true if field was set.
func ( *MessagesSendMultiMediaRequest) () ( InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(13) {
		return , false
	}
	return .SendAs, true
}

// MessagesSendMultiMedia invokes method messages.sendMultiMedia#456e8987 returning error if any.
// Send an album or grouped media¹
//
// Links:
//  1. https://core.telegram.org/api/files#albums-grouped-media
//
// Possible errors:
//
//	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_FORWARDS_RESTRICTED: You can't forward messages from a protected chat.
//	403 CHAT_SEND_MEDIA_FORBIDDEN: You can't send media in this chat.
//	403 CHAT_SEND_PHOTOS_FORBIDDEN: You can't send photos in this chat.
//	403 CHAT_SEND_VIDEOS_FORBIDDEN: You can't send videos in this chat.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	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 MEDIA_CAPTION_TOO_LONG: The caption is too long.
//	400 MEDIA_EMPTY: The provided media object is invalid.
//	400 MEDIA_INVALID: Media invalid.
//	400 MULTI_MEDIA_TOO_LONG: Too many media files for album.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	500 RANDOM_ID_DUPLICATE: You provided a random ID that was already used.
//	400 RANDOM_ID_EMPTY: Random ID empty.
//	400 SCHEDULE_DATE_TOO_LATE: You can't schedule a message this far in the future.
//	400 SCHEDULE_TOO_MUCH: There are too many scheduled messages.
//	400 SEND_AS_PEER_INVALID: You can't send messages as the specified peer.
//	420 SLOWMODE_WAIT_%d: Slowmode is enabled in this chat: wait %d seconds before sending another message to this chat.
//	400 TOPIC_CLOSED: This topic was closed, you can't send messages to it anymore.
//	400 TOPIC_DELETED: The specified topic was deleted.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//
// See https://core.telegram.org/method/messages.sendMultiMedia for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesSendMultiMediaRequest) (UpdatesClass, error) {
	var  UpdatesBox

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