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

// MessagesEditForumTopicRequest represents TL type `messages.editForumTopic#cecc1134`.
// Edit forum topic¹.
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/messages.editForumTopic for reference.
type MessagesEditForumTopicRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The supergroup forum, private chat (for forum-enabled bots) or bot forum (for users)
	// where the topic is located.
	Peer InputPeerClass
	// 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
}

// MessagesEditForumTopicRequestTypeID is TL type id of MessagesEditForumTopicRequest.
const MessagesEditForumTopicRequestTypeID = 0xcecc1134

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

func ( *MessagesEditForumTopicRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Peer == 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 ( *MessagesEditForumTopicRequest) () string {
	if  == nil {
		return "MessagesEditForumTopicRequest(nil)"
	}
	type  MessagesEditForumTopicRequest
	return fmt.Sprintf("MessagesEditForumTopicRequest%+v", (*))
}

// FillFrom fills MessagesEditForumTopicRequest from given interface.
func ( *MessagesEditForumTopicRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( string,  bool)
	() ( int64,  bool)
	() ( bool,  bool)
	() ( bool,  bool)
}) {
	.Peer = .()
	.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 (*MessagesEditForumTopicRequest) () uint32 {
	return MessagesEditForumTopicRequestTypeID
}

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

// TypeInfo returns info about TL type.
func ( *MessagesEditForumTopicRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.editForumTopic",
		ID:   MessagesEditForumTopicRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			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 ( *MessagesEditForumTopicRequest) () {
	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 ( *MessagesEditForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editForumTopic#cecc1134 as nil")
	}
	.PutID(MessagesEditForumTopicRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesEditForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editForumTopic#cecc1134 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editForumTopic#cecc1134: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.editForumTopic#cecc1134: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editForumTopic#cecc1134: field peer: %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 ( *MessagesEditForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.editForumTopic#cecc1134 to nil")
	}
	if  := .ConsumeID(MessagesEditForumTopicRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.editForumTopic#cecc1134: %w", )
	}
	return .DecodeBare()
}

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

// GetPeer returns value of Peer field.
func ( *MessagesEditForumTopicRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

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

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

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

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

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

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

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

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

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

// MessagesEditForumTopic invokes method messages.editForumTopic#cecc1134 returning error if any.
// Edit forum topic¹.
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/messages.editForumTopic for reference.
func ( *Client) ( context.Context,  *MessagesEditForumTopicRequest) (UpdatesClass, error) {
	var  UpdatesBox

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