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

// MessagesAddChatUserRequest represents TL type `messages.addChatUser#f24753e3`.
// Adds a user to a chat and sends a service message on it.
// May also return 0-N updates of type updateGroupInvitePrivacyForbidden¹: it indicates
// we couldn't add a user to a chat because of their privacy settings; if required, an
// invite link² can be shared with the user, instead.
//
// Links:
//  1. https://core.telegram.org/constructor/updateGroupInvitePrivacyForbidden
//  2. https://core.telegram.org/api/invites
//
// See https://core.telegram.org/method/messages.addChatUser for reference.
type MessagesAddChatUserRequest struct {
	// Chat ID
	ChatID int64
	// User ID to be added
	UserID InputUserClass
	// Number of last messages to be forwarded
	FwdLimit int
}

// MessagesAddChatUserRequestTypeID is TL type id of MessagesAddChatUserRequest.
const MessagesAddChatUserRequestTypeID = 0xf24753e3

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

func ( *MessagesAddChatUserRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ChatID == 0) {
		return false
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.FwdLimit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesAddChatUserRequest from given interface.
func ( *MessagesAddChatUserRequest) ( interface {
	() ( int64)
	() ( InputUserClass)
	() ( int)
}) {
	.ChatID = .()
	.UserID = .()
	.FwdLimit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesAddChatUserRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.addChatUser",
		ID:   MessagesAddChatUserRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "FwdLimit",
			SchemaName: "fwd_limit",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesAddChatUserRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.addChatUser#f24753e3 as nil")
	}
	.PutID(MessagesAddChatUserRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesAddChatUserRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.addChatUser#f24753e3 as nil")
	}
	.PutLong(.ChatID)
	if .UserID == nil {
		return fmt.Errorf("unable to encode messages.addChatUser#f24753e3: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.addChatUser#f24753e3: field user_id: %w", )
	}
	.PutInt(.FwdLimit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesAddChatUserRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.addChatUser#f24753e3 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.addChatUser#f24753e3: field chat_id: %w", )
		}
		.ChatID = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.addChatUser#f24753e3: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.addChatUser#f24753e3: field fwd_limit: %w", )
		}
		.FwdLimit = 
	}
	return nil
}

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

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

// GetFwdLimit returns value of FwdLimit field.
func ( *MessagesAddChatUserRequest) () ( int) {
	if  == nil {
		return
	}
	return .FwdLimit
}

// MessagesAddChatUser invokes method messages.addChatUser#f24753e3 returning error if any.
// Adds a user to a chat and sends a service message on it.
// May also return 0-N updates of type updateGroupInvitePrivacyForbidden¹: it indicates
// we couldn't add a user to a chat because of their privacy settings; if required, an
// invite link² can be shared with the user, instead.
//
// Links:
//  1. https://core.telegram.org/constructor/updateGroupInvitePrivacyForbidden
//  2. https://core.telegram.org/api/invites
//
// Possible errors:
//
//	400 BOT_GROUPS_BLOCKED: This bot can't be added to groups.
//	403 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	400 INPUT_USER_DEACTIVATED: The specified user was deleted.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USERS_TOO_MUCH: The maximum number of users has been exceeded (to create a chat, for example).
//	400 USER_ALREADY_PARTICIPANT: The user is already in the group.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//	400 USER_IS_BLOCKED: You were blocked by this user.
//	403 USER_NOT_MUTUAL_CONTACT: The provided user is not a mutual contact.
//	403 USER_PRIVACY_RESTRICTED: The user's privacy settings do not allow you to do this.
//	400 YOU_BLOCKED_USER: You blocked this user.
//
// See https://core.telegram.org/method/messages.addChatUser for reference.
func ( *Client) ( context.Context,  *MessagesAddChatUserRequest) (UpdatesClass, error) {
	var  UpdatesBox

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