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 EmailVerifyPurposeLoginSetup struct {
PhoneNumber string
PhoneCodeHash string
}
const EmailVerifyPurposeLoginSetupTypeID = 0x4345be73
func (e EmailVerifyPurposeLoginSetup ) construct () EmailVerifyPurposeClass { return &e }
var (
_ bin .Encoder = &EmailVerifyPurposeLoginSetup {}
_ bin .Decoder = &EmailVerifyPurposeLoginSetup {}
_ bin .BareEncoder = &EmailVerifyPurposeLoginSetup {}
_ bin .BareDecoder = &EmailVerifyPurposeLoginSetup {}
_ EmailVerifyPurposeClass = &EmailVerifyPurposeLoginSetup {}
)
func (e *EmailVerifyPurposeLoginSetup ) Zero () bool {
if e == nil {
return true
}
if !(e .PhoneNumber == "" ) {
return false
}
if !(e .PhoneCodeHash == "" ) {
return false
}
return true
}
func (e *EmailVerifyPurposeLoginSetup ) String () string {
if e == nil {
return "EmailVerifyPurposeLoginSetup(nil)"
}
type Alias EmailVerifyPurposeLoginSetup
return fmt .Sprintf ("EmailVerifyPurposeLoginSetup%+v" , Alias (*e ))
}
func (e *EmailVerifyPurposeLoginSetup ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
}) {
e .PhoneNumber = from .GetPhoneNumber ()
e .PhoneCodeHash = from .GetPhoneCodeHash ()
}
func (*EmailVerifyPurposeLoginSetup ) TypeID () uint32 {
return EmailVerifyPurposeLoginSetupTypeID
}
func (*EmailVerifyPurposeLoginSetup ) TypeName () string {
return "emailVerifyPurposeLoginSetup"
}
func (e *EmailVerifyPurposeLoginSetup ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emailVerifyPurposeLoginSetup" ,
ID : EmailVerifyPurposeLoginSetupTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "PhoneCodeHash" ,
SchemaName : "phone_code_hash" ,
},
}
return typ
}
func (e *EmailVerifyPurposeLoginSetup ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerifyPurposeLoginSetup#4345be73 as nil" )
}
b .PutID (EmailVerifyPurposeLoginSetupTypeID )
return e .EncodeBare (b )
}
func (e *EmailVerifyPurposeLoginSetup ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerifyPurposeLoginSetup#4345be73 as nil" )
}
b .PutString (e .PhoneNumber )
b .PutString (e .PhoneCodeHash )
return nil
}
func (e *EmailVerifyPurposeLoginSetup ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerifyPurposeLoginSetup#4345be73 to nil" )
}
if err := b .ConsumeID (EmailVerifyPurposeLoginSetupTypeID ); err != nil {
return fmt .Errorf ("unable to decode emailVerifyPurposeLoginSetup#4345be73: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmailVerifyPurposeLoginSetup ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerifyPurposeLoginSetup#4345be73 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emailVerifyPurposeLoginSetup#4345be73: field phone_number: %w" , err )
}
e .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emailVerifyPurposeLoginSetup#4345be73: field phone_code_hash: %w" , err )
}
e .PhoneCodeHash = value
}
return nil
}
func (e *EmailVerifyPurposeLoginSetup ) GetPhoneNumber () (value string ) {
if e == nil {
return
}
return e .PhoneNumber
}
func (e *EmailVerifyPurposeLoginSetup ) GetPhoneCodeHash () (value string ) {
if e == nil {
return
}
return e .PhoneCodeHash
}
type EmailVerifyPurposeLoginChange struct {
}
const EmailVerifyPurposeLoginChangeTypeID = 0x527d22eb
func (e EmailVerifyPurposeLoginChange ) construct () EmailVerifyPurposeClass { return &e }
var (
_ bin .Encoder = &EmailVerifyPurposeLoginChange {}
_ bin .Decoder = &EmailVerifyPurposeLoginChange {}
_ bin .BareEncoder = &EmailVerifyPurposeLoginChange {}
_ bin .BareDecoder = &EmailVerifyPurposeLoginChange {}
_ EmailVerifyPurposeClass = &EmailVerifyPurposeLoginChange {}
)
func (e *EmailVerifyPurposeLoginChange ) Zero () bool {
if e == nil {
return true
}
return true
}
func (e *EmailVerifyPurposeLoginChange ) String () string {
if e == nil {
return "EmailVerifyPurposeLoginChange(nil)"
}
type Alias EmailVerifyPurposeLoginChange
return fmt .Sprintf ("EmailVerifyPurposeLoginChange%+v" , Alias (*e ))
}
func (*EmailVerifyPurposeLoginChange ) TypeID () uint32 {
return EmailVerifyPurposeLoginChangeTypeID
}
func (*EmailVerifyPurposeLoginChange ) TypeName () string {
return "emailVerifyPurposeLoginChange"
}
func (e *EmailVerifyPurposeLoginChange ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emailVerifyPurposeLoginChange" ,
ID : EmailVerifyPurposeLoginChangeTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (e *EmailVerifyPurposeLoginChange ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerifyPurposeLoginChange#527d22eb as nil" )
}
b .PutID (EmailVerifyPurposeLoginChangeTypeID )
return e .EncodeBare (b )
}
func (e *EmailVerifyPurposeLoginChange ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerifyPurposeLoginChange#527d22eb as nil" )
}
return nil
}
func (e *EmailVerifyPurposeLoginChange ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerifyPurposeLoginChange#527d22eb to nil" )
}
if err := b .ConsumeID (EmailVerifyPurposeLoginChangeTypeID ); err != nil {
return fmt .Errorf ("unable to decode emailVerifyPurposeLoginChange#527d22eb: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmailVerifyPurposeLoginChange ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerifyPurposeLoginChange#527d22eb to nil" )
}
return nil
}
type EmailVerifyPurposePassport struct {
}
const EmailVerifyPurposePassportTypeID = 0xbbf51685
func (e EmailVerifyPurposePassport ) construct () EmailVerifyPurposeClass { return &e }
var (
_ bin .Encoder = &EmailVerifyPurposePassport {}
_ bin .Decoder = &EmailVerifyPurposePassport {}
_ bin .BareEncoder = &EmailVerifyPurposePassport {}
_ bin .BareDecoder = &EmailVerifyPurposePassport {}
_ EmailVerifyPurposeClass = &EmailVerifyPurposePassport {}
)
func (e *EmailVerifyPurposePassport ) Zero () bool {
if e == nil {
return true
}
return true
}
func (e *EmailVerifyPurposePassport ) String () string {
if e == nil {
return "EmailVerifyPurposePassport(nil)"
}
type Alias EmailVerifyPurposePassport
return fmt .Sprintf ("EmailVerifyPurposePassport%+v" , Alias (*e ))
}
func (*EmailVerifyPurposePassport ) TypeID () uint32 {
return EmailVerifyPurposePassportTypeID
}
func (*EmailVerifyPurposePassport ) TypeName () string {
return "emailVerifyPurposePassport"
}
func (e *EmailVerifyPurposePassport ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emailVerifyPurposePassport" ,
ID : EmailVerifyPurposePassportTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (e *EmailVerifyPurposePassport ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerifyPurposePassport#bbf51685 as nil" )
}
b .PutID (EmailVerifyPurposePassportTypeID )
return e .EncodeBare (b )
}
func (e *EmailVerifyPurposePassport ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerifyPurposePassport#bbf51685 as nil" )
}
return nil
}
func (e *EmailVerifyPurposePassport ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerifyPurposePassport#bbf51685 to nil" )
}
if err := b .ConsumeID (EmailVerifyPurposePassportTypeID ); err != nil {
return fmt .Errorf ("unable to decode emailVerifyPurposePassport#bbf51685: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmailVerifyPurposePassport ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerifyPurposePassport#bbf51685 to nil" )
}
return nil
}
const EmailVerifyPurposeClassName = "EmailVerifyPurpose"
type EmailVerifyPurposeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () EmailVerifyPurposeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeEmailVerifyPurpose (buf *bin .Buffer ) (EmailVerifyPurposeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case EmailVerifyPurposeLoginSetupTypeID :
v := EmailVerifyPurposeLoginSetup {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmailVerifyPurposeClass: %w" , err )
}
return &v , nil
case EmailVerifyPurposeLoginChangeTypeID :
v := EmailVerifyPurposeLoginChange {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmailVerifyPurposeClass: %w" , err )
}
return &v , nil
case EmailVerifyPurposePassportTypeID :
v := EmailVerifyPurposePassport {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmailVerifyPurposeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode EmailVerifyPurposeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type EmailVerifyPurposeBox struct {
EmailVerifyPurpose EmailVerifyPurposeClass
}
func (b *EmailVerifyPurposeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode EmailVerifyPurposeBox to nil" )
}
v , err := DecodeEmailVerifyPurpose (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .EmailVerifyPurpose = v
return nil
}
func (b *EmailVerifyPurposeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .EmailVerifyPurpose == nil {
return fmt .Errorf ("unable to encode EmailVerifyPurposeClass as nil" )
}
return b .EmailVerifyPurpose .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 .