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

// ChatlistsJoinChatlistUpdatesRequest represents TL type `chatlists.joinChatlistUpdates#e089f8f5`.
// Join channels and supergroups recently added to a chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/method/chatlists.joinChatlistUpdates for reference.
type ChatlistsJoinChatlistUpdatesRequest struct {
	// The folder
	Chatlist InputChatlistDialogFilter
	// List of new chats to join, fetched using chatlists.getChatlistUpdates¹ and filtered
	// as specified in the documentation »².
	//
	// Links:
	//  1) https://core.telegram.org/method/chatlists.getChatlistUpdates
	//  2) https://core.telegram.org/api/folders#shared-folders
	Peers []InputPeerClass
}

// ChatlistsJoinChatlistUpdatesRequestTypeID is TL type id of ChatlistsJoinChatlistUpdatesRequest.
const ChatlistsJoinChatlistUpdatesRequestTypeID = 0xe089f8f5

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

func ( *ChatlistsJoinChatlistUpdatesRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Chatlist.Zero()) {
		return false
	}
	if !(.Peers == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChatlistsJoinChatlistUpdatesRequest from given interface.
func ( *ChatlistsJoinChatlistUpdatesRequest) ( interface {
	() ( InputChatlistDialogFilter)
	() ( []InputPeerClass)
}) {
	.Chatlist = .()
	.Peers = .()
}

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

// TypeName returns name of type in TL schema.
func (*ChatlistsJoinChatlistUpdatesRequest) () string {
	return "chatlists.joinChatlistUpdates"
}

// TypeInfo returns info about TL type.
func ( *ChatlistsJoinChatlistUpdatesRequest) () tdp.Type {
	 := tdp.Type{
		Name: "chatlists.joinChatlistUpdates",
		ID:   ChatlistsJoinChatlistUpdatesRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Chatlist",
			SchemaName: "chatlist",
		},
		{
			Name:       "Peers",
			SchemaName: "peers",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChatlistsJoinChatlistUpdatesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.joinChatlistUpdates#e089f8f5 as nil")
	}
	.PutID(ChatlistsJoinChatlistUpdatesRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatlistsJoinChatlistUpdatesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.joinChatlistUpdates#e089f8f5 as nil")
	}
	if  := .Chatlist.Encode();  != nil {
		return fmt.Errorf("unable to encode chatlists.joinChatlistUpdates#e089f8f5: field chatlist: %w", )
	}
	.PutVectorHeader(len(.Peers))
	for ,  := range .Peers {
		if  == nil {
			return fmt.Errorf("unable to encode chatlists.joinChatlistUpdates#e089f8f5: field peers element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode chatlists.joinChatlistUpdates#e089f8f5: field peers element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *ChatlistsJoinChatlistUpdatesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatlists.joinChatlistUpdates#e089f8f5 to nil")
	}
	if  := .ConsumeID(ChatlistsJoinChatlistUpdatesRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode chatlists.joinChatlistUpdates#e089f8f5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChatlistsJoinChatlistUpdatesRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatlists.joinChatlistUpdates#e089f8f5 to nil")
	}
	{
		if  := .Chatlist.Decode();  != nil {
			return fmt.Errorf("unable to decode chatlists.joinChatlistUpdates#e089f8f5: field chatlist: %w", )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode chatlists.joinChatlistUpdates#e089f8f5: field peers: %w", )
		}

		if  > 0 {
			.Peers = make([]InputPeerClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeInputPeer()
			if  != nil {
				return fmt.Errorf("unable to decode chatlists.joinChatlistUpdates#e089f8f5: field peers: %w", )
			}
			.Peers = append(.Peers, )
		}
	}
	return nil
}

// GetChatlist returns value of Chatlist field.
func ( *ChatlistsJoinChatlistUpdatesRequest) () ( InputChatlistDialogFilter) {
	if  == nil {
		return
	}
	return .Chatlist
}

// GetPeers returns value of Peers field.
func ( *ChatlistsJoinChatlistUpdatesRequest) () ( []InputPeerClass) {
	if  == nil {
		return
	}
	return .Peers
}

// MapPeers returns field Peers wrapped in InputPeerClassArray helper.
func ( *ChatlistsJoinChatlistUpdatesRequest) () ( InputPeerClassArray) {
	return InputPeerClassArray(.Peers)
}

// ChatlistsJoinChatlistUpdates invokes method chatlists.joinChatlistUpdates#e089f8f5 returning error if any.
// Join channels and supergroups recently added to a chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/method/chatlists.joinChatlistUpdates for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChatlistsJoinChatlistUpdatesRequest) (UpdatesClass, error) {
	var  UpdatesBox

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