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 AuthSentCode struct {
Flags bin .Fields
Type AuthSentCodeTypeClass
PhoneCodeHash string
NextType AuthCodeTypeClass
Timeout int
}
const AuthSentCodeTypeID = 0x5e002502
func (s AuthSentCode ) construct () AuthSentCodeClass { return &s }
var (
_ bin .Encoder = &AuthSentCode {}
_ bin .Decoder = &AuthSentCode {}
_ bin .BareEncoder = &AuthSentCode {}
_ bin .BareDecoder = &AuthSentCode {}
_ AuthSentCodeClass = &AuthSentCode {}
)
func (s *AuthSentCode ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Type == nil ) {
return false
}
if !(s .PhoneCodeHash == "" ) {
return false
}
if !(s .NextType == nil ) {
return false
}
if !(s .Timeout == 0 ) {
return false
}
return true
}
func (s *AuthSentCode ) String () string {
if s == nil {
return "AuthSentCode(nil)"
}
type Alias AuthSentCode
return fmt .Sprintf ("AuthSentCode%+v" , Alias (*s ))
}
func (s *AuthSentCode ) FillFrom (from interface {
GetType () (value AuthSentCodeTypeClass )
GetPhoneCodeHash () (value string )
GetNextType () (value AuthCodeTypeClass , ok bool )
GetTimeout () (value int , ok bool )
}) {
s .Type = from .GetType ()
s .PhoneCodeHash = from .GetPhoneCodeHash ()
if val , ok := from .GetNextType (); ok {
s .NextType = val
}
if val , ok := from .GetTimeout (); ok {
s .Timeout = val
}
}
func (*AuthSentCode ) TypeID () uint32 {
return AuthSentCodeTypeID
}
func (*AuthSentCode ) TypeName () string {
return "auth.sentCode"
}
func (s *AuthSentCode ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.sentCode" ,
ID : AuthSentCodeTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Type" ,
SchemaName : "type" ,
},
{
Name : "PhoneCodeHash" ,
SchemaName : "phone_code_hash" ,
},
{
Name : "NextType" ,
SchemaName : "next_type" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Timeout" ,
SchemaName : "timeout" ,
Null : !s .Flags .Has (2 ),
},
}
return typ
}
func (s *AuthSentCode ) SetFlags () {
if !(s .NextType == nil ) {
s .Flags .Set (1 )
}
if !(s .Timeout == 0 ) {
s .Flags .Set (2 )
}
}
func (s *AuthSentCode ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.sentCode#5e002502 as nil" )
}
b .PutID (AuthSentCodeTypeID )
return s .EncodeBare (b )
}
func (s *AuthSentCode ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.sentCode#5e002502 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.sentCode#5e002502: field flags: %w" , err )
}
if s .Type == nil {
return fmt .Errorf ("unable to encode auth.sentCode#5e002502: field type is nil" )
}
if err := s .Type .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.sentCode#5e002502: field type: %w" , err )
}
b .PutString (s .PhoneCodeHash )
if s .Flags .Has (1 ) {
if s .NextType == nil {
return fmt .Errorf ("unable to encode auth.sentCode#5e002502: field next_type is nil" )
}
if err := s .NextType .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.sentCode#5e002502: field next_type: %w" , err )
}
}
if s .Flags .Has (2 ) {
b .PutInt (s .Timeout )
}
return nil
}
func (s *AuthSentCode ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.sentCode#5e002502 to nil" )
}
if err := b .ConsumeID (AuthSentCodeTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.sentCode#5e002502: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AuthSentCode ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.sentCode#5e002502 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode auth.sentCode#5e002502: field flags: %w" , err )
}
}
{
value , err := DecodeAuthSentCodeType (b )
if err != nil {
return fmt .Errorf ("unable to decode auth.sentCode#5e002502: field type: %w" , err )
}
s .Type = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.sentCode#5e002502: field phone_code_hash: %w" , err )
}
s .PhoneCodeHash = value
}
if s .Flags .Has (1 ) {
value , err := DecodeAuthCodeType (b )
if err != nil {
return fmt .Errorf ("unable to decode auth.sentCode#5e002502: field next_type: %w" , err )
}
s .NextType = value
}
if s .Flags .Has (2 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode auth.sentCode#5e002502: field timeout: %w" , err )
}
s .Timeout = value
}
return nil
}
func (s *AuthSentCode ) GetType () (value AuthSentCodeTypeClass ) {
if s == nil {
return
}
return s .Type
}
func (s *AuthSentCode ) GetPhoneCodeHash () (value string ) {
if s == nil {
return
}
return s .PhoneCodeHash
}
func (s *AuthSentCode ) SetNextType (value AuthCodeTypeClass ) {
s .Flags .Set (1 )
s .NextType = value
}
func (s *AuthSentCode ) GetNextType () (value AuthCodeTypeClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .NextType , true
}
func (s *AuthSentCode ) SetTimeout (value int ) {
s .Flags .Set (2 )
s .Timeout = value
}
func (s *AuthSentCode ) GetTimeout () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .Timeout , true
}
type AuthSentCodeSuccess struct {
Authorization AuthAuthorizationClass
}
const AuthSentCodeSuccessTypeID = 0x2390fe44
func (s AuthSentCodeSuccess ) construct () AuthSentCodeClass { return &s }
var (
_ bin .Encoder = &AuthSentCodeSuccess {}
_ bin .Decoder = &AuthSentCodeSuccess {}
_ bin .BareEncoder = &AuthSentCodeSuccess {}
_ bin .BareDecoder = &AuthSentCodeSuccess {}
_ AuthSentCodeClass = &AuthSentCodeSuccess {}
)
func (s *AuthSentCodeSuccess ) Zero () bool {
if s == nil {
return true
}
if !(s .Authorization == nil ) {
return false
}
return true
}
func (s *AuthSentCodeSuccess ) String () string {
if s == nil {
return "AuthSentCodeSuccess(nil)"
}
type Alias AuthSentCodeSuccess
return fmt .Sprintf ("AuthSentCodeSuccess%+v" , Alias (*s ))
}
func (s *AuthSentCodeSuccess ) FillFrom (from interface {
GetAuthorization () (value AuthAuthorizationClass )
}) {
s .Authorization = from .GetAuthorization ()
}
func (*AuthSentCodeSuccess ) TypeID () uint32 {
return AuthSentCodeSuccessTypeID
}
func (*AuthSentCodeSuccess ) TypeName () string {
return "auth.sentCodeSuccess"
}
func (s *AuthSentCodeSuccess ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.sentCodeSuccess" ,
ID : AuthSentCodeSuccessTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Authorization" ,
SchemaName : "authorization" ,
},
}
return typ
}
func (s *AuthSentCodeSuccess ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.sentCodeSuccess#2390fe44 as nil" )
}
b .PutID (AuthSentCodeSuccessTypeID )
return s .EncodeBare (b )
}
func (s *AuthSentCodeSuccess ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.sentCodeSuccess#2390fe44 as nil" )
}
if s .Authorization == nil {
return fmt .Errorf ("unable to encode auth.sentCodeSuccess#2390fe44: field authorization is nil" )
}
if err := s .Authorization .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.sentCodeSuccess#2390fe44: field authorization: %w" , err )
}
return nil
}
func (s *AuthSentCodeSuccess ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.sentCodeSuccess#2390fe44 to nil" )
}
if err := b .ConsumeID (AuthSentCodeSuccessTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.sentCodeSuccess#2390fe44: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AuthSentCodeSuccess ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.sentCodeSuccess#2390fe44 to nil" )
}
{
value , err := DecodeAuthAuthorization (b )
if err != nil {
return fmt .Errorf ("unable to decode auth.sentCodeSuccess#2390fe44: field authorization: %w" , err )
}
s .Authorization = value
}
return nil
}
func (s *AuthSentCodeSuccess ) GetAuthorization () (value AuthAuthorizationClass ) {
if s == nil {
return
}
return s .Authorization
}
const AuthSentCodeClassName = "auth.SentCode"
type AuthSentCodeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () AuthSentCodeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeAuthSentCode (buf *bin .Buffer ) (AuthSentCodeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case AuthSentCodeTypeID :
v := AuthSentCode {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AuthSentCodeClass: %w" , err )
}
return &v , nil
case AuthSentCodeSuccessTypeID :
v := AuthSentCodeSuccess {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode AuthSentCodeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode AuthSentCodeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type AuthSentCodeBox struct {
SentCode AuthSentCodeClass
}
func (b *AuthSentCodeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode AuthSentCodeBox to nil" )
}
v , err := DecodeAuthSentCode (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .SentCode = v
return nil
}
func (b *AuthSentCodeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .SentCode == nil {
return fmt .Errorf ("unable to encode AuthSentCodeClass as nil" )
}
return b .SentCode .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 .