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 ContactsImportContactsRequest struct {
Contacts []InputPhoneContact
}
const ContactsImportContactsRequestTypeID = 0x2c800be5
var (
_ bin .Encoder = &ContactsImportContactsRequest {}
_ bin .Decoder = &ContactsImportContactsRequest {}
_ bin .BareEncoder = &ContactsImportContactsRequest {}
_ bin .BareDecoder = &ContactsImportContactsRequest {}
)
func (i *ContactsImportContactsRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .Contacts == nil ) {
return false
}
return true
}
func (i *ContactsImportContactsRequest ) String () string {
if i == nil {
return "ContactsImportContactsRequest(nil)"
}
type Alias ContactsImportContactsRequest
return fmt .Sprintf ("ContactsImportContactsRequest%+v" , Alias (*i ))
}
func (i *ContactsImportContactsRequest ) FillFrom (from interface {
GetContacts () (value []InputPhoneContact )
}) {
i .Contacts = from .GetContacts ()
}
func (*ContactsImportContactsRequest ) TypeID () uint32 {
return ContactsImportContactsRequestTypeID
}
func (*ContactsImportContactsRequest ) TypeName () string {
return "contacts.importContacts"
}
func (i *ContactsImportContactsRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.importContacts" ,
ID : ContactsImportContactsRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Contacts" ,
SchemaName : "contacts" ,
},
}
return typ
}
func (i *ContactsImportContactsRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode contacts.importContacts#2c800be5 as nil" )
}
b .PutID (ContactsImportContactsRequestTypeID )
return i .EncodeBare (b )
}
func (i *ContactsImportContactsRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode contacts.importContacts#2c800be5 as nil" )
}
b .PutVectorHeader (len (i .Contacts ))
for idx , v := range i .Contacts {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode contacts.importContacts#2c800be5: field contacts element with index %d: %w" , idx , err )
}
}
return nil
}
func (i *ContactsImportContactsRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode contacts.importContacts#2c800be5 to nil" )
}
if err := b .ConsumeID (ContactsImportContactsRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.importContacts#2c800be5: %w" , err )
}
return i .DecodeBare (b )
}
func (i *ContactsImportContactsRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode contacts.importContacts#2c800be5 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.importContacts#2c800be5: field contacts: %w" , err )
}
if headerLen > 0 {
i .Contacts = make ([]InputPhoneContact , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value InputPhoneContact
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode contacts.importContacts#2c800be5: field contacts: %w" , err )
}
i .Contacts = append (i .Contacts , value )
}
}
return nil
}
func (i *ContactsImportContactsRequest ) GetContacts () (value []InputPhoneContact ) {
if i == nil {
return
}
return i .Contacts
}
func (c *Client ) ContactsImportContacts (ctx context .Context , contacts []InputPhoneContact ) (*ContactsImportedContacts , error ) {
var result ContactsImportedContacts
request := &ContactsImportContactsRequest {
Contacts : contacts ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return &result , 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 .