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

// MessagesCreateForumTopicRequest represents TL type `messages.createForumTopic#2f98c3d5`.
// Create a forum topic¹.
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/messages.createForumTopic for reference.
type MessagesCreateForumTopicRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// TitleMissing field of MessagesCreateForumTopicRequest.
	TitleMissing bool
	// The supergroup, private chat (for forum-enabled bots) or forum bot (for users) where
	// to create the topic.
	Peer InputPeerClass
	// Topic title (maximum UTF-8 length: 128)
	Title string
	// If no custom emoji icon is specified, specifies the color of the fallback topic icon
	// (RGB), one of 0x6FB9F0, 0xFFD67E, 0xCB86DB, 0x8EEE98, 0xFF93B2, or 0xFB6F5F.
	//
	// Use SetIconColor and GetIconColor helpers.
	IconColor int
	// ID of 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.
	//
	// 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
	// Unique client message ID to prevent duplicate sending of the same event
	RandomID int64
	// Create the topic as the specified peer
	//
	// Use SetSendAs and GetSendAs helpers.
	SendAs InputPeerClass
}

// MessagesCreateForumTopicRequestTypeID is TL type id of MessagesCreateForumTopicRequest.
const MessagesCreateForumTopicRequestTypeID = 0x2f98c3d5

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

func ( *MessagesCreateForumTopicRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.TitleMissing == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.IconColor == 0) {
		return false
	}
	if !(.IconEmojiID == 0) {
		return false
	}
	if !(.RandomID == 0) {
		return false
	}
	if !(.SendAs == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesCreateForumTopicRequest from given interface.
func ( *MessagesCreateForumTopicRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
	() ( string)
	() ( int,  bool)
	() ( int64,  bool)
	() ( int64)
	() ( InputPeerClass,  bool)
}) {
	.TitleMissing = .()
	.Peer = .()
	.Title = .()
	if ,  := .();  {
		.IconColor = 
	}

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

	.RandomID = .()
	if ,  := .();  {
		.SendAs = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesCreateForumTopicRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.createForumTopic",
		ID:   MessagesCreateForumTopicRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "TitleMissing",
			SchemaName: "title_missing",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "IconColor",
			SchemaName: "icon_color",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "IconEmojiID",
			SchemaName: "icon_emoji_id",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "RandomID",
			SchemaName: "random_id",
		},
		{
			Name:       "SendAs",
			SchemaName: "send_as",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *MessagesCreateForumTopicRequest) () {
	if !(.TitleMissing == false) {
		.Flags.Set(4)
	}
	if !(.IconColor == 0) {
		.Flags.Set(0)
	}
	if !(.IconEmojiID == 0) {
		.Flags.Set(3)
	}
	if !(.SendAs == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesCreateForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.createForumTopic#2f98c3d5 as nil")
	}
	.PutID(MessagesCreateForumTopicRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesCreateForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.createForumTopic#2f98c3d5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.createForumTopic#2f98c3d5: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.createForumTopic#2f98c3d5: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.createForumTopic#2f98c3d5: field peer: %w", )
	}
	.PutString(.Title)
	if .Flags.Has(0) {
		.PutInt(.IconColor)
	}
	if .Flags.Has(3) {
		.PutLong(.IconEmojiID)
	}
	.PutLong(.RandomID)
	if .Flags.Has(2) {
		if .SendAs == nil {
			return fmt.Errorf("unable to encode messages.createForumTopic#2f98c3d5: field send_as is nil")
		}
		if  := .SendAs.Encode();  != nil {
			return fmt.Errorf("unable to encode messages.createForumTopic#2f98c3d5: field send_as: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesCreateForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.createForumTopic#2f98c3d5 to nil")
	}
	if  := .ConsumeID(MessagesCreateForumTopicRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesCreateForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.createForumTopic#2f98c3d5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field flags: %w", )
		}
	}
	.TitleMissing = .Flags.Has(4)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field icon_color: %w", )
		}
		.IconColor = 
	}
	if .Flags.Has(3) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field icon_emoji_id: %w", )
		}
		.IconEmojiID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field random_id: %w", )
		}
		.RandomID = 
	}
	if .Flags.Has(2) {
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.createForumTopic#2f98c3d5: field send_as: %w", )
		}
		.SendAs = 
	}
	return nil
}

// SetTitleMissing sets value of TitleMissing conditional field.
func ( *MessagesCreateForumTopicRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.TitleMissing = true
	} else {
		.Flags.Unset(4)
		.TitleMissing = false
	}
}

// GetTitleMissing returns value of TitleMissing conditional field.
func ( *MessagesCreateForumTopicRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

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

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

// SetIconColor sets value of IconColor conditional field.
func ( *MessagesCreateForumTopicRequest) ( int) {
	.Flags.Set(0)
	.IconColor = 
}

// GetIconColor returns value of IconColor conditional field and
// boolean which is true if field was set.
func ( *MessagesCreateForumTopicRequest) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .IconColor, true
}

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

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

// GetRandomID returns value of RandomID field.
func ( *MessagesCreateForumTopicRequest) () ( int64) {
	if  == nil {
		return
	}
	return .RandomID
}

// SetSendAs sets value of SendAs conditional field.
func ( *MessagesCreateForumTopicRequest) ( InputPeerClass) {
	.Flags.Set(2)
	.SendAs = 
}

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

// MessagesCreateForumTopic invokes method messages.createForumTopic#2f98c3d5 returning error if any.
// Create a forum topic¹.
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// Possible errors:
//
//	400 CHANNEL_FORUM_MISSING: This supergroup is not a forum.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.createForumTopic for reference.
func ( *Client) ( context.Context,  *MessagesCreateForumTopicRequest) (UpdatesClass, error) {
	var  UpdatesBox

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