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

// AccountUploadThemeRequest represents TL type `account.uploadTheme#1c3db333`.
// Upload theme
//
// See https://core.telegram.org/method/account.uploadTheme for reference.
type AccountUploadThemeRequest struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Previously uploadedĀ¹ theme file with platform-specific colors for UI components, can
	// be left unset when creating themes that only modify the wallpaper or accent colors.
	//
	// Links:
	//  1) https://core.telegram.org/api/themes#uploading-theme-files
	File InputFileClass
	// Thumbnail
	//
	// Use SetThumb and GetThumb helpers.
	Thumb InputFileClass
	// File name
	FileName string
	// MIME type, must be application/x-tgtheme-{format}, where format depends on the client
	MimeType string
}

// AccountUploadThemeRequestTypeID is TL type id of AccountUploadThemeRequest.
const AccountUploadThemeRequestTypeID = 0x1c3db333

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

func ( *AccountUploadThemeRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.File == nil) {
		return false
	}
	if !(.Thumb == nil) {
		return false
	}
	if !(.FileName == "") {
		return false
	}
	if !(.MimeType == "") {
		return false
	}

	return true
}

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

// FillFrom fills AccountUploadThemeRequest from given interface.
func ( *AccountUploadThemeRequest) ( interface {
	() ( InputFileClass)
	() ( InputFileClass,  bool)
	() ( string)
	() ( string)
}) {
	.File = .()
	if ,  := .();  {
		.Thumb = 
	}

	.FileName = .()
	.MimeType = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountUploadThemeRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.uploadTheme",
		ID:   AccountUploadThemeRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "File",
			SchemaName: "file",
		},
		{
			Name:       "Thumb",
			SchemaName: "thumb",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "FileName",
			SchemaName: "file_name",
		},
		{
			Name:       "MimeType",
			SchemaName: "mime_type",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AccountUploadThemeRequest) () {
	if !(.Thumb == nil) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *AccountUploadThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.uploadTheme#1c3db333 as nil")
	}
	.PutID(AccountUploadThemeRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUploadThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.uploadTheme#1c3db333 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field flags: %w", )
	}
	if .File == nil {
		return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field file: %w", )
	}
	if .Flags.Has(0) {
		if .Thumb == nil {
			return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field thumb is nil")
		}
		if  := .Thumb.Encode();  != nil {
			return fmt.Errorf("unable to encode account.uploadTheme#1c3db333: field thumb: %w", )
		}
	}
	.PutString(.FileName)
	.PutString(.MimeType)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountUploadThemeRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.uploadTheme#1c3db333 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field flags: %w", )
		}
	}
	{
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field file: %w", )
		}
		.File = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field thumb: %w", )
		}
		.Thumb = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field file_name: %w", )
		}
		.FileName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadTheme#1c3db333: field mime_type: %w", )
		}
		.MimeType = 
	}
	return nil
}

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

// SetThumb sets value of Thumb conditional field.
func ( *AccountUploadThemeRequest) ( InputFileClass) {
	.Flags.Set(0)
	.Thumb = 
}

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

// GetFileName returns value of FileName field.
func ( *AccountUploadThemeRequest) () ( string) {
	if  == nil {
		return
	}
	return .FileName
}

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

// AccountUploadTheme invokes method account.uploadTheme#1c3db333 returning error if any.
// Upload theme
//
// Possible errors:
//
//	400 THEME_FILE_INVALID: Invalid theme file provided.
//
// See https://core.telegram.org/method/account.uploadTheme for reference.
func ( *Client) ( context.Context,  *AccountUploadThemeRequest) (DocumentClass, error) {
	var  DocumentBox

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