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 AuthLoginToken struct {
Expires int
Token []byte
}
const AuthLoginTokenTypeID = 0x629f1980
func (l AuthLoginToken ) construct () AuthLoginTokenClass { return &l }
var (
_ bin .Encoder = &AuthLoginToken {}
_ bin .Decoder = &AuthLoginToken {}
_ bin .BareEncoder = &AuthLoginToken {}
_ bin .BareDecoder = &AuthLoginToken {}
_ AuthLoginTokenClass = &AuthLoginToken {}
)
func (l *AuthLoginToken ) Zero () bool {
if l == nil {
return true
}
if !(l .Expires == 0 ) {
return false
}
if !(l .Token == nil ) {
return false
}
return true
}
func (l *AuthLoginToken ) String () string {
if l == nil {
return "AuthLoginToken(nil)"
}
type Alias AuthLoginToken
return fmt .Sprintf ("AuthLoginToken%+v" , Alias (*l ))
}
func (l *AuthLoginToken ) FillFrom (from interface {
GetExpires () (value int )
GetToken () (value []byte )
}) {
l .Expires = from .GetExpires ()
l .Token = from .GetToken ()
}
func (*AuthLoginToken ) TypeID () uint32 {
return AuthLoginTokenTypeID
}
func (*AuthLoginToken ) TypeName () string {
return "auth.loginToken"
}
func (l *AuthLoginToken ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.loginToken" ,
ID : AuthLoginTokenTypeID ,
}
if l == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Expires" ,
SchemaName : "expires" ,
},
{
Name : "Token" ,
SchemaName : "token" ,
},
}
return typ
}
func (l *AuthLoginToken ) Encode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode auth.loginToken#629f1980 as nil" )
}
b .PutID (AuthLoginTokenTypeID )
return l .EncodeBare (b )
}
func (l *AuthLoginToken ) EncodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode auth.loginToken#629f1980 as nil" )
}
b .PutInt (l .Expires )
b .PutBytes (l .Token )
return nil
}
func (l *AuthLoginToken ) Decode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode auth.loginToken#629f1980 to nil" )
}
if err := b .ConsumeID (AuthLoginTokenTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.loginToken#629f1980: %w" , err )
}
return l .DecodeBare (b )
}
func (l *AuthLoginToken ) DecodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode auth.loginToken#629f1980 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.loginToken#629f1980: field expires: %w" , err )
}
l .Expires = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode auth.loginToken#629f1980: field token: %w" , err )
}
l .Token = value
}
return nil
}
func (l *AuthLoginToken ) GetExpires () (value int ) {
if l == nil {
return
}
return l .Expires
}
func (l *AuthLoginToken ) GetToken () (value []byte ) {
if l == nil {
return
}
return l .Token
}
type AuthLoginTokenMigrateTo struct {
DCID int
Token []byte
}
const AuthLoginTokenMigrateToTypeID = 0x68e9916
func (l AuthLoginTokenMigrateTo ) construct () AuthLoginTokenClass { return &l }
var (
_ bin .Encoder = &AuthLoginTokenMigrateTo {}
_ bin .Decoder = &AuthLoginTokenMigrateTo {}
_ bin .BareEncoder = &AuthLoginTokenMigrateTo {}
_ bin .BareDecoder = &AuthLoginTokenMigrateTo {}
_ AuthLoginTokenClass = &AuthLoginTokenMigrateTo {}
)
func (l *AuthLoginTokenMigrateTo ) Zero () bool {
if l == nil {
return true
}
if !(l .DCID == 0 ) {
return false
}
if !(l .Token == nil ) {
return false
}
return true
}
func (l *AuthLoginTokenMigrateTo ) String () string {
if l == nil {
return "AuthLoginTokenMigrateTo(nil)"
}
type Alias AuthLoginTokenMigrateTo
return fmt .Sprintf ("AuthLoginTokenMigrateTo%+v" , Alias (*l ))
}
func (l *AuthLoginTokenMigrateTo ) FillFrom (from interface {
GetDCID () (value int )
GetToken () (value []byte )
}) {
l .DCID = from .GetDCID ()
l .Token = from .GetToken ()
}
func (*AuthLoginTokenMigrateTo ) TypeID () uint32 {
return AuthLoginTokenMigrateToTypeID
}
func (*AuthLoginTokenMigrateTo ) TypeName () string {
return "auth.loginTokenMigrateTo"
}
func (l *AuthLoginTokenMigrateTo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.loginTokenMigrateTo" ,
ID : AuthLoginTokenMigrateToTypeID ,
}
if l == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "DCID" ,
SchemaName : "dc_id" ,
},
{
Name : "Token" ,
SchemaName : "token" ,
},
}
return typ
}
func (l *AuthLoginTokenMigrateTo ) Encode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode auth.loginTokenMigrateTo#68e9916 as nil" )
}
b .PutID (AuthLoginTokenMigrateToTypeID )
return l .EncodeBare (b )
}
func (l *AuthLoginTokenMigrateTo ) EncodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode auth.loginTokenMigrateTo#68e9916 as nil" )
}
b .PutInt (l .DCID )
b .PutBytes (l .Token )
return nil
}
func (l *AuthLoginTokenMigrateTo ) Decode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode auth.loginTokenMigrateTo#68e9916 to nil" )
}
if err := b .ConsumeID (AuthLoginTokenMigrateToTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.loginTokenMigrateTo#68e9916: %w" , err )
}
return l .DecodeBare (b )
}
func (l *AuthLoginTokenMigrateTo ) DecodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode auth.loginTokenMigrateTo#68e9916 to nil" )
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.loginTokenMigrateTo#68e9916: field dc_id: %w" , err )
}
l .DCID = value
}
{
value , err := b .Bytes ()
if err != nil {
return fmt .Errorf ("unable to decode auth.loginTokenMigrateTo#68e9916: field token: %w" , err )
}
l .Token = value
}
return nil
}
func (l *AuthLoginTokenMigrateTo ) GetDCID () (value int ) {
if l == nil {
return
}
return l .DCID
}
func (l *AuthLoginTokenMigrateTo ) GetToken () (value []byte ) {
if l == nil {
return
}
return l .Token
}
type AuthLoginTokenSuccess struct {
Authorization AuthAuthorizationClass
}
const AuthLoginTokenSuccessTypeID = 0x390d5c5e
func (l AuthLoginTokenSuccess ) construct () AuthLoginTokenClass { return &l }
var (
_ bin .Encoder = &AuthLoginTokenSuccess {}
_ bin .Decoder = &AuthLoginTokenSuccess {}
_ bin .BareEncoder = &AuthLoginTokenSuccess {}
_ bin .BareDecoder = &AuthLoginTokenSuccess {}
_ AuthLoginTokenClass = &AuthLoginTokenSuccess {}
)
func (l *AuthLoginTokenSuccess ) Zero () bool {
if l == nil {
return true
}
if !(l .Authorization == nil ) {
return false
}
return true
}
func (l *AuthLoginTokenSuccess ) String () string {
if l == nil {
return "AuthLoginTokenSuccess(nil)"
}
type Alias AuthLoginTokenSuccess
return fmt .Sprintf ("AuthLoginTokenSuccess%+v" , Alias (*l ))
}
func (l *AuthLoginTokenSuccess ) FillFrom (from interface {
GetAuthorization () (value AuthAuthorizationClass )
}) {
l .Authorization = from .GetAuthorization ()
}
func (*AuthLoginTokenSuccess ) TypeID () uint32 {
return AuthLoginTokenSuccessTypeID
}
func (*AuthLoginTokenSuccess ) TypeName () string {
return "auth.loginTokenSuccess"
}
func (l *AuthLoginTokenSuccess ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.loginTokenSuccess" ,
ID : AuthLoginTokenSuccessTypeID ,
}
if l == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Authorization" ,
SchemaName : "authorization" ,
},
}
return typ
}
func (l *AuthLoginTokenSuccess ) Encode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode auth.loginTokenSuccess#390d5c5e as nil" )
}
b .PutID (AuthLoginTokenSuccessTypeID )
return l .EncodeBare (b )
}
func (l *AuthLoginTokenSuccess ) EncodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't encode auth.loginTokenSuccess#390d5c5e as nil" )
}
if l .Authorization == nil {
return fmt .Errorf ("unable to encode auth.loginTokenSuccess#390d5c5e: field authorization is nil" )
}
if err := l .Authorization .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.loginTokenSuccess#390d5c5e: field authorization: %w" , err )
}
return nil
}
func (l *AuthLoginTokenSuccess ) Decode (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode auth.loginTokenSuccess#390d5c5e to nil" )
}
if err := b .ConsumeID (AuthLoginTokenSuccessTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.loginTokenSuccess#390d5c5e: %w" , err )
}
return l .DecodeBare (b )
}
func (l *AuthLoginTokenSuccess ) DecodeBare (b *bin .Buffer ) error {
if l == nil {
return fmt .Errorf ("can't decode auth.loginTokenSuccess#390d5c5e to nil" )
}
{
value , err := DecodeAuthAuthorization (b )
if err != nil {
return fmt .Errorf ("unable to decode auth.loginTokenSuccess#390d5c5e: field authorization: %w" , err )
}
l .Authorization = value
}
return nil
}
func (l *AuthLoginTokenSuccess ) GetAuthorization () (value AuthAuthorizationClass ) {
if l == nil {
return
}
return l .Authorization
}
const AuthLoginTokenClassName = "auth.LoginToken"
type AuthLoginTokenClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AuthLoginTokenClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeAuthLoginToken (buf *bin .Buffer ) (AuthLoginTokenClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AuthLoginTokenTypeID :
v := AuthLoginToken {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AuthLoginTokenClass: %w" , err )
}
return &v , nil
case AuthLoginTokenMigrateToTypeID :
v := AuthLoginTokenMigrateTo {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AuthLoginTokenClass: %w" , err )
}
return &v , nil
case AuthLoginTokenSuccessTypeID :
v := AuthLoginTokenSuccess {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AuthLoginTokenClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AuthLoginTokenClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AuthLoginTokenBox struct {
LoginToken AuthLoginTokenClass
}
func (b *AuthLoginTokenBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AuthLoginTokenBox to nil" )
}
v , err := DecodeAuthLoginToken (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .LoginToken = v
return nil
}
func (b *AuthLoginTokenBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .LoginToken == nil {
return fmt .Errorf ("unable to encode AuthLoginTokenClass as nil" )
}
return b .LoginToken .Encode (buf )
}
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 .