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

// ChannelsDeleteHistoryRequest represents TL type `channels.deleteHistory#9baa9647`.
// Delete the history of a supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.deleteHistory for reference.
type ChannelsDeleteHistoryRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether the history should be deleted for everyone
	ForEveryone bool
	// Supergroup¹ whose history must be deleted
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Channel InputChannelClass
	// ID of message up to which the history must be deleted
	MaxID int
}

// ChannelsDeleteHistoryRequestTypeID is TL type id of ChannelsDeleteHistoryRequest.
const ChannelsDeleteHistoryRequestTypeID = 0x9baa9647

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

func ( *ChannelsDeleteHistoryRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ForEveryone == false) {
		return false
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.MaxID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsDeleteHistoryRequest from given interface.
func ( *ChannelsDeleteHistoryRequest) ( interface {
	() ( bool)
	() ( InputChannelClass)
	() ( int)
}) {
	.ForEveryone = .()
	.Channel = .()
	.MaxID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsDeleteHistoryRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.deleteHistory",
		ID:   ChannelsDeleteHistoryRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ForEveryone",
			SchemaName: "for_everyone",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "MaxID",
			SchemaName: "max_id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *ChannelsDeleteHistoryRequest) () {
	if !(.ForEveryone == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *ChannelsDeleteHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.deleteHistory#9baa9647 as nil")
	}
	.PutID(ChannelsDeleteHistoryRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsDeleteHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.deleteHistory#9baa9647 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.deleteHistory#9baa9647: field flags: %w", )
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.deleteHistory#9baa9647: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.deleteHistory#9baa9647: field channel: %w", )
	}
	.PutInt(.MaxID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsDeleteHistoryRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.deleteHistory#9baa9647 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: field flags: %w", )
		}
	}
	.ForEveryone = .Flags.Has(0)
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode channels.deleteHistory#9baa9647: field max_id: %w", )
		}
		.MaxID = 
	}
	return nil
}

// SetForEveryone sets value of ForEveryone conditional field.
func ( *ChannelsDeleteHistoryRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.ForEveryone = true
	} else {
		.Flags.Unset(0)
		.ForEveryone = false
	}
}

// GetForEveryone returns value of ForEveryone conditional field.
func ( *ChannelsDeleteHistoryRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

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

// GetMaxID returns value of MaxID field.
func ( *ChannelsDeleteHistoryRequest) () ( int) {
	if  == nil {
		return
	}
	return .MaxID
}

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

// ChannelsDeleteHistory invokes method channels.deleteHistory#9baa9647 returning error if any.
// Delete the history of a supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PARICIPANT_MISSING: The current user is not in the channel.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHANNEL_TOO_BIG: This channel has too many participants (>1000) to be deleted.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//
// See https://core.telegram.org/method/channels.deleteHistory for reference.
func ( *Client) ( context.Context,  *ChannelsDeleteHistoryRequest) (UpdatesClass, error) {
	var  UpdatesBox

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