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

// ChannelsCreateForumTopicRequest represents TL type `channels.createForumTopic#f40c0224`.
// Create a 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.createForumTopic for reference.
type ChannelsCreateForumTopicRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// The forum¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	Channel InputChannelClass
	// 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
}

// ChannelsCreateForumTopicRequestTypeID is TL type id of ChannelsCreateForumTopicRequest.
const ChannelsCreateForumTopicRequestTypeID = 0xf40c0224

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

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

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsCreateForumTopicRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.createForumTopic",
		ID:   ChannelsCreateForumTopicRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			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 ( *ChannelsCreateForumTopicRequest) () {
	if !(.IconColor == 0) {
		.Flags.Set(0)
	}
	if !(.IconEmojiID == 0) {
		.Flags.Set(3)
	}
	if !(.SendAs == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsCreateForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.createForumTopic#f40c0224 as nil")
	}
	.PutID(ChannelsCreateForumTopicRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsCreateForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.createForumTopic#f40c0224 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field channel: %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 channels.createForumTopic#f40c0224: field send_as is nil")
		}
		if  := .SendAs.Encode();  != nil {
			return fmt.Errorf("unable to encode channels.createForumTopic#f40c0224: field send_as: %w", )
		}
	}
	return nil
}

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

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

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

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

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

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

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

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

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

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

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

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

// ChannelsCreateForumTopic invokes method channels.createForumTopic#f40c0224 returning error if any.
// Create a 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.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//	403 PREMIUM_ACCOUNT_REQUIRED: A premium account is required to execute this action.
//	400 TOPIC_TITLE_EMPTY: The specified topic title is empty.
//
// See https://core.telegram.org/method/channels.createForumTopic for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsCreateForumTopicRequest) (UpdatesClass, error) {
	var  UpdatesBox

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