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

// ChannelsEditTitleRequest represents TL type `channels.editTitle#566decd0`.
// Edit the name of a channel/supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// See https://core.telegram.org/method/channels.editTitle for reference.
type ChannelsEditTitleRequest struct {
	// Channel/supergroup
	Channel InputChannelClass
	// New name
	Title string
}

// ChannelsEditTitleRequestTypeID is TL type id of ChannelsEditTitleRequest.
const ChannelsEditTitleRequestTypeID = 0x566decd0

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

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

	return true
}

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

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

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

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

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

// Encode implements bin.Encoder.
func ( *ChannelsEditTitleRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode channels.editTitle#566decd0 as nil")
	}
	.PutID(ChannelsEditTitleRequestTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *ChannelsEditTitleRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode channels.editTitle#566decd0 to nil")
	}
	{
		,  := DecodeInputChannel()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editTitle#566decd0: field channel: %w", )
		}
		.Channel = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode channels.editTitle#566decd0: field title: %w", )
		}
		.Title = 
	}
	return nil
}

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

// GetTitle returns value of Title field.
func ( *ChannelsEditTitleRequest) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

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

// ChannelsEditTitle invokes method channels.editTitle#566decd0 returning error if any.
// Edit the name of a channel/supergroup¹
//
// Links:
//  1. https://core.telegram.org/api/channel
//
// Possible errors:
//
//	400 CHANNEL_INVALID: The provided channel is invalid.
//	400 CHANNEL_PRIVATE: You haven't joined this channel/supergroup.
//	403 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 CHAT_TITLE_EMPTY: No chat title provided.
//	403 CHAT_WRITE_FORBIDDEN: You can't write in this chat.
//
// See https://core.telegram.org/method/channels.editTitle for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *ChannelsEditTitleRequest) (UpdatesClass, error) {
	var  UpdatesBox

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