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 SavedPhoneContact struct {
Phone string
FirstName string
LastName string
Date int
}
const SavedPhoneContactTypeID = 0x1142bd56
var (
_ bin .Encoder = &SavedPhoneContact {}
_ bin .Decoder = &SavedPhoneContact {}
_ bin .BareEncoder = &SavedPhoneContact {}
_ bin .BareDecoder = &SavedPhoneContact {}
)
func (s *SavedPhoneContact ) Zero () bool {
if s == nil {
return true
}
if !(s .Phone == "" ) {
return false
}
if !(s .FirstName == "" ) {
return false
}
if !(s .LastName == "" ) {
return false
}
if !(s .Date == 0 ) {
return false
}
return true
}
func (s *SavedPhoneContact ) String () string {
if s == nil {
return "SavedPhoneContact(nil)"
}
type Alias SavedPhoneContact
return fmt .Sprintf ("SavedPhoneContact%+v" , Alias (*s ))
}
func (s *SavedPhoneContact ) FillFrom (from interface {
GetPhone () (value string )
GetFirstName () (value string )
GetLastName () (value string )
GetDate () (value int )
}) {
s .Phone = from .GetPhone ()
s .FirstName = from .GetFirstName ()
s .LastName = from .GetLastName ()
s .Date = from .GetDate ()
}
func (*SavedPhoneContact ) TypeID () uint32 {
return SavedPhoneContactTypeID
}
func (*SavedPhoneContact ) TypeName () string {
return "savedPhoneContact"
}
func (s *SavedPhoneContact ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "savedPhoneContact" ,
ID : SavedPhoneContactTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Phone" ,
SchemaName : "phone" ,
},
{
Name : "FirstName" ,
SchemaName : "first_name" ,
},
{
Name : "LastName" ,
SchemaName : "last_name" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (s *SavedPhoneContact ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode savedPhoneContact#1142bd56 as nil" )
}
b .PutID (SavedPhoneContactTypeID )
return s .EncodeBare (b )
}
func (s *SavedPhoneContact ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode savedPhoneContact#1142bd56 as nil" )
}
b .PutString (s .Phone )
b .PutString (s .FirstName )
b .PutString (s .LastName )
b .PutInt (s .Date )
return nil
}
func (s *SavedPhoneContact ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode savedPhoneContact#1142bd56 to nil" )
}
if err := b .ConsumeID (SavedPhoneContactTypeID ); err != nil {
return fmt .Errorf ("unable to decode savedPhoneContact#1142bd56: %w" , err )
}
return s .DecodeBare (b )
}
func (s *SavedPhoneContact ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode savedPhoneContact#1142bd56 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode savedPhoneContact#1142bd56: field phone: %w" , err )
}
s .Phone = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode savedPhoneContact#1142bd56: field first_name: %w" , err )
}
s .FirstName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode savedPhoneContact#1142bd56: field last_name: %w" , err )
}
s .LastName = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode savedPhoneContact#1142bd56: field date: %w" , err )
}
s .Date = value
}
return nil
}
func (s *SavedPhoneContact ) GetPhone () (value string ) {
if s == nil {
return
}
return s .Phone
}
func (s *SavedPhoneContact ) GetFirstName () (value string ) {
if s == nil {
return
}
return s .FirstName
}
func (s *SavedPhoneContact ) GetLastName () (value string ) {
if s == nil {
return
}
return s .LastName
}
func (s *SavedPhoneContact ) GetDate () (value int ) {
if s == nil {
return
}
return s .Date
}
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 .