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

// ChannelsUpdatePinnedForumTopicRequest represents TL type `channels.updatePinnedForumTopic#6c2d9026`.
// Pin or unpin forum topics¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/channels.updatePinnedForumTopic for reference.
type ChannelsUpdatePinnedForumTopicRequest struct {
	// Supergroup ID
	Channel InputChannelClass
	// Forum topic ID¹
	//
	// Links:
	//  1) https://core.telegram.org/api/forum
	TopicID int
	// Whether to pin or unpin the topic
	Pinned bool
}

// ChannelsUpdatePinnedForumTopicRequestTypeID is TL type id of ChannelsUpdatePinnedForumTopicRequest.
const ChannelsUpdatePinnedForumTopicRequestTypeID = 0x6c2d9026

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

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

	return true
}

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

// FillFrom fills ChannelsUpdatePinnedForumTopicRequest from given interface.
func ( *ChannelsUpdatePinnedForumTopicRequest) ( interface {
	() ( InputChannelClass)
	() ( int)
	() ( bool)
}) {
	.Channel = .()
	.TopicID = .()
	.Pinned = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsUpdatePinnedForumTopicRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.updatePinnedForumTopic",
		ID:   ChannelsUpdatePinnedForumTopicRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "TopicID",
			SchemaName: "topic_id",
		},
		{
			Name:       "Pinned",
			SchemaName: "pinned",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.updatePinnedForumTopic#6c2d9026 as nil")
	}
	.PutID(ChannelsUpdatePinnedForumTopicRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.updatePinnedForumTopic#6c2d9026 as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.updatePinnedForumTopic#6c2d9026: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.updatePinnedForumTopic#6c2d9026: field channel: %w", )
	}
	.PutInt(.TopicID)
	.PutBool(.Pinned)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsUpdatePinnedForumTopicRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.updatePinnedForumTopic#6c2d9026 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: field topic_id: %w", )
		}
		.TopicID = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode channels.updatePinnedForumTopic#6c2d9026: field pinned: %w", )
		}
		.Pinned = 
	}
	return nil
}

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

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

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

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

// ChannelsUpdatePinnedForumTopic invokes method channels.updatePinnedForumTopic#6c2d9026 returning error if any.
// Pin or unpin forum topics¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/channels.updatePinnedForumTopic for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsUpdatePinnedForumTopicRequest) (UpdatesClass, error) {
	var  UpdatesBox

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