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

// ChatlistsExportChatlistInviteRequest represents TL type `chatlists.exportChatlistInvite#8472478e`.
// Export a folder »¹, creating a chat folder deep link »².
//
// Links:
//  1. https://core.telegram.org/api/folders
//  2. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/method/chatlists.exportChatlistInvite for reference.
type ChatlistsExportChatlistInviteRequest struct {
	// The folder to export
	Chatlist InputChatlistDialogFilter
	// An optional name for the link
	Title string
	// The list of channels, group and supergroups to share with the link. Basic groups will
	// automatically be converted to supergroups¹ when invoking the method.
	//
	// Links:
	//  1) https://core.telegram.org/api/channel#migration
	Peers []InputPeerClass
}

// ChatlistsExportChatlistInviteRequestTypeID is TL type id of ChatlistsExportChatlistInviteRequest.
const ChatlistsExportChatlistInviteRequestTypeID = 0x8472478e

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChatlistsExportChatlistInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.exportChatlistInvite#8472478e as nil")
	}
	.PutID(ChatlistsExportChatlistInviteRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// GetTitle returns value of Title field.
func ( *ChatlistsExportChatlistInviteRequest) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

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

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

// ChatlistsExportChatlistInvite invokes method chatlists.exportChatlistInvite#8472478e returning error if any.
// Export a folder »¹, creating a chat folder deep link »².
//
// Links:
//  1. https://core.telegram.org/api/folders
//  2. https://core.telegram.org/api/links#chat-folder-links
//
// Possible errors:
//
//	400 FILTER_ID_INVALID: The specified filter ID is invalid.
//	400 FILTER_NOT_SUPPORTED: The specified filter cannot be used in this context.
//	400 INVITES_TOO_MUCH: The maximum number of per-folder invites specified by the chatlist_invites_limit_default/chatlist_invites_limit_premium client configuration parameters » was reached.
//	400 PEERS_LIST_EMPTY: The specified list of peers is empty.
//
// See https://core.telegram.org/method/chatlists.exportChatlistInvite for reference.
func ( *Client) ( context.Context,  *ChatlistsExportChatlistInviteRequest) (*ChatlistsExportedChatlistInvite, error) {
	var  ChatlistsExportedChatlistInvite

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