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

// MessagesDeleteChatUserRequest represents TL type `messages.deleteChatUser#a2185cab`.
// Deletes a user from a chat and sends a service message on it.
//
// See https://core.telegram.org/method/messages.deleteChatUser for reference.
type MessagesDeleteChatUserRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Remove the entire chat history of the specified user in this chat.
	RevokeHistory bool
	// Chat ID
	ChatID int64
	// User ID to be deleted
	UserID InputUserClass
}

// MessagesDeleteChatUserRequestTypeID is TL type id of MessagesDeleteChatUserRequest.
const MessagesDeleteChatUserRequestTypeID = 0xa2185cab

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

func ( *MessagesDeleteChatUserRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.RevokeHistory == false) {
		return false
	}
	if !(.ChatID == 0) {
		return false
	}
	if !(.UserID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesDeleteChatUserRequest from given interface.
func ( *MessagesDeleteChatUserRequest) ( interface {
	() ( bool)
	() ( int64)
	() ( InputUserClass)
}) {
	.RevokeHistory = .()
	.ChatID = .()
	.UserID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesDeleteChatUserRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.deleteChatUser",
		ID:   MessagesDeleteChatUserRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "RevokeHistory",
			SchemaName: "revoke_history",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesDeleteChatUserRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.deleteChatUser#a2185cab as nil")
	}
	.PutID(MessagesDeleteChatUserRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesDeleteChatUserRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.deleteChatUser#a2185cab as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.deleteChatUser#a2185cab: field flags: %w", )
	}
	.PutLong(.ChatID)
	if .UserID == nil {
		return fmt.Errorf("unable to encode messages.deleteChatUser#a2185cab: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.deleteChatUser#a2185cab: field user_id: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesDeleteChatUserRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.deleteChatUser#a2185cab to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: field flags: %w", )
		}
	}
	.RevokeHistory = .Flags.Has(0)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: field chat_id: %w", )
		}
		.ChatID = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.deleteChatUser#a2185cab: field user_id: %w", )
		}
		.UserID = 
	}
	return nil
}

// SetRevokeHistory sets value of RevokeHistory conditional field.
func ( *MessagesDeleteChatUserRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.RevokeHistory = true
	} else {
		.Flags.Unset(0)
		.RevokeHistory = false
	}
}

// GetRevokeHistory returns value of RevokeHistory conditional field.
func ( *MessagesDeleteChatUserRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetChatID returns value of ChatID field.
func ( *MessagesDeleteChatUserRequest) () ( int64) {
	if  == nil {
		return
	}
	return .ChatID
}

// GetUserID returns value of UserID field.
func ( *MessagesDeleteChatUserRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// MessagesDeleteChatUser invokes method messages.deleteChatUser#a2185cab returning error if any.
// Deletes a user from a chat and sends a service message on it.
//
// Possible errors:
//
//	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 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//	400 USER_NOT_PARTICIPANT: You're not a member of this supergroup/channel.
//
// See https://core.telegram.org/method/messages.deleteChatUser for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesDeleteChatUserRequest) (UpdatesClass, error) {
	var  UpdatesBox

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