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 ContactsAddContactRequest struct {
Flags bin .Fields
AddPhonePrivacyException bool
ID InputUserClass
FirstName string
LastName string
Phone string
}
const ContactsAddContactRequestTypeID = 0xe8f463d0
var (
_ bin .Encoder = &ContactsAddContactRequest {}
_ bin .Decoder = &ContactsAddContactRequest {}
_ bin .BareEncoder = &ContactsAddContactRequest {}
_ bin .BareDecoder = &ContactsAddContactRequest {}
)
func (a *ContactsAddContactRequest ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .AddPhonePrivacyException == false ) {
return false
}
if !(a .ID == nil ) {
return false
}
if !(a .FirstName == "" ) {
return false
}
if !(a .LastName == "" ) {
return false
}
if !(a .Phone == "" ) {
return false
}
return true
}
func (a *ContactsAddContactRequest ) String () string {
if a == nil {
return "ContactsAddContactRequest(nil)"
}
type Alias ContactsAddContactRequest
return fmt .Sprintf ("ContactsAddContactRequest%+v" , Alias (*a ))
}
func (a *ContactsAddContactRequest ) FillFrom (from interface {
GetAddPhonePrivacyException () (value bool )
GetID () (value InputUserClass )
GetFirstName () (value string )
GetLastName () (value string )
GetPhone () (value string )
}) {
a .AddPhonePrivacyException = from .GetAddPhonePrivacyException ()
a .ID = from .GetID ()
a .FirstName = from .GetFirstName ()
a .LastName = from .GetLastName ()
a .Phone = from .GetPhone ()
}
func (*ContactsAddContactRequest ) TypeID () uint32 {
return ContactsAddContactRequestTypeID
}
func (*ContactsAddContactRequest ) TypeName () string {
return "contacts.addContact"
}
func (a *ContactsAddContactRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.addContact" ,
ID : ContactsAddContactRequestTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "AddPhonePrivacyException" ,
SchemaName : "add_phone_privacy_exception" ,
Null : !a .Flags .Has (0 ),
},
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "FirstName" ,
SchemaName : "first_name" ,
},
{
Name : "LastName" ,
SchemaName : "last_name" ,
},
{
Name : "Phone" ,
SchemaName : "phone" ,
},
}
return typ
}
func (a *ContactsAddContactRequest ) SetFlags () {
if !(a .AddPhonePrivacyException == false ) {
a .Flags .Set (0 )
}
}
func (a *ContactsAddContactRequest ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode contacts.addContact#e8f463d0 as nil" )
}
b .PutID (ContactsAddContactRequestTypeID )
return a .EncodeBare (b )
}
func (a *ContactsAddContactRequest ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode contacts.addContact#e8f463d0 as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.addContact#e8f463d0: field flags: %w" , err )
}
if a .ID == nil {
return fmt .Errorf ("unable to encode contacts.addContact#e8f463d0: field id is nil" )
}
if err := a .ID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.addContact#e8f463d0: field id: %w" , err )
}
b .PutString (a .FirstName )
b .PutString (a .LastName )
b .PutString (a .Phone )
return nil
}
func (a *ContactsAddContactRequest ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode contacts.addContact#e8f463d0 to nil" )
}
if err := b .ConsumeID (ContactsAddContactRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.addContact#e8f463d0: %w" , err )
}
return a .DecodeBare (b )
}
func (a *ContactsAddContactRequest ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode contacts.addContact#e8f463d0 to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.addContact#e8f463d0: field flags: %w" , err )
}
}
a .AddPhonePrivacyException = a .Flags .Has (0 )
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode contacts.addContact#e8f463d0: field id: %w" , err )
}
a .ID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.addContact#e8f463d0: field first_name: %w" , err )
}
a .FirstName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.addContact#e8f463d0: field last_name: %w" , err )
}
a .LastName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.addContact#e8f463d0: field phone: %w" , err )
}
a .Phone = value
}
return nil
}
func (a *ContactsAddContactRequest ) SetAddPhonePrivacyException (value bool ) {
if value {
a .Flags .Set (0 )
a .AddPhonePrivacyException = true
} else {
a .Flags .Unset (0 )
a .AddPhonePrivacyException = false
}
}
func (a *ContactsAddContactRequest ) GetAddPhonePrivacyException () (value bool ) {
if a == nil {
return
}
return a .Flags .Has (0 )
}
func (a *ContactsAddContactRequest ) GetID () (value InputUserClass ) {
if a == nil {
return
}
return a .ID
}
func (a *ContactsAddContactRequest ) GetFirstName () (value string ) {
if a == nil {
return
}
return a .FirstName
}
func (a *ContactsAddContactRequest ) GetLastName () (value string ) {
if a == nil {
return
}
return a .LastName
}
func (a *ContactsAddContactRequest ) GetPhone () (value string ) {
if a == nil {
return
}
return a .Phone
}
func (c *Client ) ContactsAddContact (ctx context .Context , request *ContactsAddContactRequest ) (UpdatesClass , error ) {
var result UpdatesBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Updates , nil
}
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 .