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

// AccountSaveRingtoneRequest represents TL type `account.saveRingtone#3dea5b03`.
// Save or remove saved notification sound.
// If the notification sound is already in MP3 format, account.savedRingtone¹ will be
// returned.
// Otherwise, it will be automatically converted and a account.savedRingtoneConverted²
// will be returned, containing a new document³ object that should be used to refer to
// the ringtone from now on (ie when deleting it using the unsave parameter, or when
// downloading it).
//
// Links:
//  1. https://core.telegram.org/constructor/account.savedRingtone
//  2. https://core.telegram.org/constructor/account.savedRingtoneConverted
//  3. https://core.telegram.org/constructor/document
//
// See https://core.telegram.org/method/account.saveRingtone for reference.
type AccountSaveRingtoneRequest struct {
	// Notification sound uploaded using account.uploadRingtone¹
	//
	// Links:
	//  1) https://core.telegram.org/method/account.uploadRingtone
	ID InputDocumentClass
	// Whether to add or delete the notification sound
	Unsave bool
}

// AccountSaveRingtoneRequestTypeID is TL type id of AccountSaveRingtoneRequest.
const AccountSaveRingtoneRequestTypeID = 0x3dea5b03

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

func ( *AccountSaveRingtoneRequest) () bool {
	if  == nil {
		return true
	}
	if !(.ID == nil) {
		return false
	}
	if !(.Unsave == false) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSaveRingtoneRequest from given interface.
func ( *AccountSaveRingtoneRequest) ( interface {
	() ( InputDocumentClass)
	() ( bool)
}) {
	.ID = .()
	.Unsave = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSaveRingtoneRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.saveRingtone",
		ID:   AccountSaveRingtoneRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Unsave",
			SchemaName: "unsave",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSaveRingtoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveRingtone#3dea5b03 as nil")
	}
	.PutID(AccountSaveRingtoneRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSaveRingtoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveRingtone#3dea5b03 as nil")
	}
	if .ID == nil {
		return fmt.Errorf("unable to encode account.saveRingtone#3dea5b03: field id is nil")
	}
	if  := .ID.Encode();  != nil {
		return fmt.Errorf("unable to encode account.saveRingtone#3dea5b03: field id: %w", )
	}
	.PutBool(.Unsave)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSaveRingtoneRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.saveRingtone#3dea5b03 to nil")
	}
	{
		,  := DecodeInputDocument()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Bool()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveRingtone#3dea5b03: field unsave: %w", )
		}
		.Unsave = 
	}
	return nil
}

// GetID returns value of ID field.
func ( *AccountSaveRingtoneRequest) () ( InputDocumentClass) {
	if  == nil {
		return
	}
	return .ID
}

// GetUnsave returns value of Unsave field.
func ( *AccountSaveRingtoneRequest) () ( bool) {
	if  == nil {
		return
	}
	return .Unsave
}

// GetIDAsNotEmpty returns mapped value of ID field.
func ( *AccountSaveRingtoneRequest) () (*InputDocument, bool) {
	return .ID.AsNotEmpty()
}

// AccountSaveRingtone invokes method account.saveRingtone#3dea5b03 returning error if any.
// Save or remove saved notification sound.
// If the notification sound is already in MP3 format, account.savedRingtone¹ will be
// returned.
// Otherwise, it will be automatically converted and a account.savedRingtoneConverted²
// will be returned, containing a new document³ object that should be used to refer to
// the ringtone from now on (ie when deleting it using the unsave parameter, or when
// downloading it).
//
// Links:
//  1. https://core.telegram.org/constructor/account.savedRingtone
//  2. https://core.telegram.org/constructor/account.savedRingtoneConverted
//  3. https://core.telegram.org/constructor/document
//
// See https://core.telegram.org/method/account.saveRingtone for reference.
func ( *Client) ( context.Context,  *AccountSaveRingtoneRequest) (AccountSavedRingtoneClass, error) {
	var  AccountSavedRingtoneBox

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