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

// ChannelsGetForumTopicsRequest represents TL type `channels.getForumTopics#de560d1`.
// Get topics of a forum¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/channels.getForumTopics for reference.
type ChannelsGetForumTopicsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Supergroup
	Channel InputChannelClass
	// Search query
	//
	// Use SetQ and GetQ helpers.
	Q string
	// Offsets for pagination, for more info click here¹, date of the last message of the
	// last found topic. Use 0 or any date in the future to get results from the last topic.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetDate int
	// Offsets for pagination, for more info click here¹, ID of the last message of the last
	// found topic (or initially 0).
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetID int
	// Offsets for pagination, for more info click here¹, ID of the last found topic (or
	// initially 0).
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	OffsetTopic int
	// Maximum number of results to return, see pagination¹. For optimal performance, the
	// number of returned topics is chosen by the server and can be smaller than the
	// specified limit.
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets
	Limit int
}

// ChannelsGetForumTopicsRequestTypeID is TL type id of ChannelsGetForumTopicsRequest.
const ChannelsGetForumTopicsRequestTypeID = 0xde560d1

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

func ( *ChannelsGetForumTopicsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Q == "") {
		return false
	}
	if !(.OffsetDate == 0) {
		return false
	}
	if !(.OffsetID == 0) {
		return false
	}
	if !(.OffsetTopic == 0) {
		return false
	}
	if !(.Limit == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsGetForumTopicsRequest from given interface.
func ( *ChannelsGetForumTopicsRequest) ( interface {
	() ( InputChannelClass)
	() ( string,  bool)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Channel = .()
	if ,  := .();  {
		.Q = 
	}

	.OffsetDate = .()
	.OffsetID = .()
	.OffsetTopic = .()
	.Limit = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsGetForumTopicsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.getForumTopics",
		ID:   ChannelsGetForumTopicsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Q",
			SchemaName: "q",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "OffsetDate",
			SchemaName: "offset_date",
		},
		{
			Name:       "OffsetID",
			SchemaName: "offset_id",
		},
		{
			Name:       "OffsetTopic",
			SchemaName: "offset_topic",
		},
		{
			Name:       "Limit",
			SchemaName: "limit",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsGetForumTopicsRequest) () {
	if !(.Q == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsGetForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getForumTopics#de560d1 as nil")
	}
	.PutID(ChannelsGetForumTopicsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsGetForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.getForumTopics#de560d1 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getForumTopics#de560d1: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.getForumTopics#de560d1: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.getForumTopics#de560d1: field channel: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Q)
	}
	.PutInt(.OffsetDate)
	.PutInt(.OffsetID)
	.PutInt(.OffsetTopic)
	.PutInt(.Limit)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsGetForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.getForumTopics#de560d1 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field flags: %w", )
		}
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field channel: %w", )
		}
		.Channel = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field q: %w", )
		}
		.Q = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field offset_date: %w", )
		}
		.OffsetDate = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field offset_id: %w", )
		}
		.OffsetID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field offset_topic: %w", )
		}
		.OffsetTopic = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.getForumTopics#de560d1: field limit: %w", )
		}
		.Limit = 
	}
	return nil
}

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

// SetQ sets value of Q conditional field.
func ( *ChannelsGetForumTopicsRequest) ( string) {
	.Flags.Set(0)
	.Q = 
}

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

// GetOffsetDate returns value of OffsetDate field.
func ( *ChannelsGetForumTopicsRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetDate
}

// GetOffsetID returns value of OffsetID field.
func ( *ChannelsGetForumTopicsRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetID
}

// GetOffsetTopic returns value of OffsetTopic field.
func ( *ChannelsGetForumTopicsRequest) () ( int) {
	if  == nil {
		return
	}
	return .OffsetTopic
}

// GetLimit returns value of Limit field.
func ( *ChannelsGetForumTopicsRequest) () ( int) {
	if  == nil {
		return
	}
	return .Limit
}

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

// ChannelsGetForumTopics invokes method channels.getForumTopics#de560d1 returning error if any.
// Get topics of a forum¹
//
// 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 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//
// See https://core.telegram.org/method/channels.getForumTopics for reference.
func ( *Client) ( context.Context,  *ChannelsGetForumTopicsRequest) (*MessagesForumTopics, error) {
	var  MessagesForumTopics

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