package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdjson"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
var (
_ = bin .Buffer {}
_ = context .Background ()
_ = fmt .Stringer (nil )
_ = strings .Builder {}
_ = errors .Is
_ = multierr .AppendInto
_ = sort .Ints
_ = tdp .Format
_ = tgerr .Error {}
_ = tdjson .Encoder {}
)
type WalletExistingBalance struct {
Flags bin .Fields
HasBalance bool
URL string
}
const WalletExistingBalanceTypeID = 0xbde90a8d
var (
_ bin .Encoder = &WalletExistingBalance {}
_ bin .Decoder = &WalletExistingBalance {}
_ bin .BareEncoder = &WalletExistingBalance {}
_ bin .BareDecoder = &WalletExistingBalance {}
)
func (e *WalletExistingBalance ) Zero () bool {
if e == nil {
return true
}
if !(e .Flags .Zero ()) {
return false
}
if !(e .HasBalance == false ) {
return false
}
if !(e .URL == "" ) {
return false
}
return true
}
func (e *WalletExistingBalance ) String () string {
if e == nil {
return "WalletExistingBalance(nil)"
}
type Alias WalletExistingBalance
return fmt .Sprintf ("WalletExistingBalance%+v" , Alias (*e ))
}
func (e *WalletExistingBalance ) FillFrom (from interface {
GetHasBalance () (value bool )
GetURL () (value string )
}) {
e .HasBalance = from .GetHasBalance ()
e .URL = from .GetURL ()
}
func (*WalletExistingBalance ) TypeID () uint32 {
return WalletExistingBalanceTypeID
}
func (*WalletExistingBalance ) TypeName () string {
return "wallet.existingBalance"
}
func (e *WalletExistingBalance ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallet.existingBalance" ,
ID : WalletExistingBalanceTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "HasBalance" ,
SchemaName : "has_balance" ,
Null : !e .Flags .Has (0 ),
},
{
Name : "URL" ,
SchemaName : "url" ,
},
}
return typ
}
func (e *WalletExistingBalance ) SetFlags () {
if !(e .HasBalance == false ) {
e .Flags .Set (0 )
}
}
func (e *WalletExistingBalance ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode wallet.existingBalance#bde90a8d as nil" )
}
b .PutID (WalletExistingBalanceTypeID )
return e .EncodeBare (b )
}
func (e *WalletExistingBalance ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode wallet.existingBalance#bde90a8d as nil" )
}
e .SetFlags ()
if err := e .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.existingBalance#bde90a8d: field flags: %w" , err )
}
b .PutString (e .URL )
return nil
}
func (e *WalletExistingBalance ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode wallet.existingBalance#bde90a8d to nil" )
}
if err := b .ConsumeID (WalletExistingBalanceTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallet.existingBalance#bde90a8d: %w" , err )
}
return e .DecodeBare (b )
}
func (e *WalletExistingBalance ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode wallet.existingBalance#bde90a8d to nil" )
}
{
if err := e .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.existingBalance#bde90a8d: field flags: %w" , err )
}
}
e .HasBalance = e .Flags .Has (0 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.existingBalance#bde90a8d: field url: %w" , err )
}
e .URL = value
}
return nil
}
func (e *WalletExistingBalance ) SetHasBalance (value bool ) {
if value {
e .Flags .Set (0 )
e .HasBalance = true
} else {
e .Flags .Unset (0 )
e .HasBalance = false
}
}
func (e *WalletExistingBalance ) GetHasBalance () (value bool ) {
if e == nil {
return
}
return e .Flags .Has (0 )
}
func (e *WalletExistingBalance ) GetURL () (value string ) {
if e == nil {
return
}
return e .URL
}
The pages are generated with Golds v0.8.7 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .