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

// ChannelsJoinChannelRequest represents TL type `channels.joinChannel#24b524c5`.
// Join a channel/supergroup
//
// See https://core.telegram.org/method/channels.joinChannel for reference.
type ChannelsJoinChannelRequest struct {
	// Channel/supergroup to join
	Channel InputChannelClass
}

// ChannelsJoinChannelRequestTypeID is TL type id of ChannelsJoinChannelRequest.
const ChannelsJoinChannelRequestTypeID = 0x24b524c5

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsJoinChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.joinChannel#24b524c5 as nil")
	}
	.PutID(ChannelsJoinChannelRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsJoinChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.joinChannel#24b524c5 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.joinChannel#24b524c5: field channel: %w", )
		}
		.Channel = 
	}
	return nil
}

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

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

// ChannelsJoinChannel invokes method channels.joinChannel#24b524c5 returning error if any.
// Join a channel/supergroup
//
// Possible errors:
//
//	400 CHANNELS_TOO_MUCH: You have joined too many channels/supergroups.
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	400 CHAT_INVALID: Invalid chat.
//	400 INVITE_HASH_EMPTY: The invite hash is empty.
//	406 INVITE_HASH_EXPIRED: The invite link has expired.
//	400 INVITE_HASH_INVALID: The invite hash is invalid.
//	400 INVITE_REQUEST_SENT: You have successfully requested to join this chat or channel.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USERS_TOO_MUCH: The maximum number of users has been exceeded (to create a chat, for example).
//	400 USER_ALREADY_PARTICIPANT: The user is already in the group.
//	400 USER_CHANNELS_TOO_MUCH: One of the users you tried to add is already in too many channels/supergroups.
//
// See https://core.telegram.org/method/channels.joinChannel for reference.
func ( *Client) ( context.Context,  InputChannelClass) (UpdatesClass, error) {
	var  UpdatesBox

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