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

// ChannelsEditForumTopicRequest represents TL type `channels.editForumTopic#f4dfa185`.
// Edit forum topic¹; requires manage_topics rights².
//
// Links:
//  1. https://core.telegram.org/api/forum
//  2. https://core.telegram.org/api/rights
//
// See https://core.telegram.org/method/channels.editForumTopic for reference.
type ChannelsEditForumTopicRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Supergroup
	Channel InputChannelClass
	// Topic ID
	TopicID int
	// If present, will update the topic title (maximum UTF-8 length: 128).
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// If present, updates the custom emoji¹ used as topic icon. Telegram Premium² users
	// can use any custom emoji, other users can only use the custom emojis contained in the
	// inputStickerSetEmojiDefaultTopicIcons³ emoji pack. Pass 0 to switch to the fallback
	// topic icon.
	//
	// Links:
	//  1) https://core.telegram.org/api/custom-emoji
	//  2) https://core.telegram.org/api/premium
	//  3) https://core.telegram.org/constructor/inputStickerSetEmojiDefaultTopicIcons
	//
	// Use SetIconEmojiID and GetIconEmojiID helpers.
	IconEmojiID int64
	// If present, will update the open/closed status of the topic.
	//
	// Use SetClosed and GetClosed helpers.
	Closed bool
	// If present, will hide/unhide the topic (only valid for the "General" topic, id=1).
	//
	// Use SetHidden and GetHidden helpers.
	Hidden bool
}

// ChannelsEditForumTopicRequestTypeID is TL type id of ChannelsEditForumTopicRequest.
const ChannelsEditForumTopicRequestTypeID = 0xf4dfa185

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

func ( *ChannelsEditForumTopicRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.TopicID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.IconEmojiID == 0) {
		return false
	}
	if !(.Closed == false) {
		return false
	}
	if !(.Hidden == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsEditForumTopicRequest from given interface.
func ( *ChannelsEditForumTopicRequest) ( interface {
	() ( InputChannelClass)
	() ( int)
	() ( string,  bool)
	() ( int64,  bool)
	() ( bool,  bool)
	() ( bool,  bool)
}) {
	.Channel = .()
	.TopicID = .()
	if ,  := .();  {
		.Title = 
	}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsEditForumTopicRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.editForumTopic",
		ID:   ChannelsEditForumTopicRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "TopicID",
			SchemaName: "topic_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "IconEmojiID",
			SchemaName: "icon_emoji_id",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Closed",
			SchemaName: "closed",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Hidden",
			SchemaName: "hidden",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsEditForumTopicRequest) () {
	if !(.Title == "") {
		.Flags.Set(0)
	}
	if !(.IconEmojiID == 0) {
		.Flags.Set(1)
	}
	if !(.Closed == false) {
		.Flags.Set(2)
	}
	if !(.Hidden == false) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsEditForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.editForumTopic#f4dfa185 as nil")
	}
	.PutID(ChannelsEditForumTopicRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsEditForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.editForumTopic#f4dfa185 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.editForumTopic#f4dfa185: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.editForumTopic#f4dfa185: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.editForumTopic#f4dfa185: field channel: %w", )
	}
	.PutInt(.TopicID)
	if .Flags.Has(0) {
		.PutString(.Title)
	}
	if .Flags.Has(1) {
		.PutLong(.IconEmojiID)
	}
	if .Flags.Has(2) {
		.PutBool(.Closed)
	}
	if .Flags.Has(3) {
		.PutBool(.Hidden)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsEditForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.editForumTopic#f4dfa185 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field flags: %w", )
		}
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field topic_id: %w", )
		}
		.TopicID = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(1) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field icon_emoji_id: %w", )
		}
		.IconEmojiID = 
	}
	if .Flags.Has(2) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field closed: %w", )
		}
		.Closed = 
	}
	if .Flags.Has(3) {
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editForumTopic#f4dfa185: field hidden: %w", )
		}
		.Hidden = 
	}
	return nil
}

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

// GetTopicID returns value of TopicID field.
func ( *ChannelsEditForumTopicRequest) () ( int) {
	if  == nil {
		return
	}
	return .TopicID
}

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

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

// SetIconEmojiID sets value of IconEmojiID conditional field.
func ( *ChannelsEditForumTopicRequest) ( int64) {
	.Flags.Set(1)
	.IconEmojiID = 
}

// GetIconEmojiID returns value of IconEmojiID conditional field and
// boolean which is true if field was set.
func ( *ChannelsEditForumTopicRequest) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .IconEmojiID, true
}

// SetClosed sets value of Closed conditional field.
func ( *ChannelsEditForumTopicRequest) ( bool) {
	.Flags.Set(2)
	.Closed = 
}

// GetClosed returns value of Closed conditional field and
// boolean which is true if field was set.
func ( *ChannelsEditForumTopicRequest) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Closed, true
}

// SetHidden sets value of Hidden conditional field.
func ( *ChannelsEditForumTopicRequest) ( bool) {
	.Flags.Set(3)
	.Hidden = 
}

// GetHidden returns value of Hidden conditional field and
// boolean which is true if field was set.
func ( *ChannelsEditForumTopicRequest) () ( bool,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Hidden, true
}

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

// ChannelsEditForumTopic invokes method channels.editForumTopic#f4dfa185 returning error if any.
// Edit forum topic¹; requires manage_topics rights².
//
// Links:
//  1. https://core.telegram.org/api/forum
//  2. https://core.telegram.org/api/rights
//
// Possible errors:
//
//	400 CHANNEL_FORUM_MISSING: This supergroup is not a forum.
//	403 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 DOCUMENT_INVALID: The specified document is invalid.
//	400 GENERAL_MODIFY_ICON_FORBIDDEN: You can't modify the icon of the "General" topic.
//	400 TOPIC_CLOSE_SEPARATELY: The close flag cannot be provided together with any of the other flags.
//	400 TOPIC_HIDE_SEPARATELY: The hide flag cannot be provided together with any of the other flags.
//	400 TOPIC_ID_INVALID: The specified topic ID is invalid.
//	400 TOPIC_NOT_MODIFIED: The updated topic info is equal to the current topic info, nothing was changed.
//
// See https://core.telegram.org/method/channels.editForumTopic for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsEditForumTopicRequest) (UpdatesClass, error) {
	var  UpdatesBox

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