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 {
PhoneNumber string
PhoneCodeHash string
FirstName string
LastName string
}
const AuthSignUpRequestTypeID = 0x80eee427
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 .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 {
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
GetFirstName () (value string )
GetLastName () (value string )
}) {
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 : "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 ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode auth.signUp#80eee427 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#80eee427 as nil" )
}
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#80eee427 to nil" )
}
if err := b .ConsumeID (AuthSignUpRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.signUp#80eee427: %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#80eee427 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#80eee427: field phone_number: %w" , err )
}
s .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#80eee427: field phone_code_hash: %w" , err )
}
s .PhoneCodeHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#80eee427: field first_name: %w" , err )
}
s .FirstName = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.signUp#80eee427: field last_name: %w" , err )
}
s .LastName = value
}
return nil
}
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.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 .