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 AuthRequestFirebaseSMSRequest struct {
Flags bin .Fields
PhoneNumber string
PhoneCodeHash string
SafetyNetToken string
IosPushSecret string
}
const AuthRequestFirebaseSMSRequestTypeID = 0x89464b50
var (
_ bin .Encoder = &AuthRequestFirebaseSMSRequest {}
_ bin .Decoder = &AuthRequestFirebaseSMSRequest {}
_ bin .BareEncoder = &AuthRequestFirebaseSMSRequest {}
_ bin .BareDecoder = &AuthRequestFirebaseSMSRequest {}
)
func (r *AuthRequestFirebaseSMSRequest ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .PhoneNumber == "" ) {
return false
}
if !(r .PhoneCodeHash == "" ) {
return false
}
if !(r .SafetyNetToken == "" ) {
return false
}
if !(r .IosPushSecret == "" ) {
return false
}
return true
}
func (r *AuthRequestFirebaseSMSRequest ) String () string {
if r == nil {
return "AuthRequestFirebaseSMSRequest(nil)"
}
type Alias AuthRequestFirebaseSMSRequest
return fmt .Sprintf ("AuthRequestFirebaseSMSRequest%+v" , Alias (*r ))
}
func (r *AuthRequestFirebaseSMSRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
GetSafetyNetToken () (value string , ok bool )
GetIosPushSecret () (value string , ok bool )
}) {
r .PhoneNumber = from .GetPhoneNumber ()
r .PhoneCodeHash = from .GetPhoneCodeHash ()
if val , ok := from .GetSafetyNetToken (); ok {
r .SafetyNetToken = val
}
if val , ok := from .GetIosPushSecret (); ok {
r .IosPushSecret = val
}
}
func (*AuthRequestFirebaseSMSRequest ) TypeID () uint32 {
return AuthRequestFirebaseSMSRequestTypeID
}
func (*AuthRequestFirebaseSMSRequest ) TypeName () string {
return "auth.requestFirebaseSms"
}
func (r *AuthRequestFirebaseSMSRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "auth.requestFirebaseSms" ,
ID : AuthRequestFirebaseSMSRequestTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "PhoneCodeHash" ,
SchemaName : "phone_code_hash" ,
},
{
Name : "SafetyNetToken" ,
SchemaName : "safety_net_token" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "IosPushSecret" ,
SchemaName : "ios_push_secret" ,
Null : !r .Flags .Has (1 ),
},
}
return typ
}
func (r *AuthRequestFirebaseSMSRequest ) SetFlags () {
if !(r .SafetyNetToken == "" ) {
r .Flags .Set (0 )
}
if !(r .IosPushSecret == "" ) {
r .Flags .Set (1 )
}
}
func (r *AuthRequestFirebaseSMSRequest ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode auth.requestFirebaseSms#89464b50 as nil" )
}
b .PutID (AuthRequestFirebaseSMSRequestTypeID )
return r .EncodeBare (b )
}
func (r *AuthRequestFirebaseSMSRequest ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode auth.requestFirebaseSms#89464b50 as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode auth.requestFirebaseSms#89464b50: field flags: %w" , err )
}
b .PutString (r .PhoneNumber )
b .PutString (r .PhoneCodeHash )
if r .Flags .Has (0 ) {
b .PutString (r .SafetyNetToken )
}
if r .Flags .Has (1 ) {
b .PutString (r .IosPushSecret )
}
return nil
}
func (r *AuthRequestFirebaseSMSRequest ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode auth.requestFirebaseSms#89464b50 to nil" )
}
if err := b .ConsumeID (AuthRequestFirebaseSMSRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode auth.requestFirebaseSms#89464b50: %w" , err )
}
return r .DecodeBare (b )
}
func (r *AuthRequestFirebaseSMSRequest ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode auth.requestFirebaseSms#89464b50 to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode auth.requestFirebaseSms#89464b50: field flags: %w" , err )
}
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.requestFirebaseSms#89464b50: field phone_number: %w" , err )
}
r .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.requestFirebaseSms#89464b50: field phone_code_hash: %w" , err )
}
r .PhoneCodeHash = value
}
if r .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.requestFirebaseSms#89464b50: field safety_net_token: %w" , err )
}
r .SafetyNetToken = value
}
if r .Flags .Has (1 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode auth.requestFirebaseSms#89464b50: field ios_push_secret: %w" , err )
}
r .IosPushSecret = value
}
return nil
}
func (r *AuthRequestFirebaseSMSRequest ) GetPhoneNumber () (value string ) {
if r == nil {
return
}
return r .PhoneNumber
}
func (r *AuthRequestFirebaseSMSRequest ) GetPhoneCodeHash () (value string ) {
if r == nil {
return
}
return r .PhoneCodeHash
}
func (r *AuthRequestFirebaseSMSRequest ) SetSafetyNetToken (value string ) {
r .Flags .Set (0 )
r .SafetyNetToken = value
}
func (r *AuthRequestFirebaseSMSRequest ) GetSafetyNetToken () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (0 ) {
return value , false
}
return r .SafetyNetToken , true
}
func (r *AuthRequestFirebaseSMSRequest ) SetIosPushSecret (value string ) {
r .Flags .Set (1 )
r .IosPushSecret = value
}
func (r *AuthRequestFirebaseSMSRequest ) GetIosPushSecret () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .IosPushSecret , true
}
func (c *Client ) AuthRequestFirebaseSMS (ctx context .Context , request *AuthRequestFirebaseSMSRequest ) (bool , error ) {
var result BoolBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return false , err
}
_ , ok := result .Bool .(*BoolTrue )
return ok , 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 .