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 InputPhoneContact struct {
Flags bin .Fields
ClientID int64
Phone string
FirstName string
LastName string
Note TextWithEntities
}
const InputPhoneContactTypeID = 0x6a1dc4be
var (
_ bin .Encoder = &InputPhoneContact {}
_ bin .Decoder = &InputPhoneContact {}
_ bin .BareEncoder = &InputPhoneContact {}
_ bin .BareDecoder = &InputPhoneContact {}
)
func (i *InputPhoneContact ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .ClientID == 0 ) {
return false
}
if !(i .Phone == "" ) {
return false
}
if !(i .FirstName == "" ) {
return false
}
if !(i .LastName == "" ) {
return false
}
if !(i .Note .Zero ()) {
return false
}
return true
}
func (i *InputPhoneContact ) String () string {
if i == nil {
return "InputPhoneContact(nil)"
}
type Alias InputPhoneContact
return fmt .Sprintf ("InputPhoneContact%+v" , Alias (*i ))
}
func (i *InputPhoneContact ) FillFrom (from interface {
GetClientID () (value int64 )
GetPhone () (value string )
GetFirstName () (value string )
GetLastName () (value string )
GetNote () (value TextWithEntities , ok bool )
}) {
i .ClientID = from .GetClientID ()
i .Phone = from .GetPhone ()
i .FirstName = from .GetFirstName ()
i .LastName = from .GetLastName ()
if val , ok := from .GetNote (); ok {
i .Note = val
}
}
func (*InputPhoneContact ) TypeID () uint32 {
return InputPhoneContactTypeID
}
func (*InputPhoneContact ) TypeName () string {
return "inputPhoneContact"
}
func (i *InputPhoneContact ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputPhoneContact" ,
ID : InputPhoneContactTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ClientID" ,
SchemaName : "client_id" ,
},
{
Name : "Phone" ,
SchemaName : "phone" ,
},
{
Name : "FirstName" ,
SchemaName : "first_name" ,
},
{
Name : "LastName" ,
SchemaName : "last_name" ,
},
{
Name : "Note" ,
SchemaName : "note" ,
Null : !i .Flags .Has (0 ),
},
}
return typ
}
func (i *InputPhoneContact ) SetFlags () {
if !(i .Note .Zero ()) {
i .Flags .Set (0 )
}
}
func (i *InputPhoneContact ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPhoneContact#6a1dc4be as nil" )
}
b .PutID (InputPhoneContactTypeID )
return i .EncodeBare (b )
}
func (i *InputPhoneContact ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputPhoneContact#6a1dc4be as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputPhoneContact#6a1dc4be: field flags: %w" , err )
}
b .PutLong (i .ClientID )
b .PutString (i .Phone )
b .PutString (i .FirstName )
b .PutString (i .LastName )
if i .Flags .Has (0 ) {
if err := i .Note .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputPhoneContact#6a1dc4be: field note: %w" , err )
}
}
return nil
}
func (i *InputPhoneContact ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPhoneContact#6a1dc4be to nil" )
}
if err := b .ConsumeID (InputPhoneContactTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputPhoneContact ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputPhoneContact#6a1dc4be to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: field flags: %w" , err )
}
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: field client_id: %w" , err )
}
i .ClientID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: field phone: %w" , err )
}
i .Phone = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: field first_name: %w" , err )
}
i .FirstName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: field last_name: %w" , err )
}
i .LastName = value
}
if i .Flags .Has (0 ) {
if err := i .Note .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputPhoneContact#6a1dc4be: field note: %w" , err )
}
}
return nil
}
func (i *InputPhoneContact ) GetClientID () (value int64 ) {
if i == nil {
return
}
return i .ClientID
}
func (i *InputPhoneContact ) GetPhone () (value string ) {
if i == nil {
return
}
return i .Phone
}
func (i *InputPhoneContact ) GetFirstName () (value string ) {
if i == nil {
return
}
return i .FirstName
}
func (i *InputPhoneContact ) GetLastName () (value string ) {
if i == nil {
return
}
return i .LastName
}
func (i *InputPhoneContact ) SetNote (value TextWithEntities ) {
i .Flags .Set (0 )
i .Note = value
}
func (i *InputPhoneContact ) GetNote () (value TextWithEntities , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .Note , true
}
The pages are generated with Golds v0.8.4 . (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 .