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

// MessagesDeleteMessagesRequest represents TL type `messages.deleteMessages#e58e95d2`.
// Deletes messages by their identifiers.
//
// See https://core.telegram.org/method/messages.deleteMessages for reference.
type MessagesDeleteMessagesRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to delete messages for all participants of the chat
	Revoke bool
	// Message ID list
	ID []int
}

// MessagesDeleteMessagesRequestTypeID is TL type id of MessagesDeleteMessagesRequest.
const MessagesDeleteMessagesRequestTypeID = 0xe58e95d2

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

func ( *MessagesDeleteMessagesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Revoke == false) {
		return false
	}
	if !(.ID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesDeleteMessagesRequest from given interface.
func ( *MessagesDeleteMessagesRequest) ( interface {
	() ( bool)
	() ( []int)
}) {
	.Revoke = .()
	.ID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesDeleteMessagesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.deleteMessages",
		ID:   MessagesDeleteMessagesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Revoke",
			SchemaName: "revoke",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesDeleteMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.deleteMessages#e58e95d2 as nil")
	}
	.PutID(MessagesDeleteMessagesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesDeleteMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.deleteMessages#e58e95d2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.deleteMessages#e58e95d2: field flags: %w", )
	}
	.PutVectorHeader(len(.ID))
	for ,  := range .ID {
		.PutInt()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesDeleteMessagesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.deleteMessages#e58e95d2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.deleteMessages#e58e95d2: field flags: %w", )
		}
	}
	.Revoke = .Flags.Has(0)
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode messages.deleteMessages#e58e95d2: field id: %w", )
		}

		if  > 0 {
			.ID = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode messages.deleteMessages#e58e95d2: field id: %w", )
			}
			.ID = append(.ID, )
		}
	}
	return nil
}

// SetRevoke sets value of Revoke conditional field.
func ( *MessagesDeleteMessagesRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Revoke = true
	} else {
		.Flags.Unset(0)
		.Revoke = false
	}
}

// GetRevoke returns value of Revoke conditional field.
func ( *MessagesDeleteMessagesRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// MessagesDeleteMessages invokes method messages.deleteMessages#e58e95d2 returning error if any.
// Deletes messages by their identifiers.
//
// Possible errors:
//
//	403 MESSAGE_DELETE_FORBIDDEN: You can't delete one of the messages you tried to delete, most likely because it is a service message.
//	400 MESSAGE_ID_INVALID: The provided message id is invalid.
//
// See https://core.telegram.org/method/messages.deleteMessages for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesDeleteMessagesRequest) (*MessagesAffectedMessages, error) {
	var  MessagesAffectedMessages

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