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 URLAuthResultRequest struct {
Flags bin .Fields
RequestWriteAccess bool
Bot UserClass
Domain string
}
const URLAuthResultRequestTypeID = 0x92d33a0e
func (u URLAuthResultRequest ) construct () URLAuthResultClass { return &u }
var (
_ bin .Encoder = &URLAuthResultRequest {}
_ bin .Decoder = &URLAuthResultRequest {}
_ bin .BareEncoder = &URLAuthResultRequest {}
_ bin .BareDecoder = &URLAuthResultRequest {}
_ URLAuthResultClass = &URLAuthResultRequest {}
)
func (u *URLAuthResultRequest ) Zero () bool {
if u == nil {
return true
}
if !(u .Flags .Zero ()) {
return false
}
if !(u .RequestWriteAccess == false ) {
return false
}
if !(u .Bot == nil ) {
return false
}
if !(u .Domain == "" ) {
return false
}
return true
}
func (u *URLAuthResultRequest ) String () string {
if u == nil {
return "URLAuthResultRequest(nil)"
}
type Alias URLAuthResultRequest
return fmt .Sprintf ("URLAuthResultRequest%+v" , Alias (*u ))
}
func (u *URLAuthResultRequest ) FillFrom (from interface {
GetRequestWriteAccess () (value bool )
GetBot () (value UserClass )
GetDomain () (value string )
}) {
u .RequestWriteAccess = from .GetRequestWriteAccess ()
u .Bot = from .GetBot ()
u .Domain = from .GetDomain ()
}
func (*URLAuthResultRequest ) TypeID () uint32 {
return URLAuthResultRequestTypeID
}
func (*URLAuthResultRequest ) TypeName () string {
return "urlAuthResultRequest"
}
func (u *URLAuthResultRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "urlAuthResultRequest" ,
ID : URLAuthResultRequestTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "RequestWriteAccess" ,
SchemaName : "request_write_access" ,
Null : !u .Flags .Has (0 ),
},
{
Name : "Bot" ,
SchemaName : "bot" ,
},
{
Name : "Domain" ,
SchemaName : "domain" ,
},
}
return typ
}
func (u *URLAuthResultRequest ) SetFlags () {
if !(u .RequestWriteAccess == false ) {
u .Flags .Set (0 )
}
}
func (u *URLAuthResultRequest ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode urlAuthResultRequest#92d33a0e as nil" )
}
b .PutID (URLAuthResultRequestTypeID )
return u .EncodeBare (b )
}
func (u *URLAuthResultRequest ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode urlAuthResultRequest#92d33a0e as nil" )
}
u .SetFlags ()
if err := u .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode urlAuthResultRequest#92d33a0e: field flags: %w" , err )
}
if u .Bot == nil {
return fmt .Errorf ("unable to encode urlAuthResultRequest#92d33a0e: field bot is nil" )
}
if err := u .Bot .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode urlAuthResultRequest#92d33a0e: field bot: %w" , err )
}
b .PutString (u .Domain )
return nil
}
func (u *URLAuthResultRequest ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode urlAuthResultRequest#92d33a0e to nil" )
}
if err := b .ConsumeID (URLAuthResultRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode urlAuthResultRequest#92d33a0e: %w" , err )
}
return u .DecodeBare (b )
}
func (u *URLAuthResultRequest ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode urlAuthResultRequest#92d33a0e to nil" )
}
{
if err := u .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode urlAuthResultRequest#92d33a0e: field flags: %w" , err )
}
}
u .RequestWriteAccess = u .Flags .Has (0 )
{
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode urlAuthResultRequest#92d33a0e: field bot: %w" , err )
}
u .Bot = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode urlAuthResultRequest#92d33a0e: field domain: %w" , err )
}
u .Domain = value
}
return nil
}
func (u *URLAuthResultRequest ) SetRequestWriteAccess (value bool ) {
if value {
u .Flags .Set (0 )
u .RequestWriteAccess = true
} else {
u .Flags .Unset (0 )
u .RequestWriteAccess = false
}
}
func (u *URLAuthResultRequest ) GetRequestWriteAccess () (value bool ) {
if u == nil {
return
}
return u .Flags .Has (0 )
}
func (u *URLAuthResultRequest ) GetBot () (value UserClass ) {
if u == nil {
return
}
return u .Bot
}
func (u *URLAuthResultRequest ) GetDomain () (value string ) {
if u == nil {
return
}
return u .Domain
}
type URLAuthResultAccepted struct {
URL string
}
const URLAuthResultAcceptedTypeID = 0x8f8c0e4e
func (u URLAuthResultAccepted ) construct () URLAuthResultClass { return &u }
var (
_ bin .Encoder = &URLAuthResultAccepted {}
_ bin .Decoder = &URLAuthResultAccepted {}
_ bin .BareEncoder = &URLAuthResultAccepted {}
_ bin .BareDecoder = &URLAuthResultAccepted {}
_ URLAuthResultClass = &URLAuthResultAccepted {}
)
func (u *URLAuthResultAccepted ) Zero () bool {
if u == nil {
return true
}
if !(u .URL == "" ) {
return false
}
return true
}
func (u *URLAuthResultAccepted ) String () string {
if u == nil {
return "URLAuthResultAccepted(nil)"
}
type Alias URLAuthResultAccepted
return fmt .Sprintf ("URLAuthResultAccepted%+v" , Alias (*u ))
}
func (u *URLAuthResultAccepted ) FillFrom (from interface {
GetURL () (value string )
}) {
u .URL = from .GetURL ()
}
func (*URLAuthResultAccepted ) TypeID () uint32 {
return URLAuthResultAcceptedTypeID
}
func (*URLAuthResultAccepted ) TypeName () string {
return "urlAuthResultAccepted"
}
func (u *URLAuthResultAccepted ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "urlAuthResultAccepted" ,
ID : URLAuthResultAcceptedTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "URL" ,
SchemaName : "url" ,
},
}
return typ
}
func (u *URLAuthResultAccepted ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode urlAuthResultAccepted#8f8c0e4e as nil" )
}
b .PutID (URLAuthResultAcceptedTypeID )
return u .EncodeBare (b )
}
func (u *URLAuthResultAccepted ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode urlAuthResultAccepted#8f8c0e4e as nil" )
}
b .PutString (u .URL )
return nil
}
func (u *URLAuthResultAccepted ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode urlAuthResultAccepted#8f8c0e4e to nil" )
}
if err := b .ConsumeID (URLAuthResultAcceptedTypeID ); err != nil {
return fmt .Errorf ("unable to decode urlAuthResultAccepted#8f8c0e4e: %w" , err )
}
return u .DecodeBare (b )
}
func (u *URLAuthResultAccepted ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode urlAuthResultAccepted#8f8c0e4e to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode urlAuthResultAccepted#8f8c0e4e: field url: %w" , err )
}
u .URL = value
}
return nil
}
func (u *URLAuthResultAccepted ) GetURL () (value string ) {
if u == nil {
return
}
return u .URL
}
type URLAuthResultDefault struct {
}
const URLAuthResultDefaultTypeID = 0xa9d6db1f
func (u URLAuthResultDefault ) construct () URLAuthResultClass { return &u }
var (
_ bin .Encoder = &URLAuthResultDefault {}
_ bin .Decoder = &URLAuthResultDefault {}
_ bin .BareEncoder = &URLAuthResultDefault {}
_ bin .BareDecoder = &URLAuthResultDefault {}
_ URLAuthResultClass = &URLAuthResultDefault {}
)
func (u *URLAuthResultDefault ) Zero () bool {
if u == nil {
return true
}
return true
}
func (u *URLAuthResultDefault ) String () string {
if u == nil {
return "URLAuthResultDefault(nil)"
}
type Alias URLAuthResultDefault
return fmt .Sprintf ("URLAuthResultDefault%+v" , Alias (*u ))
}
func (*URLAuthResultDefault ) TypeID () uint32 {
return URLAuthResultDefaultTypeID
}
func (*URLAuthResultDefault ) TypeName () string {
return "urlAuthResultDefault"
}
func (u *URLAuthResultDefault ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "urlAuthResultDefault" ,
ID : URLAuthResultDefaultTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {}
return typ
}
func (u *URLAuthResultDefault ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode urlAuthResultDefault#a9d6db1f as nil" )
}
b .PutID (URLAuthResultDefaultTypeID )
return u .EncodeBare (b )
}
func (u *URLAuthResultDefault ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode urlAuthResultDefault#a9d6db1f as nil" )
}
return nil
}
func (u *URLAuthResultDefault ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode urlAuthResultDefault#a9d6db1f to nil" )
}
if err := b .ConsumeID (URLAuthResultDefaultTypeID ); err != nil {
return fmt .Errorf ("unable to decode urlAuthResultDefault#a9d6db1f: %w" , err )
}
return u .DecodeBare (b )
}
func (u *URLAuthResultDefault ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode urlAuthResultDefault#a9d6db1f to nil" )
}
return nil
}
const URLAuthResultClassName = "UrlAuthResult"
type URLAuthResultClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () URLAuthResultClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeURLAuthResult (buf *bin .Buffer ) (URLAuthResultClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case URLAuthResultRequestTypeID :
v := URLAuthResultRequest {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode URLAuthResultClass: %w" , err )
}
return &v , nil
case URLAuthResultAcceptedTypeID :
v := URLAuthResultAccepted {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode URLAuthResultClass: %w" , err )
}
return &v , nil
case URLAuthResultDefaultTypeID :
v := URLAuthResultDefault {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode URLAuthResultClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode URLAuthResultClass: %w" , bin .NewUnexpectedID (id ))
}
}
type URLAuthResultBox struct {
UrlAuthResult URLAuthResultClass
}
func (b *URLAuthResultBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode URLAuthResultBox to nil" )
}
v , err := DecodeURLAuthResult (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .UrlAuthResult = v
return nil
}
func (b *URLAuthResultBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .UrlAuthResult == nil {
return fmt .Errorf ("unable to encode URLAuthResultClass as nil" )
}
return b .UrlAuthResult .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 .