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

// MessagesGetForumTopicsRequest represents TL type `messages.getForumTopics#3ba47bff`.
// Get topics of a forum¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/messages.getForumTopics for reference.
type MessagesGetForumTopicsRequest 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
	// 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
}

// MessagesGetForumTopicsRequestTypeID is TL type id of MessagesGetForumTopicsRequest.
const MessagesGetForumTopicsRequestTypeID = 0x3ba47bff

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

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

// FillFrom fills MessagesGetForumTopicsRequest from given interface.
func ( *MessagesGetForumTopicsRequest) ( interface {
	() ( InputPeerClass)
	() ( string,  bool)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
}) {
	.Peer = .()
	if ,  := .();  {
		.Q = 
	}

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

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

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

// TypeInfo returns info about TL type.
func ( *MessagesGetForumTopicsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.getForumTopics",
		ID:   MessagesGetForumTopicsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			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 ( *MessagesGetForumTopicsRequest) () {
	if !(.Q == "") {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *MessagesGetForumTopicsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.getForumTopics#3ba47bff as nil")
	}
	.PutID(MessagesGetForumTopicsRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

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

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

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

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

// MessagesGetForumTopics invokes method messages.getForumTopics#3ba47bff returning error if any.
// Get topics of a forum¹
//
// 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.getForumTopics for reference.
func ( *Client) ( context.Context,  *MessagesGetForumTopicsRequest) (*MessagesForumTopics, error) {
	var  MessagesForumTopics

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