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

// ChannelsToggleJoinToSendRequest represents TL type `channels.toggleJoinToSend#e4cb9580`.
// Set whether all users should join a discussion group in order to comment on a post
// »¹
//
// Links:
//  1. https://core.telegram.org/api/discussion#requiring-users-to-join-the-group
//
// See https://core.telegram.org/method/channels.toggleJoinToSend for reference.
type ChannelsToggleJoinToSendRequest struct {
	// Discussion group
	Channel InputChannelClass
	// Toggle
	Enabled bool
}

// ChannelsToggleJoinToSendRequestTypeID is TL type id of ChannelsToggleJoinToSendRequest.
const ChannelsToggleJoinToSendRequestTypeID = 0xe4cb9580

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsToggleJoinToSendRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.toggleJoinToSend#e4cb9580 as nil")
	}
	.PutID(ChannelsToggleJoinToSendRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

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

// ChannelsToggleJoinToSend invokes method channels.toggleJoinToSend#e4cb9580 returning error if any.
// Set whether all users should join a discussion group in order to comment on a post
// »¹
//
// Links:
//  1. https://core.telegram.org/api/discussion#requiring-users-to-join-the-group
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHAT_ADMIN_REQUIRED: You must be an admin in this chat to do this.
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	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.toggleJoinToSend for reference.
func ( *Client) ( context.Context,  *ChannelsToggleJoinToSendRequest) (UpdatesClass, error) {
	var  UpdatesBox

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