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

// MessagesEditChatPhotoRequest represents TL type `messages.editChatPhoto#35ddd674`.
// Changes chat photo and sends a service message on it
//
// See https://core.telegram.org/method/messages.editChatPhoto for reference.
type MessagesEditChatPhotoRequest struct {
	// Chat ID
	ChatID int64
	// Photo to be set
	Photo InputChatPhotoClass
}

// MessagesEditChatPhotoRequestTypeID is TL type id of MessagesEditChatPhotoRequest.
const MessagesEditChatPhotoRequestTypeID = 0x35ddd674

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

func ( *MessagesEditChatPhotoRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ChatID == 0) {
		return false
	}
	if !(.Photo == nil) {
		return false
	}

	return true
}

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

// FillFrom fills MessagesEditChatPhotoRequest from given interface.
func ( *MessagesEditChatPhotoRequest) ( interface {
	() ( int64)
	() ( InputChatPhotoClass)
}) {
	.ChatID = .()
	.Photo = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *MessagesEditChatPhotoRequest) () tdp.Type {
	 := tdp.Type{
		Name: "messages.editChatPhoto",
		ID:   MessagesEditChatPhotoRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ChatID",
			SchemaName: "chat_id",
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *MessagesEditChatPhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editChatPhoto#35ddd674 as nil")
	}
	.PutID(MessagesEditChatPhotoRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *MessagesEditChatPhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode messages.editChatPhoto#35ddd674 as nil")
	}
	.PutLong(.ChatID)
	if .Photo == nil {
		return fmt.Errorf("unable to encode messages.editChatPhoto#35ddd674: field photo is nil")
	}
	if  := .Photo.Encode();  != nil {
		return fmt.Errorf("unable to encode messages.editChatPhoto#35ddd674: field photo: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *MessagesEditChatPhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode messages.editChatPhoto#35ddd674 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editChatPhoto#35ddd674: field chat_id: %w", )
		}
		.ChatID = 
	}
	{
		,  := DecodeInputChatPhoto()
		if  != nil {
			return fmt.Errorf("unable to decode messages.editChatPhoto#35ddd674: field photo: %w", )
		}
		.Photo = 
	}
	return nil
}

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

// GetPhoto returns value of Photo field.
func ( *MessagesEditChatPhotoRequest) () ( InputChatPhotoClass) {
	if  == nil {
		return
	}
	return .Photo
}

// MessagesEditChatPhoto invokes method messages.editChatPhoto#35ddd674 returning error if any.
// Changes chat photo and sends a service message on it
//
// Possible errors:
//
//	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.
//	400 IMAGE_PROCESS_FAILED: Failure while processing image.
//	400 PEER_ID_INVALID: The provided peer id is invalid.
//	400 PHOTO_CROP_SIZE_SMALL: Photo is too small.
//	400 PHOTO_EXT_INVALID: The extension of the photo is invalid.
//	400 PHOTO_INVALID: Photo invalid.
//
// See https://core.telegram.org/method/messages.editChatPhoto for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *MessagesEditChatPhotoRequest) (UpdatesClass, error) {
	var  UpdatesBox

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