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