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

// ChannelsGetForumTopicsByIDRequest represents TL type `channels.getForumTopicsByID#b0831eb9`.
// Get forum topics by their ID
//
// See https://core.telegram.org/method/channels.getForumTopicsByID for reference.
type ChannelsGetForumTopicsByIDRequest struct {
	// Forum
	Channel InputChannelClass
	// Topic IDs
	Topics []int
}

// ChannelsGetForumTopicsByIDRequestTypeID is TL type id of ChannelsGetForumTopicsByIDRequest.
const ChannelsGetForumTopicsByIDRequestTypeID = 0xb0831eb9

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

func ( *ChannelsGetForumTopicsByIDRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Topics == nil) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsGetForumTopicsByIDRequest from given interface.
func ( *ChannelsGetForumTopicsByIDRequest) ( interface {
	() ( InputChannelClass)
	() ( []int)
}) {
	.Channel = .()
	.Topics = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsGetForumTopicsByIDRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.getForumTopicsByID",
		ID:   ChannelsGetForumTopicsByIDRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Topics",
			SchemaName: "topics",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsGetForumTopicsByIDRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getForumTopicsByID#b0831eb9 as nil")
	}
	.PutID(ChannelsGetForumTopicsByIDRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsGetForumTopicsByIDRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getForumTopicsByID#b0831eb9 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.getForumTopicsByID#b0831eb9: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getForumTopicsByID#b0831eb9: field channel: %w", )
	}
	.PutVectorHeader(len(.Topics))
	for ,  := range .Topics {
		.PutInt()
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetForumTopicsByIDRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getForumTopicsByID#b0831eb9 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopicsByID#b0831eb9: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopicsByID#b0831eb9: field topics: %w", )
		}

		if  > 0 {
			.Topics = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode channels.getForumTopicsByID#b0831eb9: field topics: %w", )
			}
			.Topics = append(.Topics, )
		}
	}
	return nil
}

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

// GetTopics returns value of Topics field.
func ( *ChannelsGetForumTopicsByIDRequest) () ( []int) {
	if  == nil {
		return
	}
	return .Topics
}

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

// ChannelsGetForumTopicsByID invokes method channels.getForumTopicsByID#b0831eb9 returning error if any.
// Get forum topics by their ID
//
// Possible errors:
//
//	400 CHANNEL_FORUM_MISSING: This supergroup is not a forum.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 TOPICS_EMPTY: You specified no topic IDs.
//
// See https://core.telegram.org/method/channels.getForumTopicsByID for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsGetForumTopicsByIDRequest) (*MessagesForumTopics, error) {
	var  MessagesForumTopics

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