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 EmailVerificationCode struct {
Code string
}
const EmailVerificationCodeTypeID = 0x922e55a9
func (e EmailVerificationCode ) construct () EmailVerificationClass { return &e }
var (
_ bin .Encoder = &EmailVerificationCode {}
_ bin .Decoder = &EmailVerificationCode {}
_ bin .BareEncoder = &EmailVerificationCode {}
_ bin .BareDecoder = &EmailVerificationCode {}
_ EmailVerificationClass = &EmailVerificationCode {}
)
func (e *EmailVerificationCode ) Zero () bool {
if e == nil {
return true
}
if !(e .Code == "" ) {
return false
}
return true
}
func (e *EmailVerificationCode ) String () string {
if e == nil {
return "EmailVerificationCode(nil)"
}
type Alias EmailVerificationCode
return fmt .Sprintf ("EmailVerificationCode%+v" , Alias (*e ))
}
func (e *EmailVerificationCode ) FillFrom (from interface {
GetCode () (value string )
}) {
e .Code = from .GetCode ()
}
func (*EmailVerificationCode ) TypeID () uint32 {
return EmailVerificationCodeTypeID
}
func (*EmailVerificationCode ) TypeName () string {
return "emailVerificationCode"
}
func (e *EmailVerificationCode ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emailVerificationCode" ,
ID : EmailVerificationCodeTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Code" ,
SchemaName : "code" ,
},
}
return typ
}
func (e *EmailVerificationCode ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerificationCode#922e55a9 as nil" )
}
b .PutID (EmailVerificationCodeTypeID )
return e .EncodeBare (b )
}
func (e *EmailVerificationCode ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerificationCode#922e55a9 as nil" )
}
b .PutString (e .Code )
return nil
}
func (e *EmailVerificationCode ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerificationCode#922e55a9 to nil" )
}
if err := b .ConsumeID (EmailVerificationCodeTypeID ); err != nil {
return fmt .Errorf ("unable to decode emailVerificationCode#922e55a9: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmailVerificationCode ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerificationCode#922e55a9 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emailVerificationCode#922e55a9: field code: %w" , err )
}
e .Code = value
}
return nil
}
func (e *EmailVerificationCode ) GetCode () (value string ) {
if e == nil {
return
}
return e .Code
}
type EmailVerificationGoogle struct {
Token string
}
const EmailVerificationGoogleTypeID = 0xdb909ec2
func (e EmailVerificationGoogle ) construct () EmailVerificationClass { return &e }
var (
_ bin .Encoder = &EmailVerificationGoogle {}
_ bin .Decoder = &EmailVerificationGoogle {}
_ bin .BareEncoder = &EmailVerificationGoogle {}
_ bin .BareDecoder = &EmailVerificationGoogle {}
_ EmailVerificationClass = &EmailVerificationGoogle {}
)
func (e *EmailVerificationGoogle ) Zero () bool {
if e == nil {
return true
}
if !(e .Token == "" ) {
return false
}
return true
}
func (e *EmailVerificationGoogle ) String () string {
if e == nil {
return "EmailVerificationGoogle(nil)"
}
type Alias EmailVerificationGoogle
return fmt .Sprintf ("EmailVerificationGoogle%+v" , Alias (*e ))
}
func (e *EmailVerificationGoogle ) FillFrom (from interface {
GetToken () (value string )
}) {
e .Token = from .GetToken ()
}
func (*EmailVerificationGoogle ) TypeID () uint32 {
return EmailVerificationGoogleTypeID
}
func (*EmailVerificationGoogle ) TypeName () string {
return "emailVerificationGoogle"
}
func (e *EmailVerificationGoogle ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emailVerificationGoogle" ,
ID : EmailVerificationGoogleTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Token" ,
SchemaName : "token" ,
},
}
return typ
}
func (e *EmailVerificationGoogle ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerificationGoogle#db909ec2 as nil" )
}
b .PutID (EmailVerificationGoogleTypeID )
return e .EncodeBare (b )
}
func (e *EmailVerificationGoogle ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerificationGoogle#db909ec2 as nil" )
}
b .PutString (e .Token )
return nil
}
func (e *EmailVerificationGoogle ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerificationGoogle#db909ec2 to nil" )
}
if err := b .ConsumeID (EmailVerificationGoogleTypeID ); err != nil {
return fmt .Errorf ("unable to decode emailVerificationGoogle#db909ec2: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmailVerificationGoogle ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerificationGoogle#db909ec2 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emailVerificationGoogle#db909ec2: field token: %w" , err )
}
e .Token = value
}
return nil
}
func (e *EmailVerificationGoogle ) GetToken () (value string ) {
if e == nil {
return
}
return e .Token
}
type EmailVerificationApple struct {
Token string
}
const EmailVerificationAppleTypeID = 0x96d074fd
func (e EmailVerificationApple ) construct () EmailVerificationClass { return &e }
var (
_ bin .Encoder = &EmailVerificationApple {}
_ bin .Decoder = &EmailVerificationApple {}
_ bin .BareEncoder = &EmailVerificationApple {}
_ bin .BareDecoder = &EmailVerificationApple {}
_ EmailVerificationClass = &EmailVerificationApple {}
)
func (e *EmailVerificationApple ) Zero () bool {
if e == nil {
return true
}
if !(e .Token == "" ) {
return false
}
return true
}
func (e *EmailVerificationApple ) String () string {
if e == nil {
return "EmailVerificationApple(nil)"
}
type Alias EmailVerificationApple
return fmt .Sprintf ("EmailVerificationApple%+v" , Alias (*e ))
}
func (e *EmailVerificationApple ) FillFrom (from interface {
GetToken () (value string )
}) {
e .Token = from .GetToken ()
}
func (*EmailVerificationApple ) TypeID () uint32 {
return EmailVerificationAppleTypeID
}
func (*EmailVerificationApple ) TypeName () string {
return "emailVerificationApple"
}
func (e *EmailVerificationApple ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "emailVerificationApple" ,
ID : EmailVerificationAppleTypeID ,
}
if e == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Token" ,
SchemaName : "token" ,
},
}
return typ
}
func (e *EmailVerificationApple ) Encode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerificationApple#96d074fd as nil" )
}
b .PutID (EmailVerificationAppleTypeID )
return e .EncodeBare (b )
}
func (e *EmailVerificationApple ) EncodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't encode emailVerificationApple#96d074fd as nil" )
}
b .PutString (e .Token )
return nil
}
func (e *EmailVerificationApple ) Decode (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerificationApple#96d074fd to nil" )
}
if err := b .ConsumeID (EmailVerificationAppleTypeID ); err != nil {
return fmt .Errorf ("unable to decode emailVerificationApple#96d074fd: %w" , err )
}
return e .DecodeBare (b )
}
func (e *EmailVerificationApple ) DecodeBare (b *bin .Buffer ) error {
if e == nil {
return fmt .Errorf ("can't decode emailVerificationApple#96d074fd to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode emailVerificationApple#96d074fd: field token: %w" , err )
}
e .Token = value
}
return nil
}
func (e *EmailVerificationApple ) GetToken () (value string ) {
if e == nil {
return
}
return e .Token
}
const EmailVerificationClassName = "EmailVerification"
type EmailVerificationClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () EmailVerificationClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeEmailVerification (buf *bin .Buffer ) (EmailVerificationClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case EmailVerificationCodeTypeID :
v := EmailVerificationCode {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmailVerificationClass: %w" , err )
}
return &v , nil
case EmailVerificationGoogleTypeID :
v := EmailVerificationGoogle {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmailVerificationClass: %w" , err )
}
return &v , nil
case EmailVerificationAppleTypeID :
v := EmailVerificationApple {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode EmailVerificationClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode EmailVerificationClass: %w" , bin .NewUnexpectedID (id ))
}
}
type EmailVerificationBox struct {
EmailVerification EmailVerificationClass
}
func (b *EmailVerificationBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode EmailVerificationBox to nil" )
}
v , err := DecodeEmailVerification (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .EmailVerification = v
return nil
}
func (b *EmailVerificationBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .EmailVerification == nil {
return fmt .Errorf ("unable to encode EmailVerificationClass as nil" )
}
return b .EmailVerification .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 .