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

// MessagesToggleNoForwardsRequest represents TL type `messages.toggleNoForwards#b11eafa2`.
// Enable or disable content protection¹ on a channel or chat
//
// Links:
//  1. https://telegram.org/blog/protected-content-delete-by-date-and-more
//
// See https://core.telegram.org/method/messages.toggleNoForwards for reference.
type MessagesToggleNoForwardsRequest struct {
	// The chat or channel
	Peer InputPeerClass
	// Enable or disable content protection
	Enabled bool
}

// MessagesToggleNoForwardsRequestTypeID is TL type id of MessagesToggleNoForwardsRequest.
const MessagesToggleNoForwardsRequestTypeID = 0xb11eafa2

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

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

	return true
}

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

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

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

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

// TypeInfo returns info about TL type.
func ( *MessagesToggleNoForwardsRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.toggleNoForwards",
		ID:   MessagesToggleNoForwardsRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Peer",
			SchemaName: "peer",
		},
		{
			Name:       "Enabled",
			SchemaName: "enabled",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesToggleNoForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.toggleNoForwards#b11eafa2 as nil")
	}
	.PutID(MessagesToggleNoForwardsRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesToggleNoForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.toggleNoForwards#b11eafa2 as nil")
	}
	if .Peer == nil {
		return fmt.Errorf("unable to encode messages.toggleNoForwards#b11eafa2: field peer is nil")
	}
	if  := .Peer.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.toggleNoForwards#b11eafa2: field peer: %w", )
	}
	.PutBool(.Enabled)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesToggleNoForwardsRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.toggleNoForwards#b11eafa2 to nil")
	}
	{
		,  := DecodeInputPeer()
		if  != nil {
			return fmt.Errorf("unable to decode messages.toggleNoForwards#b11eafa2: field peer: %w", )
		}
		.Peer = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.toggleNoForwards#b11eafa2: field enabled: %w", )
		}
		.Enabled = 
	}
	return nil
}

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

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

// MessagesToggleNoForwards invokes method messages.toggleNoForwards#b11eafa2 returning error if any.
// Enable or disable content protection¹ on a channel or chat
//
// Links:
//  1. https://telegram.org/blog/protected-content-delete-by-date-and-more
//
// Possible errors:
//
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_NOT_MODIFIED: No changes were made to chat information because the new information you passed is identical to the current information.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//
// See https://core.telegram.org/method/messages.toggleNoForwards for reference.
func ( *Client) ( context.Context,  *MessagesToggleNoForwardsRequest) (UpdatesClass, error) {
	var  UpdatesBox

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