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

// PhotosUploadContactProfilePhotoRequest represents TL type `photos.uploadContactProfilePhoto#e14c4a71`.
// Upload a custom profile picture for a contact, or suggest a new profile picture to a
// contact.
// The file, video and video_emoji_markup flags are mutually exclusive.
//
// See https://core.telegram.org/method/photos.uploadContactProfilePhoto for reference.
type PhotosUploadContactProfilePhotoRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// If set, will send a messageActionSuggestProfilePhoto¹ service message to user_id,
	// suggesting them to use the specified profile picture; otherwise, will set a personal
	// profile picture for the user (only visible to the current user).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageActionSuggestProfilePhoto
	Suggest bool
	// If set, removes a previously set personal profile picture (does not affect suggested
	// profile pictures, to remove them simply deleted the messageActionSuggestProfilePhoto¹
	// service message with messages.deleteMessages²).
	//
	// Links:
	//  1) https://core.telegram.org/constructor/messageActionSuggestProfilePhoto
	//  2) https://core.telegram.org/method/messages.deleteMessages
	Save bool
	// The contact
	UserID 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
}

// PhotosUploadContactProfilePhotoRequestTypeID is TL type id of PhotosUploadContactProfilePhotoRequest.
const PhotosUploadContactProfilePhotoRequestTypeID = 0xe14c4a71

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

func ( *PhotosUploadContactProfilePhotoRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Suggest == false) {
		return false
	}
	if !(.Save == false) {
		return false
	}
	if !(.UserID == 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 ( *PhotosUploadContactProfilePhotoRequest) () string {
	if  == nil {
		return "PhotosUploadContactProfilePhotoRequest(nil)"
	}
	type  PhotosUploadContactProfilePhotoRequest
	return fmt.Sprintf("PhotosUploadContactProfilePhotoRequest%+v", (*))
}

// FillFrom fills PhotosUploadContactProfilePhotoRequest from given interface.
func ( *PhotosUploadContactProfilePhotoRequest) ( interface {
	() ( bool)
	() ( bool)
	() ( InputUserClass)
	() ( InputFileClass,  bool)
	() ( InputFileClass,  bool)
	() ( float64,  bool)
	() ( VideoSizeClass,  bool)
}) {
	.Suggest = .()
	.Save = .()
	.UserID = .()
	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 (*PhotosUploadContactProfilePhotoRequest) () uint32 {
	return PhotosUploadContactProfilePhotoRequestTypeID
}

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

// TypeInfo returns info about TL type.
func ( *PhotosUploadContactProfilePhotoRequest) () tdp.Type {
	 := tdp.Type{
		Name: "photos.uploadContactProfilePhoto",
		ID:   PhotosUploadContactProfilePhotoRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Suggest",
			SchemaName: "suggest",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Save",
			SchemaName: "save",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "UserID",
			SchemaName: "user_id",
		},
		{
			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(5),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *PhotosUploadContactProfilePhotoRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode photos.uploadContactProfilePhoto#e14c4a71 as nil")
	}
	.PutID(PhotosUploadContactProfilePhotoRequestTypeID)
	return .EncodeBare()
}

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

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

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

// SetSuggest sets value of Suggest conditional field.
func ( *PhotosUploadContactProfilePhotoRequest) ( bool) {
	if  {
		.Flags.Set(3)
		.Suggest = true
	} else {
		.Flags.Unset(3)
		.Suggest = false
	}
}

// GetSuggest returns value of Suggest conditional field.
func ( *PhotosUploadContactProfilePhotoRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(3)
}

// SetSave sets value of Save conditional field.
func ( *PhotosUploadContactProfilePhotoRequest) ( bool) {
	if  {
		.Flags.Set(4)
		.Save = true
	} else {
		.Flags.Unset(4)
		.Save = false
	}
}

// GetSave returns value of Save conditional field.
func ( *PhotosUploadContactProfilePhotoRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(4)
}

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

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

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

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

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

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

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

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

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

// PhotosUploadContactProfilePhoto invokes method photos.uploadContactProfilePhoto#e14c4a71 returning error if any.
// Upload a custom profile picture for a contact, or suggest a new profile picture to a
// contact.
// The file, video and video_emoji_markup flags are mutually exclusive.
//
// Possible errors:
//
//	400 USER_ID_INVALID: The provided user ID is invalid.
//
// See https://core.telegram.org/method/photos.uploadContactProfilePhoto for reference.
// Can be used by bots.
func ( *Client) ( context.Context,  *PhotosUploadContactProfilePhotoRequest) (*PhotosPhoto, error) {
	var  PhotosPhoto

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