// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// AuthLoginToken represents TL type `auth.loginToken#629f1980`.
// Login token (for QR code loginĀ¹)
//
// Links:
//  1. https://core.telegram.org/api/qr-login
//
// See https://core.telegram.org/constructor/auth.loginToken for reference.
type AuthLoginToken struct {
	// Expiration date of QR code
	Expires int
	// Token to render in QR code
	Token []byte
}

// AuthLoginTokenTypeID is TL type id of AuthLoginToken.
const AuthLoginTokenTypeID = 0x629f1980

// construct implements constructor of AuthLoginTokenClass.
func ( AuthLoginToken) () AuthLoginTokenClass { return & }

// Ensuring interfaces in compile-time for AuthLoginToken.
var (
	_ bin.Encoder     = &AuthLoginToken{}
	_ bin.Decoder     = &AuthLoginToken{}
	_ bin.BareEncoder = &AuthLoginToken{}
	_ bin.BareDecoder = &AuthLoginToken{}

	_ AuthLoginTokenClass = &AuthLoginToken{}
)

func ( *AuthLoginToken) () bool {
	if  == nil {
		return true
	}
	if !(.Expires == 0) {
		return false
	}
	if !(.Token == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *AuthLoginToken) () string {
	if  == nil {
		return "AuthLoginToken(nil)"
	}
	type  AuthLoginToken
	return fmt.Sprintf("AuthLoginToken%+v", (*))
}

// FillFrom fills AuthLoginToken from given interface.
func ( *AuthLoginToken) ( interface {
	() ( int)
	() ( []byte)
}) {
	.Expires = .()
	.Token = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AuthLoginToken) () uint32 {
	return AuthLoginTokenTypeID
}

// TypeName returns name of type in TL schema.
func (*AuthLoginToken) () string {
	return "auth.loginToken"
}

// TypeInfo returns info about TL type.
func ( *AuthLoginToken) () tdp.Type {
	 := tdp.Type{
		Name: "auth.loginToken",
		ID:   AuthLoginTokenTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Expires",
			SchemaName: "expires",
		},
		{
			Name:       "Token",
			SchemaName: "token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthLoginToken) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.loginToken#629f1980 as nil")
	}
	.PutID(AuthLoginTokenTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthLoginToken) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.loginToken#629f1980 as nil")
	}
	.PutInt(.Expires)
	.PutBytes(.Token)
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthLoginToken) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.loginToken#629f1980 to nil")
	}
	if  := .ConsumeID(AuthLoginTokenTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.loginToken#629f1980: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthLoginToken) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.loginToken#629f1980 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.loginToken#629f1980: field expires: %w", )
		}
		.Expires = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode auth.loginToken#629f1980: field token: %w", )
		}
		.Token = 
	}
	return nil
}

// GetExpires returns value of Expires field.
func ( *AuthLoginToken) () ( int) {
	if  == nil {
		return
	}
	return .Expires
}

// GetToken returns value of Token field.
func ( *AuthLoginToken) () ( []byte) {
	if  == nil {
		return
	}
	return .Token
}

// AuthLoginTokenMigrateTo represents TL type `auth.loginTokenMigrateTo#68e9916`.
// Repeat the query to the specified DC
//
// See https://core.telegram.org/constructor/auth.loginTokenMigrateTo for reference.
type AuthLoginTokenMigrateTo struct {
	// DC ID
	DCID int
	// Token to use for login
	Token []byte
}

// AuthLoginTokenMigrateToTypeID is TL type id of AuthLoginTokenMigrateTo.
const AuthLoginTokenMigrateToTypeID = 0x68e9916

// construct implements constructor of AuthLoginTokenClass.
func ( AuthLoginTokenMigrateTo) () AuthLoginTokenClass { return & }

// Ensuring interfaces in compile-time for AuthLoginTokenMigrateTo.
var (
	_ bin.Encoder     = &AuthLoginTokenMigrateTo{}
	_ bin.Decoder     = &AuthLoginTokenMigrateTo{}
	_ bin.BareEncoder = &AuthLoginTokenMigrateTo{}
	_ bin.BareDecoder = &AuthLoginTokenMigrateTo{}

	_ AuthLoginTokenClass = &AuthLoginTokenMigrateTo{}
)

func ( *AuthLoginTokenMigrateTo) () bool {
	if  == nil {
		return true
	}
	if !(.DCID == 0) {
		return false
	}
	if !(.Token == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *AuthLoginTokenMigrateTo) () string {
	if  == nil {
		return "AuthLoginTokenMigrateTo(nil)"
	}
	type  AuthLoginTokenMigrateTo
	return fmt.Sprintf("AuthLoginTokenMigrateTo%+v", (*))
}

// FillFrom fills AuthLoginTokenMigrateTo from given interface.
func ( *AuthLoginTokenMigrateTo) ( interface {
	() ( int)
	() ( []byte)
}) {
	.DCID = .()
	.Token = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AuthLoginTokenMigrateTo) () uint32 {
	return AuthLoginTokenMigrateToTypeID
}

// TypeName returns name of type in TL schema.
func (*AuthLoginTokenMigrateTo) () string {
	return "auth.loginTokenMigrateTo"
}

// TypeInfo returns info about TL type.
func ( *AuthLoginTokenMigrateTo) () tdp.Type {
	 := tdp.Type{
		Name: "auth.loginTokenMigrateTo",
		ID:   AuthLoginTokenMigrateToTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DCID",
			SchemaName: "dc_id",
		},
		{
			Name:       "Token",
			SchemaName: "token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthLoginTokenMigrateTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.loginTokenMigrateTo#68e9916 as nil")
	}
	.PutID(AuthLoginTokenMigrateToTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthLoginTokenMigrateTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.loginTokenMigrateTo#68e9916 as nil")
	}
	.PutInt(.DCID)
	.PutBytes(.Token)
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthLoginTokenMigrateTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.loginTokenMigrateTo#68e9916 to nil")
	}
	if  := .ConsumeID(AuthLoginTokenMigrateToTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.loginTokenMigrateTo#68e9916: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthLoginTokenMigrateTo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.loginTokenMigrateTo#68e9916 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.loginTokenMigrateTo#68e9916: field dc_id: %w", )
		}
		.DCID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode auth.loginTokenMigrateTo#68e9916: field token: %w", )
		}
		.Token = 
	}
	return nil
}

// GetDCID returns value of DCID field.
func ( *AuthLoginTokenMigrateTo) () ( int) {
	if  == nil {
		return
	}
	return .DCID
}

// GetToken returns value of Token field.
func ( *AuthLoginTokenMigrateTo) () ( []byte) {
	if  == nil {
		return
	}
	return .Token
}

// AuthLoginTokenSuccess represents TL type `auth.loginTokenSuccess#390d5c5e`.
// Login via token (QR code) succeeded!
//
// See https://core.telegram.org/constructor/auth.loginTokenSuccess for reference.
type AuthLoginTokenSuccess struct {
	// Authorization info
	Authorization AuthAuthorizationClass
}

// AuthLoginTokenSuccessTypeID is TL type id of AuthLoginTokenSuccess.
const AuthLoginTokenSuccessTypeID = 0x390d5c5e

// construct implements constructor of AuthLoginTokenClass.
func ( AuthLoginTokenSuccess) () AuthLoginTokenClass { return & }

// Ensuring interfaces in compile-time for AuthLoginTokenSuccess.
var (
	_ bin.Encoder     = &AuthLoginTokenSuccess{}
	_ bin.Decoder     = &AuthLoginTokenSuccess{}
	_ bin.BareEncoder = &AuthLoginTokenSuccess{}
	_ bin.BareDecoder = &AuthLoginTokenSuccess{}

	_ AuthLoginTokenClass = &AuthLoginTokenSuccess{}
)

func ( *AuthLoginTokenSuccess) () bool {
	if  == nil {
		return true
	}
	if !(.Authorization == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *AuthLoginTokenSuccess) () string {
	if  == nil {
		return "AuthLoginTokenSuccess(nil)"
	}
	type  AuthLoginTokenSuccess
	return fmt.Sprintf("AuthLoginTokenSuccess%+v", (*))
}

// FillFrom fills AuthLoginTokenSuccess from given interface.
func ( *AuthLoginTokenSuccess) ( interface {
	() ( AuthAuthorizationClass)
}) {
	.Authorization = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*AuthLoginTokenSuccess) () uint32 {
	return AuthLoginTokenSuccessTypeID
}

// TypeName returns name of type in TL schema.
func (*AuthLoginTokenSuccess) () string {
	return "auth.loginTokenSuccess"
}

// TypeInfo returns info about TL type.
func ( *AuthLoginTokenSuccess) () tdp.Type {
	 := tdp.Type{
		Name: "auth.loginTokenSuccess",
		ID:   AuthLoginTokenSuccessTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Authorization",
			SchemaName: "authorization",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthLoginTokenSuccess) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.loginTokenSuccess#390d5c5e as nil")
	}
	.PutID(AuthLoginTokenSuccessTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthLoginTokenSuccess) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.loginTokenSuccess#390d5c5e as nil")
	}
	if .Authorization == nil {
		return fmt.Errorf("unable to encode auth.loginTokenSuccess#390d5c5e: field authorization is nil")
	}
	if  := .Authorization.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.loginTokenSuccess#390d5c5e: field authorization: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthLoginTokenSuccess) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.loginTokenSuccess#390d5c5e to nil")
	}
	if  := .ConsumeID(AuthLoginTokenSuccessTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.loginTokenSuccess#390d5c5e: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthLoginTokenSuccess) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.loginTokenSuccess#390d5c5e to nil")
	}
	{
		,  := DecodeAuthAuthorization()
		if  != nil {
			return fmt.Errorf("unable to decode auth.loginTokenSuccess#390d5c5e: field authorization: %w", )
		}
		.Authorization = 
	}
	return nil
}

// GetAuthorization returns value of Authorization field.
func ( *AuthLoginTokenSuccess) () ( AuthAuthorizationClass) {
	if  == nil {
		return
	}
	return .Authorization
}

// AuthLoginTokenClassName is schema name of AuthLoginTokenClass.
const AuthLoginTokenClassName = "auth.LoginToken"

// AuthLoginTokenClass represents auth.LoginToken generic type.
//
// See https://core.telegram.org/type/auth.LoginToken for reference.
//
// Example:
//
//	g, err := tg.DecodeAuthLoginToken(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AuthLoginToken: // auth.loginToken#629f1980
//	case *tg.AuthLoginTokenMigrateTo: // auth.loginTokenMigrateTo#68e9916
//	case *tg.AuthLoginTokenSuccess: // auth.loginTokenSuccess#390d5c5e
//	default: panic(v)
//	}
type AuthLoginTokenClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AuthLoginTokenClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeAuthLoginToken implements binary de-serialization for AuthLoginTokenClass.
func ( *bin.Buffer) (AuthLoginTokenClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AuthLoginTokenTypeID:
		// Decoding auth.loginToken#629f1980.
		 := AuthLoginToken{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthLoginTokenClass: %w", )
		}
		return &, nil
	case AuthLoginTokenMigrateToTypeID:
		// Decoding auth.loginTokenMigrateTo#68e9916.
		 := AuthLoginTokenMigrateTo{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthLoginTokenClass: %w", )
		}
		return &, nil
	case AuthLoginTokenSuccessTypeID:
		// Decoding auth.loginTokenSuccess#390d5c5e.
		 := AuthLoginTokenSuccess{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthLoginTokenClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AuthLoginTokenClass: %w", bin.NewUnexpectedID())
	}
}

// AuthLoginToken boxes the AuthLoginTokenClass providing a helper.
type AuthLoginTokenBox struct {
	LoginToken AuthLoginTokenClass
}

// Decode implements bin.Decoder for AuthLoginTokenBox.
func ( *AuthLoginTokenBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode AuthLoginTokenBox to nil")
	}
	,  := DecodeAuthLoginToken()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.LoginToken = 
	return nil
}

// Encode implements bin.Encode for AuthLoginTokenBox.
func ( *AuthLoginTokenBox) ( *bin.Buffer) error {
	if  == nil || .LoginToken == nil {
		return fmt.Errorf("unable to encode AuthLoginTokenClass as nil")
	}
	return .LoginToken.Encode()
}