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

// ChatlistsEditExportedInviteRequest represents TL type `chatlists.editExportedInvite#653db63d`.
// Edit a chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// See https://core.telegram.org/method/chatlists.editExportedInvite for reference.
type ChatlistsEditExportedInviteRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Folder ID
	Chatlist InputChatlistDialogFilter
	// slug obtained from the chat folder deep link »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#chat-folder-links
	Slug string
	// If set, sets a new name for the link
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// If set, changes the list of peers shared with the link
	//
	// Use SetPeers and GetPeers helpers.
	Peers []InputPeerClass
}

// ChatlistsEditExportedInviteRequestTypeID is TL type id of ChatlistsEditExportedInviteRequest.
const ChatlistsEditExportedInviteRequestTypeID = 0x653db63d

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

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

	return true
}

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

// FillFrom fills ChatlistsEditExportedInviteRequest from given interface.
func ( *ChatlistsEditExportedInviteRequest) ( interface {
	() ( InputChatlistDialogFilter)
	() ( string)
	() ( string,  bool)
	() ( []InputPeerClass,  bool)
}) {
	.Chatlist = .()
	.Slug = .()
	if ,  := .();  {
		.Title = 
	}

	if ,  := .();  {
		.Peers = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *ChatlistsEditExportedInviteRequest) () tdp.Type {
	 := tdp.Type{
		Name: "chatlists.editExportedInvite",
		ID:   ChatlistsEditExportedInviteRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Chatlist",
			SchemaName: "chatlist",
		},
		{
			Name:       "Slug",
			SchemaName: "slug",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Peers",
			SchemaName: "peers",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChatlistsEditExportedInviteRequest) () {
	if !(.Title == "") {
		.Flags.Set(1)
	}
	if !(.Peers == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *ChatlistsEditExportedInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.editExportedInvite#653db63d as nil")
	}
	.PutID(ChatlistsEditExportedInviteRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChatlistsEditExportedInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode chatlists.editExportedInvite#653db63d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode chatlists.editExportedInvite#653db63d: field flags: %w", )
	}
	if  := .Chatlist.Encode();  != nil {
		return fmt.Errorf("unable to encode chatlists.editExportedInvite#653db63d: field chatlist: %w", )
	}
	.PutString(.Slug)
	if .Flags.Has(1) {
		.PutString(.Title)
	}
	if .Flags.Has(2) {
		.PutVectorHeader(len(.Peers))
		for ,  := range .Peers {
			if  == nil {
				return fmt.Errorf("unable to encode chatlists.editExportedInvite#653db63d: field peers element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode chatlists.editExportedInvite#653db63d: field peers element with index %d: %w", , )
			}
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChatlistsEditExportedInviteRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode chatlists.editExportedInvite#653db63d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode chatlists.editExportedInvite#653db63d: field flags: %w", )
		}
	}
	{
		if  := .Chatlist.Decode();  != nil {
			return fmt.Errorf("unable to decode chatlists.editExportedInvite#653db63d: field chatlist: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode chatlists.editExportedInvite#653db63d: field slug: %w", )
		}
		.Slug = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode chatlists.editExportedInvite#653db63d: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(2) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode chatlists.editExportedInvite#653db63d: field peers: %w", )
		}

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

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

// GetSlug returns value of Slug field.
func ( *ChatlistsEditExportedInviteRequest) () ( string) {
	if  == nil {
		return
	}
	return .Slug
}

// SetTitle sets value of Title conditional field.
func ( *ChatlistsEditExportedInviteRequest) ( string) {
	.Flags.Set(1)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *ChatlistsEditExportedInviteRequest) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Title, true
}

// SetPeers sets value of Peers conditional field.
func ( *ChatlistsEditExportedInviteRequest) ( []InputPeerClass) {
	.Flags.Set(2)
	.Peers = 
}

// GetPeers returns value of Peers conditional field and
// boolean which is true if field was set.
func ( *ChatlistsEditExportedInviteRequest) () ( []InputPeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Peers, true
}

// MapPeers returns field Peers wrapped in InputPeerClassArray helper.
func ( *ChatlistsEditExportedInviteRequest) () ( InputPeerClassArray,  bool) {
	if !.Flags.Has(2) {
		return , false
	}
	return InputPeerClassArray(.Peers), true
}

// ChatlistsEditExportedInvite invokes method chatlists.editExportedInvite#653db63d returning error if any.
// Edit a chat folder deep link »¹.
//
// Links:
//  1. https://core.telegram.org/api/links#chat-folder-links
//
// Possible errors:
//
//	400 FILTER_ID_INVALID: The specified filter ID is invalid.
//
// See https://core.telegram.org/method/chatlists.editExportedInvite for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChatlistsEditExportedInviteRequest) (*ExportedChatlistInvite, error) {
	var  ExportedChatlistInvite

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