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

// ChannelsDeleteTopicHistoryRequest represents TL type `channels.deleteTopicHistory#34435f2d`.
// Delete message history of a forum topicĀ¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// See https://core.telegram.org/method/channels.deleteTopicHistory for reference.
type ChannelsDeleteTopicHistoryRequest struct {
	// Forum
	Channel InputChannelClass
	// Topic ID
	TopMsgID int
}

// ChannelsDeleteTopicHistoryRequestTypeID is TL type id of ChannelsDeleteTopicHistoryRequest.
const ChannelsDeleteTopicHistoryRequestTypeID = 0x34435f2d

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

func ( *ChannelsDeleteTopicHistoryRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.TopMsgID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsDeleteTopicHistoryRequest from given interface.
func ( *ChannelsDeleteTopicHistoryRequest) ( interface {
	() ( InputChannelClass)
	() ( int)
}) {
	.Channel = .()
	.TopMsgID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsDeleteTopicHistoryRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.deleteTopicHistory",
		ID:   ChannelsDeleteTopicHistoryRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "TopMsgID",
			SchemaName: "top_msg_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsDeleteTopicHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.deleteTopicHistory#34435f2d as nil")
	}
	.PutID(ChannelsDeleteTopicHistoryRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsDeleteTopicHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.deleteTopicHistory#34435f2d as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.deleteTopicHistory#34435f2d: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.deleteTopicHistory#34435f2d: field channel: %w", )
	}
	.PutInt(.TopMsgID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsDeleteTopicHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.deleteTopicHistory#34435f2d to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.deleteTopicHistory#34435f2d: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.deleteTopicHistory#34435f2d: field top_msg_id: %w", )
		}
		.TopMsgID = 
	}
	return nil
}

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

// GetTopMsgID returns value of TopMsgID field.
func ( *ChannelsDeleteTopicHistoryRequest) () ( int) {
	if  == nil {
		return
	}
	return .TopMsgID
}

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

// ChannelsDeleteTopicHistory invokes method channels.deleteTopicHistory#34435f2d returning error if any.
// Delete message history of a forum topicĀ¹
//
// Links:
//  1. https://core.telegram.org/api/forum
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 TOPIC_ID_INVALID: The specified topic ID is invalid.
//
// See https://core.telegram.org/method/channels.deleteTopicHistory for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsDeleteTopicHistoryRequest) (*MessagesAffectedHistory, error) {
	var  MessagesAffectedHistory

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