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

// ChannelsToggleAntiSpamRequest represents TL type `channels.toggleAntiSpam#68f3e4eb`.
// Enable or disable the native antispam system¹.
//
// Links:
//  1. https://core.telegram.org/api/antispam
//
// See https://core.telegram.org/method/channels.toggleAntiSpam for reference.
type ChannelsToggleAntiSpamRequest struct {
	// Supergroup ID. The specified supergroup must have at least
	// telegram_antispam_group_size_min members to enable antispam functionality, as
	// specified by the client configuration parameters¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/config#client-configuration
	Channel InputChannelClass
	// Enable or disable the native antispam system.
	Enabled bool
}

// ChannelsToggleAntiSpamRequestTypeID is TL type id of ChannelsToggleAntiSpamRequest.
const ChannelsToggleAntiSpamRequestTypeID = 0x68f3e4eb

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

func ( *ChannelsToggleAntiSpamRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Channel == nil) {
		return false
	}
	if !(.Enabled == false) {
		return false
	}

	return true
}

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

// FillFrom fills ChannelsToggleAntiSpamRequest from given interface.
func ( *ChannelsToggleAntiSpamRequest) ( interface {
	() ( InputChannelClass)
	() ( bool)
}) {
	.Channel = .()
	.Enabled = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *ChannelsToggleAntiSpamRequest) () tdp.Type {
	 := tdp.Type{
		Name: "channels.toggleAntiSpam",
		ID:   ChannelsToggleAntiSpamRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Channel",
			SchemaName: "channel",
		},
		{
			Name:       "Enabled",
			SchemaName: "enabled",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *ChannelsToggleAntiSpamRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.toggleAntiSpam#68f3e4eb as nil")
	}
	.PutID(ChannelsToggleAntiSpamRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *ChannelsToggleAntiSpamRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.toggleAntiSpam#68f3e4eb as nil")
	}
	if .Channel == nil {
		return fmt.Errorf("unable to encode channels.toggleAntiSpam#68f3e4eb: field channel is nil")
	}
	if  := .Channel.Encode();  != nil {
		return fmt.Errorf("unable to encode channels.toggleAntiSpam#68f3e4eb: field channel: %w", )
	}
	.PutBool(.Enabled)
	return nil
}

// Decode implements bin.Decoder.
func ( *ChannelsToggleAntiSpamRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.toggleAntiSpam#68f3e4eb to nil")
	}
	if  := .ConsumeID(ChannelsToggleAntiSpamRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.toggleAntiSpam#68f3e4eb: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsToggleAntiSpamRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.toggleAntiSpam#68f3e4eb to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.toggleAntiSpam#68f3e4eb: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode channels.toggleAntiSpam#68f3e4eb: field enabled: %w", )
		}
		.Enabled = 
	}
	return nil
}

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

// GetEnabled returns value of Enabled field.
func ( *ChannelsToggleAntiSpamRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Enabled
}

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

// ChannelsToggleAntiSpam invokes method channels.toggleAntiSpam#68f3e4eb returning error if any.
// Enable or disable the native antispam system¹.
//
// Links:
//  1. https://core.telegram.org/api/antispam
//
// Possible errors:
//
//	400 CHAT_NOT_MODIFIED: No changes were made to chat information because the new information you passed is identical to the current information.
//
// See https://core.telegram.org/method/channels.toggleAntiSpam for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsToggleAntiSpamRequest) (UpdatesClass, error) {
	var  UpdatesBox

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