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 WalletTransactions struct {
Flags bin .Fields
Balance int64
Transactions []WalletTransaction
NextOffset string
Chats []ChatClass
Users []UserClass
}
const WalletTransactionsTypeID = 0x4322d5a5
var (
_ bin .Encoder = &WalletTransactions {}
_ bin .Decoder = &WalletTransactions {}
_ bin .BareEncoder = &WalletTransactions {}
_ bin .BareDecoder = &WalletTransactions {}
)
func (t *WalletTransactions ) Zero () bool {
if t == nil {
return true
}
if !(t .Flags .Zero ()) {
return false
}
if !(t .Balance == 0 ) {
return false
}
if !(t .Transactions == nil ) {
return false
}
if !(t .NextOffset == "" ) {
return false
}
if !(t .Chats == nil ) {
return false
}
if !(t .Users == nil ) {
return false
}
return true
}
func (t *WalletTransactions ) String () string {
if t == nil {
return "WalletTransactions(nil)"
}
type Alias WalletTransactions
return fmt .Sprintf ("WalletTransactions%+v" , Alias (*t ))
}
func (t *WalletTransactions ) FillFrom (from interface {
GetBalance () (value int64 )
GetTransactions () (value []WalletTransaction )
GetNextOffset () (value string , ok bool )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
t .Balance = from .GetBalance ()
t .Transactions = from .GetTransactions ()
if val , ok := from .GetNextOffset (); ok {
t .NextOffset = val
}
t .Chats = from .GetChats ()
t .Users = from .GetUsers ()
}
func (*WalletTransactions ) TypeID () uint32 {
return WalletTransactionsTypeID
}
func (*WalletTransactions ) TypeName () string {
return "wallet.transactions"
}
func (t *WalletTransactions ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "wallet.transactions" ,
ID : WalletTransactionsTypeID ,
}
if t == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Balance" ,
SchemaName : "balance" ,
},
{
Name : "Transactions" ,
SchemaName : "transactions" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !t .Flags .Has (0 ),
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (t *WalletTransactions ) SetFlags () {
if !(t .NextOffset == "" ) {
t .Flags .Set (0 )
}
}
func (t *WalletTransactions ) Encode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode wallet.transactions#4322d5a5 as nil" )
}
b .PutID (WalletTransactionsTypeID )
return t .EncodeBare (b )
}
func (t *WalletTransactions ) EncodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't encode wallet.transactions#4322d5a5 as nil" )
}
t .SetFlags ()
if err := t .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.transactions#4322d5a5: field flags: %w" , err )
}
b .PutLong (t .Balance )
b .PutVectorHeader (len (t .Transactions ))
for idx , v := range t .Transactions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.transactions#4322d5a5: field transactions element with index %d: %w" , idx , err )
}
}
if t .Flags .Has (0 ) {
b .PutString (t .NextOffset )
}
b .PutVectorHeader (len (t .Chats ))
for idx , v := range t .Chats {
if v == nil {
return fmt .Errorf ("unable to encode wallet.transactions#4322d5a5: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.transactions#4322d5a5: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (t .Users ))
for idx , v := range t .Users {
if v == nil {
return fmt .Errorf ("unable to encode wallet.transactions#4322d5a5: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode wallet.transactions#4322d5a5: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (t *WalletTransactions ) Decode (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode wallet.transactions#4322d5a5 to nil" )
}
if err := b .ConsumeID (WalletTransactionsTypeID ); err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: %w" , err )
}
return t .DecodeBare (b )
}
func (t *WalletTransactions ) DecodeBare (b *bin .Buffer ) error {
if t == nil {
return fmt .Errorf ("can't decode wallet.transactions#4322d5a5 to nil" )
}
{
if err := t .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field balance: %w" , err )
}
t .Balance = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field transactions: %w" , err )
}
if headerLen > 0 {
t .Transactions = make ([]WalletTransaction , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value WalletTransaction
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field transactions: %w" , err )
}
t .Transactions = append (t .Transactions , value )
}
}
if t .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field next_offset: %w" , err )
}
t .NextOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field chats: %w" , err )
}
if headerLen > 0 {
t .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field chats: %w" , err )
}
t .Chats = append (t .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field users: %w" , err )
}
if headerLen > 0 {
t .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode wallet.transactions#4322d5a5: field users: %w" , err )
}
t .Users = append (t .Users , value )
}
}
return nil
}
func (t *WalletTransactions ) GetBalance () (value int64 ) {
if t == nil {
return
}
return t .Balance
}
func (t *WalletTransactions ) GetTransactions () (value []WalletTransaction ) {
if t == nil {
return
}
return t .Transactions
}
func (t *WalletTransactions ) SetNextOffset (value string ) {
t .Flags .Set (0 )
t .NextOffset = value
}
func (t *WalletTransactions ) GetNextOffset () (value string , ok bool ) {
if t == nil {
return
}
if !t .Flags .Has (0 ) {
return value , false
}
return t .NextOffset , true
}
func (t *WalletTransactions ) GetChats () (value []ChatClass ) {
if t == nil {
return
}
return t .Chats
}
func (t *WalletTransactions ) GetUsers () (value []UserClass ) {
if t == nil {
return
}
return t .Users
}
func (t *WalletTransactions ) MapChats () (value ChatClassArray ) {
return ChatClassArray (t .Chats )
}
func (t *WalletTransactions ) MapUsers () (value UserClassArray ) {
return UserClassArray (t .Users )
}
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 .