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

// WalletReplaceWalletRequest represents TL type `wallet.replaceWallet#d8c72eec`.
//
// See https://core.telegram.org/method/wallet.replaceWallet for reference.
type WalletReplaceWalletRequest struct {
	// Flags field of WalletReplaceWalletRequest.
	Flags bin.Fields
	// Wallet field of WalletReplaceWalletRequest.
	Wallet InputWalletReplacementClass
	// Password field of WalletReplaceWalletRequest.
	//
	// Use SetPassword and GetPassword helpers.
	Password InputCheckPasswordSRPClass
}

// WalletReplaceWalletRequestTypeID is TL type id of WalletReplaceWalletRequest.
const WalletReplaceWalletRequestTypeID = 0xd8c72eec

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

func ( *WalletReplaceWalletRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Wallet == nil) {
		return false
	}
	if !(.Password == nil) {
		return false
	}

	return true
}

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

// FillFrom fills WalletReplaceWalletRequest from given interface.
func ( *WalletReplaceWalletRequest) ( interface {
	() ( InputWalletReplacementClass)
	() ( InputCheckPasswordSRPClass,  bool)
}) {
	.Wallet = .()
	if ,  := .();  {
		.Password = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*WalletReplaceWalletRequest) () string {
	return "wallet.replaceWallet"
}

// TypeInfo returns info about TL type.
func ( *WalletReplaceWalletRequest) () tdp.Type {
	 := tdp.Type{
		Name: "wallet.replaceWallet",
		ID:   WalletReplaceWalletRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Wallet",
			SchemaName: "wallet",
		},
		{
			Name:       "Password",
			SchemaName: "password",
			Null:       !.Flags.Has(0),
		},
	}
	return 
}

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

// Encode implements bin.Encoder.
func ( *WalletReplaceWalletRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.replaceWallet#d8c72eec as nil")
	}
	.PutID(WalletReplaceWalletRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WalletReplaceWalletRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.replaceWallet#d8c72eec as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode wallet.replaceWallet#d8c72eec: field flags: %w", )
	}
	if .Wallet == nil {
		return fmt.Errorf("unable to encode wallet.replaceWallet#d8c72eec: field wallet is nil")
	}
	if  := .Wallet.Encode();  != nil {
		return fmt.Errorf("unable to encode wallet.replaceWallet#d8c72eec: field wallet: %w", )
	}
	if .Flags.Has(0) {
		if .Password == nil {
			return fmt.Errorf("unable to encode wallet.replaceWallet#d8c72eec: field password is nil")
		}
		if  := .Password.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.replaceWallet#d8c72eec: field password: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *WalletReplaceWalletRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.replaceWallet#d8c72eec to nil")
	}
	if  := .ConsumeID(WalletReplaceWalletRequestTypeID);  != nil {
		return fmt.Errorf("unable to decode wallet.replaceWallet#d8c72eec: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *WalletReplaceWalletRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.replaceWallet#d8c72eec to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode wallet.replaceWallet#d8c72eec: field flags: %w", )
		}
	}
	{
		,  := DecodeInputWalletReplacement()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.replaceWallet#d8c72eec: field wallet: %w", )
		}
		.Wallet = 
	}
	if .Flags.Has(0) {
		,  := DecodeInputCheckPasswordSRP()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.replaceWallet#d8c72eec: field password: %w", )
		}
		.Password = 
	}
	return nil
}

// GetWallet returns value of Wallet field.
func ( *WalletReplaceWalletRequest) () ( InputWalletReplacementClass) {
	if  == nil {
		return
	}
	return .Wallet
}

// SetPassword sets value of Password conditional field.
func ( *WalletReplaceWalletRequest) ( InputCheckPasswordSRPClass) {
	.Flags.Set(0)
	.Password = 
}

// GetPassword returns value of Password conditional field and
// boolean which is true if field was set.
func ( *WalletReplaceWalletRequest) () ( InputCheckPasswordSRPClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Password, true
}

// GetPasswordAsNotEmpty returns mapped value of Password conditional field and
// boolean which is true if field was set.
func ( *WalletReplaceWalletRequest) () (*InputCheckPasswordSRP, bool) {
	if ,  := .GetPassword();  {
		return .AsNotEmpty()
	}
	return nil, false
}

// WalletReplaceWallet invokes method wallet.replaceWallet#d8c72eec returning error if any.
//
// See https://core.telegram.org/method/wallet.replaceWallet for reference.
func ( *Client) ( context.Context,  *WalletReplaceWalletRequest) (WalletStateClass, error) {
	var  WalletStateBox

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