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

// ChannelsLeaveChannelRequest represents TL type `channels.leaveChannel#f836aa95`.
// Leave a channel/supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.leaveChannel for reference.
type ChannelsLeaveChannelRequest struct {
	// Channel/supergroup¹ to leave
	//
	// Links:
	//  1) https://core.telegram.org/api/channel
	Channel InputChannelClass
}

// ChannelsLeaveChannelRequestTypeID is TL type id of ChannelsLeaveChannelRequest.
const ChannelsLeaveChannelRequestTypeID = 0xf836aa95

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsLeaveChannelRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.leaveChannel#f836aa95 as nil")
	}
	.PutID(ChannelsLeaveChannelRequestTypeID)
	return .EncodeBare()
}

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

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

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

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

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

// ChannelsLeaveChannel invokes method channels.leaveChannel#f836aa95 returning error if any.
// Leave a channel/supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	406 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 CHANNEL_PUBLIC_GROUP_NA: channel/supergroup not available.
//	400 CHAT_INVALID: Invalid chat.
//	400 MSG_ID_INVALID: Invalid message ID provided.
//	400 USER_BANNED_IN_CHANNEL: You're banned from sending messages in supergroups/channels.
//	400 USER_CREATOR: You can't leave this channel, because you're its creator.
//	400 USER_NOT_PARTICIPANT: You're not a member of this supergroup/channel.
//
// See https://core.telegram.org/method/channels.leaveChannel for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  InputChannelClass) (UpdatesClass, error) {
	var  UpdatesBox

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