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

// AccountGetTmpPasswordRequest represents TL type `account.getTmpPassword#449e0b51`.
// Get temporary payment password
//
// See https://core.telegram.org/method/account.getTmpPassword for reference.
type AccountGetTmpPasswordRequest struct {
	// SRP password parameters
	Password InputCheckPasswordSRPClass
	// Time during which the temporary password will be valid, in seconds; should be between
	// 60 and 86400
	Period int
}

// AccountGetTmpPasswordRequestTypeID is TL type id of AccountGetTmpPasswordRequest.
const AccountGetTmpPasswordRequestTypeID = 0x449e0b51

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

func ( *AccountGetTmpPasswordRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Password == nil) {
		return false
	}
	if !(.Period == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AccountGetTmpPasswordRequest from given interface.
func ( *AccountGetTmpPasswordRequest) ( interface {
	() ( InputCheckPasswordSRPClass)
	() ( int)
}) {
	.Password = .()
	.Period = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *AccountGetTmpPasswordRequest) () tdp.Type {
	 := tdp.Type{
		Name: "account.getTmpPassword",
		ID:   AccountGetTmpPasswordRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Password",
			SchemaName: "password",
		},
		{
			Name:       "Period",
			SchemaName: "period",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AccountGetTmpPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.getTmpPassword#449e0b51 as nil")
	}
	.PutID(AccountGetTmpPasswordRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AccountGetTmpPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode account.getTmpPassword#449e0b51 as nil")
	}
	if .Password == nil {
		return fmt.Errorf("unable to encode account.getTmpPassword#449e0b51: field password is nil")
	}
	if  := .Password.Encode();  != nil {
		return fmt.Errorf("unable to encode account.getTmpPassword#449e0b51: field password: %w", )
	}
	.PutInt(.Period)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AccountGetTmpPasswordRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode account.getTmpPassword#449e0b51 to nil")
	}
	{
		,  := DecodeInputCheckPasswordSRP()
		if  != nil {
			return fmt.Errorf("unable to decode account.getTmpPassword#449e0b51: field password: %w", )
		}
		.Password = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode account.getTmpPassword#449e0b51: field period: %w", )
		}
		.Period = 
	}
	return nil
}

// GetPassword returns value of Password field.
func ( *AccountGetTmpPasswordRequest) () ( InputCheckPasswordSRPClass) {
	if  == nil {
		return
	}
	return .Password
}

// GetPeriod returns value of Period field.
func ( *AccountGetTmpPasswordRequest) () ( int) {
	if  == nil {
		return
	}
	return .Period
}

// GetPasswordAsNotEmpty returns mapped value of Password field.
func ( *AccountGetTmpPasswordRequest) () (*InputCheckPasswordSRP, bool) {
	return .Password.AsNotEmpty()
}

// AccountGetTmpPassword invokes method account.getTmpPassword#449e0b51 returning error if any.
// Get temporary payment password
//
// Possible errors:
//
//	400 PASSWORD_HASH_INVALID: The provided password hash is invalid.
//	400 TMP_PASSWORD_DISABLED: The temporary password is disabled.
//
// See https://core.telegram.org/method/account.getTmpPassword for reference.
func ( *Client) ( context.Context,  *AccountGetTmpPasswordRequest) (*AccountTmpPassword, error) {
	var  AccountTmpPassword

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