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 ContactsImportContactTokenRequest struct {
Token string
}
const ContactsImportContactTokenRequestTypeID = 0x13005788
var (
_ bin .Encoder = &ContactsImportContactTokenRequest {}
_ bin .Decoder = &ContactsImportContactTokenRequest {}
_ bin .BareEncoder = &ContactsImportContactTokenRequest {}
_ bin .BareDecoder = &ContactsImportContactTokenRequest {}
)
func (i *ContactsImportContactTokenRequest ) Zero () bool {
if i == nil {
return true
}
if !(i .Token == "" ) {
return false
}
return true
}
func (i *ContactsImportContactTokenRequest ) String () string {
if i == nil {
return "ContactsImportContactTokenRequest(nil)"
}
type Alias ContactsImportContactTokenRequest
return fmt .Sprintf ("ContactsImportContactTokenRequest%+v" , Alias (*i ))
}
func (i *ContactsImportContactTokenRequest ) FillFrom (from interface {
GetToken () (value string )
}) {
i .Token = from .GetToken ()
}
func (*ContactsImportContactTokenRequest ) TypeID () uint32 {
return ContactsImportContactTokenRequestTypeID
}
func (*ContactsImportContactTokenRequest ) TypeName () string {
return "contacts.importContactToken"
}
func (i *ContactsImportContactTokenRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "contacts.importContactToken" ,
ID : ContactsImportContactTokenRequestTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Token" ,
SchemaName : "token" ,
},
}
return typ
}
func (i *ContactsImportContactTokenRequest ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode contacts.importContactToken#13005788 as nil" )
}
b .PutID (ContactsImportContactTokenRequestTypeID )
return i .EncodeBare (b )
}
func (i *ContactsImportContactTokenRequest ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode contacts.importContactToken#13005788 as nil" )
}
b .PutString (i .Token )
return nil
}
func (i *ContactsImportContactTokenRequest ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode contacts.importContactToken#13005788 to nil" )
}
if err := b .ConsumeID (ContactsImportContactTokenRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode contacts.importContactToken#13005788: %w" , err )
}
return i .DecodeBare (b )
}
func (i *ContactsImportContactTokenRequest ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode contacts.importContactToken#13005788 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode contacts.importContactToken#13005788: field token: %w" , err )
}
i .Token = value
}
return nil
}
func (i *ContactsImportContactTokenRequest ) GetToken () (value string ) {
if i == nil {
return
}
return i .Token
}
func (c *Client ) ContactsImportContactToken (ctx context .Context , token string ) (UserClass , error ) {
var result UserBox
request := &ContactsImportContactTokenRequest {
Token : token ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .User , 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 .