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 AccountVerifyPhoneRequest struct {
PhoneNumber string
PhoneCodeHash string
PhoneCode string
}
const AccountVerifyPhoneRequestTypeID = 0x4dd3a7f6
var (
_ bin .Encoder = &AccountVerifyPhoneRequest {}
_ bin .Decoder = &AccountVerifyPhoneRequest {}
_ bin .BareEncoder = &AccountVerifyPhoneRequest {}
_ bin .BareDecoder = &AccountVerifyPhoneRequest {}
)
func (v *AccountVerifyPhoneRequest ) Zero () bool {
if v == nil {
return true
}
if !(v .PhoneNumber == "" ) {
return false
}
if !(v .PhoneCodeHash == "" ) {
return false
}
if !(v .PhoneCode == "" ) {
return false
}
return true
}
func (v *AccountVerifyPhoneRequest ) String () string {
if v == nil {
return "AccountVerifyPhoneRequest(nil)"
}
type Alias AccountVerifyPhoneRequest
return fmt .Sprintf ("AccountVerifyPhoneRequest%+v" , Alias (*v ))
}
func (v *AccountVerifyPhoneRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
GetPhoneCode () (value string )
}) {
v .PhoneNumber = from .GetPhoneNumber ()
v .PhoneCodeHash = from .GetPhoneCodeHash ()
v .PhoneCode = from .GetPhoneCode ()
}
func (*AccountVerifyPhoneRequest ) TypeID () uint32 {
return AccountVerifyPhoneRequestTypeID
}
func (*AccountVerifyPhoneRequest ) TypeName () string {
return "account.verifyPhone"
}
func (v *AccountVerifyPhoneRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.verifyPhone" ,
ID : AccountVerifyPhoneRequestTypeID ,
}
if v == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "PhoneCodeHash" ,
SchemaName : "phone_code_hash" ,
},
{
Name : "PhoneCode" ,
SchemaName : "phone_code" ,
},
}
return typ
}
func (v *AccountVerifyPhoneRequest ) Encode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode account.verifyPhone#4dd3a7f6 as nil" )
}
b .PutID (AccountVerifyPhoneRequestTypeID )
return v .EncodeBare (b )
}
func (v *AccountVerifyPhoneRequest ) EncodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't encode account.verifyPhone#4dd3a7f6 as nil" )
}
b .PutString (v .PhoneNumber )
b .PutString (v .PhoneCodeHash )
b .PutString (v .PhoneCode )
return nil
}
func (v *AccountVerifyPhoneRequest ) Decode (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode account.verifyPhone#4dd3a7f6 to nil" )
}
if err := b .ConsumeID (AccountVerifyPhoneRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.verifyPhone#4dd3a7f6: %w" , err )
}
return v .DecodeBare (b )
}
func (v *AccountVerifyPhoneRequest ) DecodeBare (b *bin .Buffer ) error {
if v == nil {
return fmt .Errorf ("can't decode account.verifyPhone#4dd3a7f6 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.verifyPhone#4dd3a7f6: field phone_number: %w" , err )
}
v .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.verifyPhone#4dd3a7f6: field phone_code_hash: %w" , err )
}
v .PhoneCodeHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.verifyPhone#4dd3a7f6: field phone_code: %w" , err )
}
v .PhoneCode = value
}
return nil
}
func (v *AccountVerifyPhoneRequest ) GetPhoneNumber () (value string ) {
if v == nil {
return
}
return v .PhoneNumber
}
func (v *AccountVerifyPhoneRequest ) GetPhoneCodeHash () (value string ) {
if v == nil {
return
}
return v .PhoneCodeHash
}
func (v *AccountVerifyPhoneRequest ) GetPhoneCode () (value string ) {
if v == nil {
return
}
return v .PhoneCode
}
func (c *Client ) AccountVerifyPhone (ctx context .Context , request *AccountVerifyPhoneRequest ) (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 .