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 AccountAuthorizationForm struct {
Flags bin .Fields
RequiredTypes []SecureRequiredTypeClass
Values []SecureValue
Errors []SecureValueErrorClass
Users []UserClass
PrivacyPolicyURL string
}
const AccountAuthorizationFormTypeID = 0xad2e1cd8
var (
_ bin .Encoder = &AccountAuthorizationForm {}
_ bin .Decoder = &AccountAuthorizationForm {}
_ bin .BareEncoder = &AccountAuthorizationForm {}
_ bin .BareDecoder = &AccountAuthorizationForm {}
)
func (a *AccountAuthorizationForm ) Zero () bool {
if a == nil {
return true
}
if !(a .Flags .Zero ()) {
return false
}
if !(a .RequiredTypes == nil ) {
return false
}
if !(a .Values == nil ) {
return false
}
if !(a .Errors == nil ) {
return false
}
if !(a .Users == nil ) {
return false
}
if !(a .PrivacyPolicyURL == "" ) {
return false
}
return true
}
func (a *AccountAuthorizationForm ) String () string {
if a == nil {
return "AccountAuthorizationForm(nil)"
}
type Alias AccountAuthorizationForm
return fmt .Sprintf ("AccountAuthorizationForm%+v" , Alias (*a ))
}
func (a *AccountAuthorizationForm ) FillFrom (from interface {
GetRequiredTypes () (value []SecureRequiredTypeClass )
GetValues () (value []SecureValue )
GetErrors () (value []SecureValueErrorClass )
GetUsers () (value []UserClass )
GetPrivacyPolicyURL () (value string , ok bool )
}) {
a .RequiredTypes = from .GetRequiredTypes ()
a .Values = from .GetValues ()
a .Errors = from .GetErrors ()
a .Users = from .GetUsers ()
if val , ok := from .GetPrivacyPolicyURL (); ok {
a .PrivacyPolicyURL = val
}
}
func (*AccountAuthorizationForm ) TypeID () uint32 {
return AccountAuthorizationFormTypeID
}
func (*AccountAuthorizationForm ) TypeName () string {
return "account.authorizationForm"
}
func (a *AccountAuthorizationForm ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.authorizationForm" ,
ID : AccountAuthorizationFormTypeID ,
}
if a == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "RequiredTypes" ,
SchemaName : "required_types" ,
},
{
Name : "Values" ,
SchemaName : "values" ,
},
{
Name : "Errors" ,
SchemaName : "errors" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "PrivacyPolicyURL" ,
SchemaName : "privacy_policy_url" ,
Null : !a .Flags .Has (0 ),
},
}
return typ
}
func (a *AccountAuthorizationForm ) SetFlags () {
if !(a .PrivacyPolicyURL == "" ) {
a .Flags .Set (0 )
}
}
func (a *AccountAuthorizationForm ) Encode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode account.authorizationForm#ad2e1cd8 as nil" )
}
b .PutID (AccountAuthorizationFormTypeID )
return a .EncodeBare (b )
}
func (a *AccountAuthorizationForm ) EncodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't encode account.authorizationForm#ad2e1cd8 as nil" )
}
a .SetFlags ()
if err := a .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field flags: %w" , err )
}
b .PutVectorHeader (len (a .RequiredTypes ))
for idx , v := range a .RequiredTypes {
if v == nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field required_types element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field required_types element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Values ))
for idx , v := range a .Values {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field values element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Errors ))
for idx , v := range a .Errors {
if v == nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field errors element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field errors element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (a .Users ))
for idx , v := range a .Users {
if v == nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.authorizationForm#ad2e1cd8: field users element with index %d: %w" , idx , err )
}
}
if a .Flags .Has (0 ) {
b .PutString (a .PrivacyPolicyURL )
}
return nil
}
func (a *AccountAuthorizationForm ) Decode (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode account.authorizationForm#ad2e1cd8 to nil" )
}
if err := b .ConsumeID (AccountAuthorizationFormTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: %w" , err )
}
return a .DecodeBare (b )
}
func (a *AccountAuthorizationForm ) DecodeBare (b *bin .Buffer ) error {
if a == nil {
return fmt .Errorf ("can't decode account.authorizationForm#ad2e1cd8 to nil" )
}
{
if err := a .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field flags: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field required_types: %w" , err )
}
if headerLen > 0 {
a .RequiredTypes = make ([]SecureRequiredTypeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeSecureRequiredType (b )
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field required_types: %w" , err )
}
a .RequiredTypes = append (a .RequiredTypes , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field values: %w" , err )
}
if headerLen > 0 {
a .Values = make ([]SecureValue , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value SecureValue
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field values: %w" , err )
}
a .Values = append (a .Values , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field errors: %w" , err )
}
if headerLen > 0 {
a .Errors = make ([]SecureValueErrorClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeSecureValueError (b )
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field errors: %w" , err )
}
a .Errors = append (a .Errors , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field users: %w" , err )
}
if headerLen > 0 {
a .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field users: %w" , err )
}
a .Users = append (a .Users , value )
}
}
if a .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.authorizationForm#ad2e1cd8: field privacy_policy_url: %w" , err )
}
a .PrivacyPolicyURL = value
}
return nil
}
func (a *AccountAuthorizationForm ) GetRequiredTypes () (value []SecureRequiredTypeClass ) {
if a == nil {
return
}
return a .RequiredTypes
}
func (a *AccountAuthorizationForm ) GetValues () (value []SecureValue ) {
if a == nil {
return
}
return a .Values
}
func (a *AccountAuthorizationForm ) GetErrors () (value []SecureValueErrorClass ) {
if a == nil {
return
}
return a .Errors
}
func (a *AccountAuthorizationForm ) GetUsers () (value []UserClass ) {
if a == nil {
return
}
return a .Users
}
func (a *AccountAuthorizationForm ) SetPrivacyPolicyURL (value string ) {
a .Flags .Set (0 )
a .PrivacyPolicyURL = value
}
func (a *AccountAuthorizationForm ) GetPrivacyPolicyURL () (value string , ok bool ) {
if a == nil {
return
}
if !a .Flags .Has (0 ) {
return value , false
}
return a .PrivacyPolicyURL , true
}
func (a *AccountAuthorizationForm ) MapRequiredTypes () (value SecureRequiredTypeClassArray ) {
return SecureRequiredTypeClassArray (a .RequiredTypes )
}
func (a *AccountAuthorizationForm ) MapErrors () (value SecureValueErrorClassArray ) {
return SecureValueErrorClassArray (a .Errors )
}
func (a *AccountAuthorizationForm ) MapUsers () (value UserClassArray ) {
return UserClassArray (a .Users )
}
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 .