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

// PhotosUploadProfilePhotoRequest represents TL type `photos.uploadProfilePhoto#388a3b5`.
// Updates current user profile photo.
// The file, video and video_emoji_markup flags are mutually exclusive.
//
// See https://core.telegram.org/method/photos.uploadProfilePhoto for reference.
type PhotosUploadProfilePhotoRequest 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
	// Profile photo
	//
	// Use SetFile and GetFile helpers.
	File InputFileClass
	// Animated profile picture¹ video
	//
	// Links:
	//  1) https://core.telegram.org/api/files#animated-profile-pictures
	//
	// Use SetVideo and GetVideo helpers.
	Video InputFileClass
	// Floating point UNIX timestamp in seconds, indicating the frame of the video/sticker
	// that should be used as static preview; can only be used if video or video_emoji_markup
	// is set.
	//
	// Use SetVideoStartTs and GetVideoStartTs helpers.
	VideoStartTs float64
	// Animated sticker profile picture, must contain either a videoSizeEmojiMarkup¹ or a
	// videoSizeStickerMarkup² constructor.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/videoSizeEmojiMarkup
	//  2) https://core.telegram.org/constructor/videoSizeStickerMarkup
	//
	// Use SetVideoEmojiMarkup and GetVideoEmojiMarkup helpers.
	VideoEmojiMarkup VideoSizeClass
}

// PhotosUploadProfilePhotoRequestTypeID is TL type id of PhotosUploadProfilePhotoRequest.
const PhotosUploadProfilePhotoRequestTypeID = 0x388a3b5

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

func ( *PhotosUploadProfilePhotoRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Fallback == false) {
		return false
	}
	if !(.Bot == nil) {
		return false
	}
	if !(.File == nil) {
		return false
	}
	if !(.Video == nil) {
		return false
	}
	if !(.VideoStartTs == 0) {
		return false
	}
	if !(.VideoEmojiMarkup == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PhotosUploadProfilePhotoRequest from given interface.
func ( *PhotosUploadProfilePhotoRequest) ( interface {
	() ( bool)
	() ( InputUserClass,  bool)
	() ( InputFileClass,  bool)
	() ( InputFileClass,  bool)
	() ( float64,  bool)
	() ( VideoSizeClass,  bool)
}) {
	.Fallback = .()
	if ,  := .();  {
		.Bot = 
	}

	if ,  := .();  {
		.File = 
	}

	if ,  := .();  {
		.Video = 
	}

	if ,  := .();  {
		.VideoStartTs = 
	}

	if ,  := .();  {
		.VideoEmojiMarkup = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *PhotosUploadProfilePhotoRequest) () tdp.Type {
	 := tdp.Type{
		Name: "photos.uploadProfilePhoto",
		ID:   PhotosUploadProfilePhotoRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Fallback",
			SchemaName: "fallback",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Bot",
			SchemaName: "bot",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "File",
			SchemaName: "file",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Video",
			SchemaName: "video",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "VideoStartTs",
			SchemaName: "video_start_ts",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "VideoEmojiMarkup",
			SchemaName: "video_emoji_markup",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PhotosUploadProfilePhotoRequest) () {
	if !(.Fallback == false) {
		.Flags.Set(3)
	}
	if !(.Bot == nil) {
		.Flags.Set(5)
	}
	if !(.File == nil) {
		.Flags.Set(0)
	}
	if !(.Video == nil) {
		.Flags.Set(1)
	}
	if !(.VideoStartTs == 0) {
		.Flags.Set(2)
	}
	if !(.VideoEmojiMarkup == nil) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *PhotosUploadProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.uploadProfilePhoto#388a3b5 as nil")
	}
	.PutID(PhotosUploadProfilePhotoRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PhotosUploadProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.uploadProfilePhoto#388a3b5 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field flags: %w", )
	}
	if .Flags.Has(5) {
		if .Bot == nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field bot is nil")
		}
		if  := .Bot.Encode();  != nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field bot: %w", )
		}
	}
	if .Flags.Has(0) {
		if .File == nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field file is nil")
		}
		if  := .File.Encode();  != nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field file: %w", )
		}
	}
	if .Flags.Has(1) {
		if .Video == nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field video is nil")
		}
		if  := .Video.Encode();  != nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field video: %w", )
		}
	}
	if .Flags.Has(2) {
		.PutDouble(.VideoStartTs)
	}
	if .Flags.Has(4) {
		if .VideoEmojiMarkup == nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field video_emoji_markup is nil")
		}
		if  := .VideoEmojiMarkup.Encode();  != nil {
			return fmt.Errorf("unable to encode photos.uploadProfilePhoto#388a3b5: field video_emoji_markup: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PhotosUploadProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.uploadProfilePhoto#388a3b5 to nil")
	}
	if  := .ConsumeID(PhotosUploadProfilePhotoRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PhotosUploadProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode photos.uploadProfilePhoto#388a3b5 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: field flags: %w", )
		}
	}
	.Fallback = .Flags.Has(3)
	if .Flags.Has(5) {
		,  := DecodeInputUser()
		if  != nil {
			return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: field bot: %w", )
		}
		.Bot = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: field file: %w", )
		}
		.File = 
	}
	if .Flags.Has(1) {
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: field video: %w", )
		}
		.Video = 
	}
	if .Flags.Has(2) {
		,  := .Double()
		if  != nil {
			return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: field video_start_ts: %w", )
		}
		.VideoStartTs = 
	}
	if .Flags.Has(4) {
		,  := DecodeVideoSize()
		if  != nil {
			return fmt.Errorf("unable to decode photos.uploadProfilePhoto#388a3b5: field video_emoji_markup: %w", )
		}
		.VideoEmojiMarkup = 
	}
	return nil
}

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

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

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

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

// SetFile sets value of File conditional field.
func ( *PhotosUploadProfilePhotoRequest) ( InputFileClass) {
	.Flags.Set(0)
	.File = 
}

// GetFile returns value of File conditional field and
// boolean which is true if field was set.
func ( *PhotosUploadProfilePhotoRequest) () ( InputFileClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .File, true
}

// SetVideo sets value of Video conditional field.
func ( *PhotosUploadProfilePhotoRequest) ( InputFileClass) {
	.Flags.Set(1)
	.Video = 
}

// GetVideo returns value of Video conditional field and
// boolean which is true if field was set.
func ( *PhotosUploadProfilePhotoRequest) () ( InputFileClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Video, true
}

// SetVideoStartTs sets value of VideoStartTs conditional field.
func ( *PhotosUploadProfilePhotoRequest) ( float64) {
	.Flags.Set(2)
	.VideoStartTs = 
}

// GetVideoStartTs returns value of VideoStartTs conditional field and
// boolean which is true if field was set.
func ( *PhotosUploadProfilePhotoRequest) () ( float64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .VideoStartTs, true
}

// SetVideoEmojiMarkup sets value of VideoEmojiMarkup conditional field.
func ( *PhotosUploadProfilePhotoRequest) ( VideoSizeClass) {
	.Flags.Set(4)
	.VideoEmojiMarkup = 
}

// GetVideoEmojiMarkup returns value of VideoEmojiMarkup conditional field and
// boolean which is true if field was set.
func ( *PhotosUploadProfilePhotoRequest) () ( VideoSizeClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .VideoEmojiMarkup, true
}

// PhotosUploadProfilePhoto invokes method photos.uploadProfilePhoto#388a3b5 returning error if any.
// Updates current user profile photo.
// The file, video and video_emoji_markup flags are mutually exclusive.
//
// Possible errors:
//
//	400 ALBUM_PHOTOS_TOO_MANY: You have uploaded too many profile photos, delete some before retrying.
//	400 BOT_INVALID: This is not a valid bot.
//	400 EMOJI_MARKUP_INVALID: The specified video_emoji_markup was invalid.
//	400 FILE_PARTS_INVALID: The number of file parts is invalid.
//	400 IMAGE_PROCESS_FAILED: Failure while processing image.
//	400 PHOTO_CROP_FILE_MISSING: Photo crop file missing.
//	400 PHOTO_CROP_SIZE_SMALL: Photo is too small.
//	400 PHOTO_EXT_INVALID: The extension of the photo is invalid.
//	400 PHOTO_FILE_MISSING: Profile photo file missing.
//	400 PHOTO_INVALID: Photo invalid.
//	400 STICKER_MIME_INVALID: The specified sticker MIME type is invalid.
//	400 VIDEO_FILE_INVALID: The specified video file is invalid.
//
// See https://core.telegram.org/method/photos.uploadProfilePhoto for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *PhotosUploadProfilePhotoRequest) (*PhotosPhoto, error) {
	var  PhotosPhoto

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