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 AuthExportLoginTokenRequest struct {
APIID int
APIHash string
ExceptIDs []int64
}
const AuthExportLoginTokenRequestTypeID = 0xb7e085fe
var (
_ bin .Encoder = &AuthExportLoginTokenRequest {}
_ bin .Decoder = &AuthExportLoginTokenRequest {}
_ bin .BareEncoder = &AuthExportLoginTokenRequest {}
_ bin .BareDecoder = &AuthExportLoginTokenRequest {}
)
func (e *AuthExportLoginTokenRequest ) Zero () bool {
if e == nil {
return true
}
if !(e .APIID == 0 ) {
return false
}
if !(e .APIHash == "" ) {
return false
}
if !(e .ExceptIDs == nil ) {
return false
}
return true
}
func (e *AuthExportLoginTokenRequest ) String () string {
if e == nil {
return "AuthExportLoginTokenRequest(nil)"
}
type Alias AuthExportLoginTokenRequest
return fmt .Sprintf ("AuthExportLoginTokenRequest%+v" , Alias (*e ))
}
func (e *AuthExportLoginTokenRequest ) FillFrom (from interface {
GetAPIID () (value int )
GetAPIHash () (value string )
GetExceptIDs () (value []int64 )
}) {
e .APIID = from .GetAPIID ()
e .APIHash = from .GetAPIHash ()
e .ExceptIDs = from .GetExceptIDs ()
}
func (*AuthExportLoginTokenRequest ) TypeID () uint32 {
return AuthExportLoginTokenRequestTypeID
}
func (*AuthExportLoginTokenRequest ) TypeName () string {
return "auth.exportLoginToken"
}
func (e *AuthExportLoginTokenRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.exportLoginToken" ,
ID : AuthExportLoginTokenRequestTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "APIID" ,
SchemaName : "api_id" ,
},
{
Name : "APIHash" ,
SchemaName : "api_hash" ,
},
{
Name : "ExceptIDs" ,
SchemaName : "except_ids" ,
},
}
return typ
}
func (e *AuthExportLoginTokenRequest ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode auth.exportLoginToken#b7e085fe as nil" )
}
b .PutID (AuthExportLoginTokenRequestTypeID )
return e .EncodeBare (b )
}
func (e *AuthExportLoginTokenRequest ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode auth.exportLoginToken#b7e085fe as nil" )
}
b .PutInt (e .APIID )
b .PutString (e .APIHash )
b .PutVectorHeader (len (e .ExceptIDs ))
for _ , v := range e .ExceptIDs {
b .PutLong (v )
}
return nil
}
func (e *AuthExportLoginTokenRequest ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode auth.exportLoginToken#b7e085fe to nil" )
}
if err := b .ConsumeID (AuthExportLoginTokenRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.exportLoginToken#b7e085fe: %w" , err )
}
return e .DecodeBare (b )
}
func (e *AuthExportLoginTokenRequest ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode auth.exportLoginToken#b7e085fe to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.exportLoginToken#b7e085fe: field api_id: %w" , err )
}
e .APIID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.exportLoginToken#b7e085fe: field api_hash: %w" , err )
}
e .APIHash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode auth.exportLoginToken#b7e085fe: field except_ids: %w" , err )
}
if headerLen > 0 {
e .ExceptIDs = make ([]int64 , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode auth.exportLoginToken#b7e085fe: field except_ids: %w" , err )
}
e .ExceptIDs = append (e .ExceptIDs , value )
}
}
return nil
}
func (e *AuthExportLoginTokenRequest ) GetAPIID () (value int ) {
if e == nil {
return
}
return e .APIID
}
func (e *AuthExportLoginTokenRequest ) GetAPIHash () (value string ) {
if e == nil {
return
}
return e .APIHash
}
func (e *AuthExportLoginTokenRequest ) GetExceptIDs () (value []int64 ) {
if e == nil {
return
}
return e .ExceptIDs
}
func (c *Client ) AuthExportLoginToken (ctx context .Context , request *AuthExportLoginTokenRequest ) (AuthLoginTokenClass , error ) {
var result AuthLoginTokenBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .LoginToken , 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 .