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

// ChannelsToggleAutotranslationRequest represents TL type `channels.toggleAutotranslation#167fc0a1`.
// Toggle autotranslation in a channel, for all users: see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/translation#autotranslation-for-channels
//
// See https://core.telegram.org/method/channels.toggleAutotranslation for reference.
type ChannelsToggleAutotranslationRequest struct {
	// The channel where to toggle autotranslation.
	Channel InputChannelClass
	// Whether to enable or disable autotranslation.
	Enabled bool
}

// ChannelsToggleAutotranslationRequestTypeID is TL type id of ChannelsToggleAutotranslationRequest.
const ChannelsToggleAutotranslationRequestTypeID = 0x167fc0a1

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsToggleAutotranslationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.toggleAutotranslation#167fc0a1 as nil")
	}
	.PutID(ChannelsToggleAutotranslationRequestTypeID)
	return .EncodeBare()
}

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

// Decode implements bin.Decoder.
func ( *ChannelsToggleAutotranslationRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.toggleAutotranslation#167fc0a1 to nil")
	}
	if  := .ConsumeID(ChannelsToggleAutotranslationRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode channels.toggleAutotranslation#167fc0a1: %w", )
	}
	return .DecodeBare()
}

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

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

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

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

// ChannelsToggleAutotranslation invokes method channels.toggleAutotranslation#167fc0a1 returning error if any.
// Toggle autotranslation in a channel, for all users: see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/translation#autotranslation-for-channels
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//
// See https://core.telegram.org/method/channels.toggleAutotranslation for reference.
func ( *Client) ( context.Context,  *ChannelsToggleAutotranslationRequest) (UpdatesClass, error) {
	var  UpdatesBox

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