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

// AccountUploadRingtoneRequest represents TL type `account.uploadRingtone#831a83a2`.
// Upload notification sound, use account.saveRingtoneĀ¹ to convert it and add it to the
// list of saved notification sounds.
//
// Links:
//  1. https://core.telegram.org/method/account.saveRingtone
//
// See https://core.telegram.org/method/account.uploadRingtone for reference.
type AccountUploadRingtoneRequest struct {
	// Notification sound
	File InputFileClass
	// File name
	FileName string
	// MIME type of file
	MimeType string
}

// AccountUploadRingtoneRequestTypeID is TL type id of AccountUploadRingtoneRequest.
const AccountUploadRingtoneRequestTypeID = 0x831a83a2

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

func ( *AccountUploadRingtoneRequest) () bool {
	if  == nil {
		return true
	}
	if !(.File == nil) {
		return false
	}
	if !(.FileName == "") {
		return false
	}
	if !(.MimeType == "") {
		return false
	}

	return true
}

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

// FillFrom fills AccountUploadRingtoneRequest from given interface.
func ( *AccountUploadRingtoneRequest) ( interface {
	() ( InputFileClass)
	() ( string)
	() ( string)
}) {
	.File = .()
	.FileName = .()
	.MimeType = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountUploadRingtoneRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.uploadRingtone",
		ID:   AccountUploadRingtoneRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "File",
			SchemaName: "file",
		},
		{
			Name:       "FileName",
			SchemaName: "file_name",
		},
		{
			Name:       "MimeType",
			SchemaName: "mime_type",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountUploadRingtoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.uploadRingtone#831a83a2 as nil")
	}
	.PutID(AccountUploadRingtoneRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountUploadRingtoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.uploadRingtone#831a83a2 as nil")
	}
	if .File == nil {
		return fmt.Errorf("unable to encode account.uploadRingtone#831a83a2: field file is nil")
	}
	if  := .File.Encode();  != nil {
		return fmt.Errorf("unable to encode account.uploadRingtone#831a83a2: field file: %w", )
	}
	.PutString(.FileName)
	.PutString(.MimeType)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountUploadRingtoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.uploadRingtone#831a83a2 to nil")
	}
	{
		,  := DecodeInputFile()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: field file: %w", )
		}
		.File = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: field file_name: %w", )
		}
		.FileName = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode account.uploadRingtone#831a83a2: field mime_type: %w", )
		}
		.MimeType = 
	}
	return nil
}

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

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

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

// AccountUploadRingtone invokes method account.uploadRingtone#831a83a2 returning error if any.
// Upload notification sound, use account.saveRingtoneĀ¹ to convert it and add it to the
// list of saved notification sounds.
//
// Links:
//  1. https://core.telegram.org/method/account.saveRingtone
//
// See https://core.telegram.org/method/account.uploadRingtone for reference.
func ( *Client) ( context.Context,  *AccountUploadRingtoneRequest) (DocumentClass, error) {
	var  DocumentBox

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