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

// PhotosUpdateProfilePhotoRequest represents TL type `photos.updateProfilePhoto#9e82039`.
// Installs a previously uploaded photo as a profile photo.
//
// See https://core.telegram.org/method/photos.updateProfilePhoto for reference.
type PhotosUpdateProfilePhotoRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, the chosen profile photo will be shown to users that can't display your main
	// profile photo due to your privacy settings.
	Fallback bool
	// Can contain info of a bot we own, to change the profile photo of that bot, instead of
	// the current user.
	//
	// Use SetBot and GetBot helpers.
	Bot InputUserClass
	// Input photo
	ID InputPhotoClass
}

// PhotosUpdateProfilePhotoRequestTypeID is TL type id of PhotosUpdateProfilePhotoRequest.
const PhotosUpdateProfilePhotoRequestTypeID = 0x9e82039

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

func ( *PhotosUpdateProfilePhotoRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Fallback == false) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.ID == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PhotosUpdateProfilePhotoRequest from given interface.
func ( *PhotosUpdateProfilePhotoRequest) ( interface {
	() ( bool)
	() ( InputUserClass,  bool)
	() ( InputPhotoClass)
}) {
	.Fallback = .()
	if ,  := .();  {
		.Bot = 
	}

	.ID = .()
}

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

// TypeName returns name of type in TL schema.
func (*PhotosUpdateProfilePhotoRequest) () string {
	return "photos.updateProfilePhoto"
}

// TypeInfo returns info about TL type.
func ( *PhotosUpdateProfilePhotoRequest) () tdp.Type {
	 := tdp.Type{
		Name: "photos.updateProfilePhoto",
		ID:   PhotosUpdateProfilePhotoRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Fallback",
			SchemaName: "fallback",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhotosUpdateProfilePhotoRequest) () {
	if !(.Fallback == false) {
		.Flags.Set(0)
	}
	if !(.Bot == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *PhotosUpdateProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.updateProfilePhoto#9e82039 as nil")
	}
	.PutID(PhotosUpdateProfilePhotoRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhotosUpdateProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.updateProfilePhoto#9e82039 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode photos.updateProfilePhoto#9e82039: field flags: %w", )
	}
	if .Flags.Has(1) {
		if .Bot == nil {
			return fmt.Errorf("unable to encode photos.updateProfilePhoto#9e82039: field bot is nil")
		}
		if  := .Bot.Encode();  != nil {
			return fmt.Errorf("unable to encode photos.updateProfilePhoto#9e82039: field bot: %w", )
		}
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode photos.updateProfilePhoto#9e82039: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode photos.updateProfilePhoto#9e82039: field id: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhotosUpdateProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.updateProfilePhoto#9e82039 to nil")
	}
	if  := .ConsumeID(PhotosUpdateProfilePhotoRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode photos.updateProfilePhoto#9e82039: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhotosUpdateProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.updateProfilePhoto#9e82039 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode photos.updateProfilePhoto#9e82039: field flags: %w", )
		}
	}
	.Fallback = .Flags.Has(0)
	if .Flags.Has(1) {
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode photos.updateProfilePhoto#9e82039: field bot: %w", )
		}
		.Bot = 
	}
	{
		,  := DecodeInputPhoto()
		if  != nil {
			return fmt.Errorf("unable to decode photos.updateProfilePhoto#9e82039: field id: %w", )
		}
		.ID = 
	}
	return nil
}

// SetFallback sets value of Fallback conditional field.
func ( *PhotosUpdateProfilePhotoRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.Fallback = true
	} else {
		.Flags.Unset(0)
		.Fallback = false
	}
}

// GetFallback returns value of Fallback conditional field.
func ( *PhotosUpdateProfilePhotoRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetBot sets value of Bot conditional field.
func ( *PhotosUpdateProfilePhotoRequest) ( InputUserClass) {
	.Flags.Set(1)
	.Bot = 
}

// GetBot returns value of Bot conditional field and
// boolean which is true if field was set.
func ( *PhotosUpdateProfilePhotoRequest) () ( InputUserClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Bot, true
}

// GetID returns value of ID field.
func ( *PhotosUpdateProfilePhotoRequest) () ( InputPhotoClass) {
	if  == nil {
		return
	}
	return .ID
}

// GetIDAsNotEmpty returns mapped value of ID field.
func ( *PhotosUpdateProfilePhotoRequest) () (*InputPhoto, bool) {
	return .ID.AsNotEmpty()
}

// PhotosUpdateProfilePhoto invokes method photos.updateProfilePhoto#9e82039 returning error if any.
// Installs a previously uploaded photo as a profile photo.
//
// Possible errors:
//
//	400 ALBUM_PHOTOS_TOO_MANY: You have uploaded too many profile photos, delete some before retrying.
//	400 FILE_PARTS_INVALID: The number of file parts is invalid.
//	400 IMAGE_PROCESS_FAILED: Failure while processing image.
//	400 LOCATION_INVALID: The provided location is invalid.
//	400 PHOTO_CROP_SIZE_SMALL: Photo is too small.
//	400 PHOTO_EXT_INVALID: The extension of the photo is invalid.
//	400 PHOTO_ID_INVALID: Photo ID invalid.
//
// See https://core.telegram.org/method/photos.updateProfilePhoto for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *PhotosUpdateProfilePhotoRequest) (*PhotosPhoto, error) {
	var  PhotosPhoto

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