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 AuthSignUpRequest struct {
Flags bin .Fields
NoJoinedNotifications bool
PhoneNumber string
PhoneCodeHash string
FirstName string
LastName string
}
const AuthSignUpRequestTypeID = 0xaac7b717
var (
_ bin .Encoder = &AuthSignUpRequest {}
_ bin .Decoder = &AuthSignUpRequest {}
_ bin .BareEncoder = &AuthSignUpRequest {}
_ bin .BareDecoder = &AuthSignUpRequest {}
)
func (s *AuthSignUpRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .NoJoinedNotifications == false ) {
return false
}
if !(s .PhoneNumber == "" ) {
return false
}
if !(s .PhoneCodeHash == "" ) {
return false
}
if !(s .FirstName == "" ) {
return false
}
if !(s .LastName == "" ) {
return false
}
return true
}
func (s *AuthSignUpRequest ) String () string {
if s == nil {
return "AuthSignUpRequest(nil)"
}
type Alias AuthSignUpRequest
return fmt .Sprintf ("AuthSignUpRequest%+v" , Alias (*s ))
}
func (s *AuthSignUpRequest ) FillFrom (from interface {
GetNoJoinedNotifications () (value bool )
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
GetFirstName () (value string )
GetLastName () (value string )
}) {
s .NoJoinedNotifications = from .GetNoJoinedNotifications ()
s .PhoneNumber = from .GetPhoneNumber ()
s .PhoneCodeHash = from .GetPhoneCodeHash ()
s .FirstName = from .GetFirstName ()
s .LastName = from .GetLastName ()
}
func (*AuthSignUpRequest ) TypeID () uint32 {
return AuthSignUpRequestTypeID
}
func (*AuthSignUpRequest ) TypeName () string {
return "auth.signUp"
}
func (s *AuthSignUpRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.signUp" ,
ID : AuthSignUpRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "NoJoinedNotifications" ,
SchemaName : "no_joined_notifications" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "PhoneCodeHash" ,
SchemaName : "phone_code_hash" ,
},
{
Name : "FirstName" ,
SchemaName : "first_name" ,
},
{
Name : "LastName" ,
SchemaName : "last_name" ,
},
}
return typ
}
func (s *AuthSignUpRequest ) SetFlags () {
if !(s .NoJoinedNotifications == false ) {
s .Flags .Set (0 )
}
}
func (s *AuthSignUpRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.signUp#aac7b717 as nil" )
}
b .PutID (AuthSignUpRequestTypeID )
return s .EncodeBare (b )
}
func (s *AuthSignUpRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.signUp#aac7b717 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.signUp#aac7b717: field flags: %w" , err )
}
b .PutString (s .PhoneNumber )
b .PutString (s .PhoneCodeHash )
b .PutString (s .FirstName )
b .PutString (s .LastName )
return nil
}
func (s *AuthSignUpRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.signUp#aac7b717 to nil" )
}
if err := b .ConsumeID (AuthSignUpRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.signUp#aac7b717: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AuthSignUpRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode auth.signUp#aac7b717 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode auth.signUp#aac7b717: field flags: %w" , err )
}
}
s .NoJoinedNotifications = s .Flags .Has (0 )
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#aac7b717: field phone_number: %w" , err )
}
s .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#aac7b717: field phone_code_hash: %w" , err )
}
s .PhoneCodeHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#aac7b717: field first_name: %w" , err )
}
s .FirstName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#aac7b717: field last_name: %w" , err )
}
s .LastName = value
}
return nil
}
func (s *AuthSignUpRequest ) SetNoJoinedNotifications (value bool ) {
if value {
s .Flags .Set (0 )
s .NoJoinedNotifications = true
} else {
s .Flags .Unset (0 )
s .NoJoinedNotifications = false
}
}
func (s *AuthSignUpRequest ) GetNoJoinedNotifications () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (0 )
}
func (s *AuthSignUpRequest ) GetPhoneNumber () (value string ) {
if s == nil {
return
}
return s .PhoneNumber
}
func (s *AuthSignUpRequest ) GetPhoneCodeHash () (value string ) {
if s == nil {
return
}
return s .PhoneCodeHash
}
func (s *AuthSignUpRequest ) GetFirstName () (value string ) {
if s == nil {
return
}
return s .FirstName
}
func (s *AuthSignUpRequest ) GetLastName () (value string ) {
if s == nil {
return
}
return s .LastName
}
func (c *Client ) AuthSignUp (ctx context .Context , request *AuthSignUpRequest ) (AuthAuthorizationClass , error ) {
var result AuthAuthorizationBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .Authorization , nil
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .