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

// AccountUploadWallPaperRequest represents TL type `account.uploadWallPaper#e39a8f03`.
// Create and upload a new wallpaper¹
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// See https://core.telegram.org/method/account.uploadWallPaper for reference.
type AccountUploadWallPaperRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Set this flag when uploading wallpapers to be passed to messages.setChatWallPaper¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/messages.setChatWallPaper
	ForChat bool
	// The JPG/PNG wallpaper
	File InputFileClass
	// MIME type of uploaded wallpaper
	MimeType string
	// Wallpaper settings
	Settings WallPaperSettings
}

// AccountUploadWallPaperRequestTypeID is TL type id of AccountUploadWallPaperRequest.
const AccountUploadWallPaperRequestTypeID = 0xe39a8f03

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

func ( *AccountUploadWallPaperRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ForChat == false) {
		return false
	}
	if !(.File == nil) {
		return false
	}
	if !(.MimeType == "") {
		return false
	}
	if !(.Settings.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills AccountUploadWallPaperRequest from given interface.
func ( *AccountUploadWallPaperRequest) ( interface {
	() ( bool)
	() ( InputFileClass)
	() ( string)
	() ( WallPaperSettings)
}) {
	.ForChat = .()
	.File = .()
	.MimeType = .()
	.Settings = .()
}

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

// TypeName returns name of type in TL schema.
func (*AccountUploadWallPaperRequest) () string {
	return "account.uploadWallPaper"
}

// TypeInfo returns info about TL type.
func ( *AccountUploadWallPaperRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.uploadWallPaper",
		ID:   AccountUploadWallPaperRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ForChat",
			SchemaName: "for_chat",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "File",
			SchemaName: "file",
		},
		{
			Name:       "MimeType",
			SchemaName: "mime_type",
		},
		{
			Name:       "Settings",
			SchemaName: "settings",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountUploadWallPaperRequest) () {
	if !(.ForChat == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountUploadWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.uploadWallPaper#e39a8f03 as nil")
	}
	.PutID(AccountUploadWallPaperRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUploadWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.uploadWallPaper#e39a8f03 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.uploadWallPaper#e39a8f03: field flags: %w", )
	}
	if .File == nil {
		return fmt.Errorf("unable to encode account.uploadWallPaper#e39a8f03: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode account.uploadWallPaper#e39a8f03: field file: %w", )
	}
	.PutString(.MimeType)
	if  := .Settings.Encode();  != nil {
		return fmt.Errorf("unable to encode account.uploadWallPaper#e39a8f03: field settings: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AccountUploadWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.uploadWallPaper#e39a8f03 to nil")
	}
	if  := .ConsumeID(AccountUploadWallPaperRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode account.uploadWallPaper#e39a8f03: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AccountUploadWallPaperRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.uploadWallPaper#e39a8f03 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.uploadWallPaper#e39a8f03: field flags: %w", )
		}
	}
	.ForChat = .Flags.Has(0)
	{
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadWallPaper#e39a8f03: field file: %w", )
		}
		.File = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadWallPaper#e39a8f03: field mime_type: %w", )
		}
		.MimeType = 
	}
	{
		if  := .Settings.Decode();  != nil {
			return fmt.Errorf("unable to decode account.uploadWallPaper#e39a8f03: field settings: %w", )
		}
	}
	return nil
}

// SetForChat sets value of ForChat conditional field.
func ( *AccountUploadWallPaperRequest) ( bool) {
	if  {
		.Flags.Set(0)
		.ForChat = true
	} else {
		.Flags.Unset(0)
		.ForChat = false
	}
}

// GetForChat returns value of ForChat conditional field.
func ( *AccountUploadWallPaperRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetFile returns value of File field.
func ( *AccountUploadWallPaperRequest) () ( InputFileClass) {
	if  == nil {
		return
	}
	return .File
}

// GetMimeType returns value of MimeType field.
func ( *AccountUploadWallPaperRequest) () ( string) {
	if  == nil {
		return
	}
	return .MimeType
}

// GetSettings returns value of Settings field.
func ( *AccountUploadWallPaperRequest) () ( WallPaperSettings) {
	if  == nil {
		return
	}
	return .Settings
}

// AccountUploadWallPaper invokes method account.uploadWallPaper#e39a8f03 returning error if any.
// Create and upload a new wallpaper¹
//
// Links:
//  1. https://core.telegram.org/api/wallpapers
//
// Possible errors:
//
//	400 WALLPAPER_FILE_INVALID: The specified wallpaper file is invalid.
//	400 WALLPAPER_MIME_INVALID: The specified wallpaper MIME type is invalid.
//
// See https://core.telegram.org/method/account.uploadWallPaper for reference.
func ( *Client) ( context.Context,  *AccountUploadWallPaperRequest) (WallPaperClass, error) {
	var  WallPaperBox

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