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

// AccountSaveSecureValueRequest represents TL type `account.saveSecureValue#899fe31d`.
// Securely save Telegram Passport¹ document, for more info see the passport docs »²
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#encryption
//
// See https://core.telegram.org/method/account.saveSecureValue for reference.
type AccountSaveSecureValueRequest struct {
	// Secure value, for more info see the passport docs »¹
	//
	// Links:
	//  1) https://core.telegram.org/passport/encryption#encryption
	Value InputSecureValue
	// Passport secret hash, for more info see the passport docs »¹
	//
	// Links:
	//  1) https://core.telegram.org/passport/encryption#encryption
	SecureSecretID int64
}

// AccountSaveSecureValueRequestTypeID is TL type id of AccountSaveSecureValueRequest.
const AccountSaveSecureValueRequestTypeID = 0x899fe31d

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

func ( *AccountSaveSecureValueRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Value.Zero()) {
		return false
	}
	if !(.SecureSecretID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountSaveSecureValueRequest from given interface.
func ( *AccountSaveSecureValueRequest) ( interface {
	() ( InputSecureValue)
	() ( int64)
}) {
	.Value = .()
	.SecureSecretID = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountSaveSecureValueRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.saveSecureValue",
		ID:   AccountSaveSecureValueRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Value",
			SchemaName: "value",
		},
		{
			Name:       "SecureSecretID",
			SchemaName: "secure_secret_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountSaveSecureValueRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveSecureValue#899fe31d as nil")
	}
	.PutID(AccountSaveSecureValueRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountSaveSecureValueRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.saveSecureValue#899fe31d as nil")
	}
	if  := .Value.Encode();  != nil {
		return fmt.Errorf("unable to encode account.saveSecureValue#899fe31d: field value: %w", )
	}
	.PutLong(.SecureSecretID)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountSaveSecureValueRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.saveSecureValue#899fe31d to nil")
	}
	{
		if  := .Value.Decode();  != nil {
			return fmt.Errorf("unable to decode account.saveSecureValue#899fe31d: field value: %w", )
		}
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode account.saveSecureValue#899fe31d: field secure_secret_id: %w", )
		}
		.SecureSecretID = 
	}
	return nil
}

// GetValue returns value of Value field.
func ( *AccountSaveSecureValueRequest) () ( InputSecureValue) {
	if  == nil {
		return
	}
	return .Value
}

// GetSecureSecretID returns value of SecureSecretID field.
func ( *AccountSaveSecureValueRequest) () ( int64) {
	if  == nil {
		return
	}
	return .SecureSecretID
}

// AccountSaveSecureValue invokes method account.saveSecureValue#899fe31d returning error if any.
// Securely save Telegram Passport¹ document, for more info see the passport docs »²
//
// Links:
//  1. https://core.telegram.org/passport
//  2. https://core.telegram.org/passport/encryption#encryption
//
// Possible errors:
//
//	400 PASSWORD_REQUIRED: A 2FA password must be configured to use Telegram Passport.
//
// See https://core.telegram.org/method/account.saveSecureValue for reference.
func ( *Client) ( context.Context,  *AccountSaveSecureValueRequest) (*SecureValue, error) {
	var  SecureValue

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