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

// MessagesUpdatePinnedForumTopicRequest represents TL type `messages.updatePinnedForumTopic#175df251`.
// Pin or unpin forum topics¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/messages.updatePinnedForumTopic for reference.
type MessagesUpdatePinnedForumTopicRequest struct {
	// The supergroup forum, private chat (for forum-enabled bots) or bot forum (for users)
	// where the topic is located.
	Peer InputPeerClass
	// Forum topic ID¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	TopicID int
	// Whether to pin or unpin the topic
	Pinned bool
}

// MessagesUpdatePinnedForumTopicRequestTypeID is TL type id of MessagesUpdatePinnedForumTopicRequest.
const MessagesUpdatePinnedForumTopicRequestTypeID = 0x175df251

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

func ( *MessagesUpdatePinnedForumTopicRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Peer == nil) {
		return false
	}
	if !(.TopicID == 0) {
		return false
	}
	if !(.Pinned == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesUpdatePinnedForumTopicRequest from given interface.
func ( *MessagesUpdatePinnedForumTopicRequest) ( interface {
	() ( InputPeerClass)
	() ( int)
	() ( bool)
}) {
	.Peer = .()
	.TopicID = .()
	.Pinned = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesUpdatePinnedForumTopicRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.updatePinnedForumTopic",
		ID:   MessagesUpdatePinnedForumTopicRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "TopicID",
			SchemaName: "topic_id",
		},
		{
			Name:       "Pinned",
			SchemaName: "pinned",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.updatePinnedForumTopic#175df251 as nil")
	}
	.PutID(MessagesUpdatePinnedForumTopicRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.updatePinnedForumTopic#175df251 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.updatePinnedForumTopic#175df251: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.updatePinnedForumTopic#175df251: field peer: %w", )
	}
	.PutInt(.TopicID)
	.PutBool(.Pinned)
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.updatePinnedForumTopic#175df251 to nil")
	}
	if  := .ConsumeID(MessagesUpdatePinnedForumTopicRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.updatePinnedForumTopic#175df251: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.updatePinnedForumTopic#175df251 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.updatePinnedForumTopic#175df251: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode messages.updatePinnedForumTopic#175df251: field topic_id: %w", )
		}
		.TopicID = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.updatePinnedForumTopic#175df251: field pinned: %w", )
		}
		.Pinned = 
	}
	return nil
}

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

// GetTopicID returns value of TopicID field.
func ( *MessagesUpdatePinnedForumTopicRequest) () ( int) {
	if  == nil {
		return
	}
	return .TopicID
}

// GetPinned returns value of Pinned field.
func ( *MessagesUpdatePinnedForumTopicRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Pinned
}

// MessagesUpdatePinnedForumTopic invokes method messages.updatePinnedForumTopic#175df251 returning error if any.
// Pin or unpin forum topics¹
//
// 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.updatePinnedForumTopic for reference.
func ( *Client) ( context.Context,  *MessagesUpdatePinnedForumTopicRequest) (UpdatesClass, error) {
	var  UpdatesBox

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