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

// MessagesTogglePeerTranslationsRequest represents TL type `messages.togglePeerTranslations#e47cb579`.
// Show or hide the real-time chat translation popup¹ for a certain chat
//
// Links:
//  1. https://core.telegram.org/api/translation
//
// See https://core.telegram.org/method/messages.togglePeerTranslations for reference.
type MessagesTogglePeerTranslationsRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether to disable or enable the real-time chat translation popup
	Disabled bool
	// The peer
	Peer InputPeerClass
}

// MessagesTogglePeerTranslationsRequestTypeID is TL type id of MessagesTogglePeerTranslationsRequest.
const MessagesTogglePeerTranslationsRequestTypeID = 0xe47cb579

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

func ( *MessagesTogglePeerTranslationsRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Disabled == false) {
		return false
	}
	if !(.Peer == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesTogglePeerTranslationsRequest from given interface.
func ( *MessagesTogglePeerTranslationsRequest) ( interface {
	() ( bool)
	() ( InputPeerClass)
}) {
	.Disabled = .()
	.Peer = .()
}

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

// TypeName returns name of type in TL schema.
func (*MessagesTogglePeerTranslationsRequest) () string {
	return "messages.togglePeerTranslations"
}

// TypeInfo returns info about TL type.
func ( *MessagesTogglePeerTranslationsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.togglePeerTranslations",
		ID:   MessagesTogglePeerTranslationsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Disabled",
			SchemaName: "disabled",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *MessagesTogglePeerTranslationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.togglePeerTranslations#e47cb579 as nil")
	}
	.PutID(MessagesTogglePeerTranslationsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesTogglePeerTranslationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.togglePeerTranslations#e47cb579 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.togglePeerTranslations#e47cb579: field flags: %w", )
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.togglePeerTranslations#e47cb579: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.togglePeerTranslations#e47cb579: field peer: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *MessagesTogglePeerTranslationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.togglePeerTranslations#e47cb579 to nil")
	}
	if  := .ConsumeID(MessagesTogglePeerTranslationsRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode messages.togglePeerTranslations#e47cb579: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *MessagesTogglePeerTranslationsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.togglePeerTranslations#e47cb579 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode messages.togglePeerTranslations#e47cb579: field flags: %w", )
		}
	}
	.Disabled = .Flags.Has(0)
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.togglePeerTranslations#e47cb579: field peer: %w", )
		}
		.Peer = 
	}
	return nil
}

// SetDisabled sets value of Disabled conditional field.
func ( *MessagesTogglePeerTranslationsRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Disabled = true
	} else {
		.Flags.Unset(0)
		.Disabled = false
	}
}

// GetDisabled returns value of Disabled conditional field.
func ( *MessagesTogglePeerTranslationsRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetPeer returns value of Peer field.
func ( *MessagesTogglePeerTranslationsRequest) () ( InputPeerClass) {
	if  == nil {
		return
	}
	return .Peer
}

// MessagesTogglePeerTranslations invokes method messages.togglePeerTranslations#e47cb579 returning error if any.
// Show or hide the real-time chat translation popup¹ for a certain chat
//
// Links:
//  1. https://core.telegram.org/api/translation
//
// See https://core.telegram.org/method/messages.togglePeerTranslations for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesTogglePeerTranslationsRequest) (bool, error) {
	var  BoolBox

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