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

// ChannelsInviteToChannelRequest represents TL type `channels.inviteToChannel#199f3a6c`.
// Invite users to a channel/supergroup
// 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/channels.inviteToChannel for reference.
type ChannelsInviteToChannelRequest struct {
	// Channel/supergroup
	Channel InputChannelClass
	// Users to invite
	Users []InputUserClass
}

// ChannelsInviteToChannelRequestTypeID is TL type id of ChannelsInviteToChannelRequest.
const ChannelsInviteToChannelRequestTypeID = 0x199f3a6c

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

func ( *ChannelsInviteToChannelRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsInviteToChannelRequest from given interface.
func ( *ChannelsInviteToChannelRequest) ( interface {
	() ( InputChannelClass)
	() ( []InputUserClass)
}) {
	.Channel = .()
	.Users = .()
}

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

// TypeName returns name of type in TL schema.
func (*ChannelsInviteToChannelRequest) () string {
	return "channels.inviteToChannel"
}

// TypeInfo returns info about TL type.
func ( *ChannelsInviteToChannelRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.inviteToChannel",
		ID:   ChannelsInviteToChannelRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsInviteToChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.inviteToChannel#199f3a6c as nil")
	}
	.PutID(ChannelsInviteToChannelRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsInviteToChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.inviteToChannel#199f3a6c as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.inviteToChannel#199f3a6c: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.inviteToChannel#199f3a6c: field channel: %w", )
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode channels.inviteToChannel#199f3a6c: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode channels.inviteToChannel#199f3a6c: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsInviteToChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.inviteToChannel#199f3a6c to nil")
	}
	if  := .ConsumeID(ChannelsInviteToChannelRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.inviteToChannel#199f3a6c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsInviteToChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.inviteToChannel#199f3a6c to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.inviteToChannel#199f3a6c: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.inviteToChannel#199f3a6c: field users: %w", )
		}

		if  > 0 {
			.Users = make([]InputUserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputUser()
			if  != nil {
				return fmt.Errorf("unable to decode channels.inviteToChannel#199f3a6c: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetChannel returns value of Channel field.
func ( *ChannelsInviteToChannelRequest) () ( InputChannelClass) {
	if  == nil {
		return
	}
	return .Channel
}

// GetUsers returns value of Users field.
func ( *ChannelsInviteToChannelRequest) () ( []InputUserClass) {
	if  == nil {
		return
	}
	return .Users
}

// GetChannelAsNotEmpty returns mapped value of Channel field.
func ( *ChannelsInviteToChannelRequest) () (NotEmptyInputChannel, bool) {
	return .Channel.AsNotEmpty()
}

// MapUsers returns field Users wrapped in InputUserClassArray helper.
func ( *ChannelsInviteToChannelRequest) () ( InputUserClassArray) {
	return InputUserClassArray(.Users)
}

// ChannelsInviteToChannel invokes method channels.inviteToChannel#199f3a6c returning error if any.
// Invite users to a channel/supergroup
// 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 BOTS_TOO_MUCH: There are too many bots in this chat/channel.
//	400 BOT_GROUPS_BLOCKED: This bot can't be added to groups.
//	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_INVALID: Invalid chat.
//	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 USERS_TOO_MUCH: The maximum number of users has been exceeded (to create a chat, for example).
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//	400 USER_BLOCKED: User blocked.
//	400 USER_BOT: Bots can only be admins in channels.
//	403 USER_CHANNELS_TOO_MUCH: One of the users you tried to add is already in too many channels/supergroups.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//	400 USER_KICKED: This user was kicked from this supergroup/channel.
//	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.
//
// See https://core.telegram.org/method/channels.inviteToChannel for reference.
func ( *Client) ( context.Context,  *ChannelsInviteToChannelRequest) (UpdatesClass, error) {
	var  UpdatesBox

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