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

// MessagesEditChatAdminRequest represents TL type `messages.editChatAdmin#a85bd1c2`.
// Make a user admin in a basic groupĀ¹.
//
// Links:
//  1. https://core.telegram.org/api/channel#basic-groups
//
// See https://core.telegram.org/method/messages.editChatAdmin for reference.
type MessagesEditChatAdminRequest struct {
	// The ID of the group
	ChatID int64
	// The user to make admin
	UserID InputUserClass
	// Whether to make them admin
	IsAdmin bool
}

// MessagesEditChatAdminRequestTypeID is TL type id of MessagesEditChatAdminRequest.
const MessagesEditChatAdminRequestTypeID = 0xa85bd1c2

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

func ( *MessagesEditChatAdminRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ChatID == 0) {
		return false
	}
	if !(.UserID == nil) {
		return false
	}
	if !(.IsAdmin == false) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesEditChatAdminRequest from given interface.
func ( *MessagesEditChatAdminRequest) ( interface {
	() ( int64)
	() ( InputUserClass)
	() ( bool)
}) {
	.ChatID = .()
	.UserID = .()
	.IsAdmin = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesEditChatAdminRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.editChatAdmin",
		ID:   MessagesEditChatAdminRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			Name:       "IsAdmin",
			SchemaName: "is_admin",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesEditChatAdminRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editChatAdmin#a85bd1c2 as nil")
	}
	.PutID(MessagesEditChatAdminRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesEditChatAdminRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editChatAdmin#a85bd1c2 as nil")
	}
	.PutLong(.ChatID)
	if .UserID == nil {
		return fmt.Errorf("unable to encode messages.editChatAdmin#a85bd1c2: field user_id is nil")
	}
	if  := .UserID.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editChatAdmin#a85bd1c2: field user_id: %w", )
	}
	.PutBool(.IsAdmin)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesEditChatAdminRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.editChatAdmin#a85bd1c2 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editChatAdmin#a85bd1c2: field chat_id: %w", )
		}
		.ChatID = 
	}
	{
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editChatAdmin#a85bd1c2: field user_id: %w", )
		}
		.UserID = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editChatAdmin#a85bd1c2: field is_admin: %w", )
		}
		.IsAdmin = 
	}
	return nil
}

// GetChatID returns value of ChatID field.
func ( *MessagesEditChatAdminRequest) () ( int64) {
	if  == nil {
		return
	}
	return .ChatID
}

// GetUserID returns value of UserID field.
func ( *MessagesEditChatAdminRequest) () ( InputUserClass) {
	if  == nil {
		return
	}
	return .UserID
}

// GetIsAdmin returns value of IsAdmin field.
func ( *MessagesEditChatAdminRequest) () ( bool) {
	if  == nil {
		return
	}
	return .IsAdmin
}

// MessagesEditChatAdmin invokes method messages.editChatAdmin#a85bd1c2 returning error if any.
// Make a user admin in a basic groupĀ¹.
//
// Links:
//  1. https://core.telegram.org/api/channel#basic-groups
//
// Possible errors:
//
//	400 CHAT_ID_INVALID: The provided chat id is invalid.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 USER_ID_INVALID: The provided user ID is invalid.
//	400 USER_NOT_PARTICIPANT: You're not a member of this supergroup/channel.
//
// See https://core.telegram.org/method/messages.editChatAdmin for reference.
func ( *Client) ( context.Context,  *MessagesEditChatAdminRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}