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

// WalletExistingBalance represents TL type `wallet.existingBalance#bde90a8d`.
//
// See https://core.telegram.org/constructor/wallet.existingBalance for reference.
type WalletExistingBalance struct {
	// Flags field of WalletExistingBalance.
	Flags bin.Fields
	// HasBalance field of WalletExistingBalance.
	HasBalance bool
	// URL field of WalletExistingBalance.
	URL string
}

// WalletExistingBalanceTypeID is TL type id of WalletExistingBalance.
const WalletExistingBalanceTypeID = 0xbde90a8d

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

func ( *WalletExistingBalance) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.HasBalance == false) {
		return false
	}
	if !(.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills WalletExistingBalance from given interface.
func ( *WalletExistingBalance) ( interface {
	() ( bool)
	() ( string)
}) {
	.HasBalance = .()
	.URL = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *WalletExistingBalance) () tdp.Type {
	 := tdp.Type{
		Name: "wallet.existingBalance",
		ID:   WalletExistingBalanceTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "HasBalance",
			SchemaName: "has_balance",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *WalletExistingBalance) () {
	if !(.HasBalance == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *WalletExistingBalance) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.existingBalance#bde90a8d as nil")
	}
	.PutID(WalletExistingBalanceTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WalletExistingBalance) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.existingBalance#bde90a8d as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode wallet.existingBalance#bde90a8d: field flags: %w", )
	}
	.PutString(.URL)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *WalletExistingBalance) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.existingBalance#bde90a8d to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode wallet.existingBalance#bde90a8d: field flags: %w", )
		}
	}
	.HasBalance = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.existingBalance#bde90a8d: field url: %w", )
		}
		.URL = 
	}
	return nil
}

// SetHasBalance sets value of HasBalance conditional field.
func ( *WalletExistingBalance) ( bool) {
	if  {
		.Flags.Set(0)
		.HasBalance = true
	} else {
		.Flags.Unset(0)
		.HasBalance = false
	}
}

// GetHasBalance returns value of HasBalance conditional field.
func ( *WalletExistingBalance) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetURL returns value of URL field.
func ( *WalletExistingBalance) () ( string) {
	if  == nil {
		return
	}
	return .URL
}