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 PaymentsSavedInfo struct {
Flags bin .Fields
HasSavedCredentials bool
SavedInfo PaymentRequestedInfo
}
const PaymentsSavedInfoTypeID = 0xfb8fe43c
var (
_ bin .Encoder = &PaymentsSavedInfo {}
_ bin .Decoder = &PaymentsSavedInfo {}
_ bin .BareEncoder = &PaymentsSavedInfo {}
_ bin .BareDecoder = &PaymentsSavedInfo {}
)
func (s *PaymentsSavedInfo ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .HasSavedCredentials == false ) {
return false
}
if !(s .SavedInfo .Zero ()) {
return false
}
return true
}
func (s *PaymentsSavedInfo ) String () string {
if s == nil {
return "PaymentsSavedInfo(nil)"
}
type Alias PaymentsSavedInfo
return fmt .Sprintf ("PaymentsSavedInfo%+v" , Alias (*s ))
}
func (s *PaymentsSavedInfo ) FillFrom (from interface {
GetHasSavedCredentials () (value bool )
GetSavedInfo () (value PaymentRequestedInfo , ok bool )
}) {
s .HasSavedCredentials = from .GetHasSavedCredentials ()
if val , ok := from .GetSavedInfo (); ok {
s .SavedInfo = val
}
}
func (*PaymentsSavedInfo ) TypeID () uint32 {
return PaymentsSavedInfoTypeID
}
func (*PaymentsSavedInfo ) TypeName () string {
return "payments.savedInfo"
}
func (s *PaymentsSavedInfo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.savedInfo" ,
ID : PaymentsSavedInfoTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "HasSavedCredentials" ,
SchemaName : "has_saved_credentials" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "SavedInfo" ,
SchemaName : "saved_info" ,
Null : !s .Flags .Has (0 ),
},
}
return typ
}
func (s *PaymentsSavedInfo ) SetFlags () {
if !(s .HasSavedCredentials == false ) {
s .Flags .Set (1 )
}
if !(s .SavedInfo .Zero ()) {
s .Flags .Set (0 )
}
}
func (s *PaymentsSavedInfo ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.savedInfo#fb8fe43c as nil" )
}
b .PutID (PaymentsSavedInfoTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsSavedInfo ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.savedInfo#fb8fe43c as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.savedInfo#fb8fe43c: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
if err := s .SavedInfo .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.savedInfo#fb8fe43c: field saved_info: %w" , err )
}
}
return nil
}
func (s *PaymentsSavedInfo ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.savedInfo#fb8fe43c to nil" )
}
if err := b .ConsumeID (PaymentsSavedInfoTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.savedInfo#fb8fe43c: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsSavedInfo ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.savedInfo#fb8fe43c to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.savedInfo#fb8fe43c: field flags: %w" , err )
}
}
s .HasSavedCredentials = s .Flags .Has (1 )
if s .Flags .Has (0 ) {
if err := s .SavedInfo .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.savedInfo#fb8fe43c: field saved_info: %w" , err )
}
}
return nil
}
func (s *PaymentsSavedInfo ) SetHasSavedCredentials (value bool ) {
if value {
s .Flags .Set (1 )
s .HasSavedCredentials = true
} else {
s .Flags .Unset (1 )
s .HasSavedCredentials = false
}
}
func (s *PaymentsSavedInfo ) GetHasSavedCredentials () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *PaymentsSavedInfo ) SetSavedInfo (value PaymentRequestedInfo ) {
s .Flags .Set (0 )
s .SavedInfo = value
}
func (s *PaymentsSavedInfo ) GetSavedInfo () (value PaymentRequestedInfo , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .SavedInfo , true
}
The pages are generated with Golds v0.6.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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .