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 AccountChangePhoneRequest struct {
PhoneNumber string
PhoneCodeHash string
PhoneCode string
}
const AccountChangePhoneRequestTypeID = 0x70c32edb
var (
_ bin .Encoder = &AccountChangePhoneRequest {}
_ bin .Decoder = &AccountChangePhoneRequest {}
_ bin .BareEncoder = &AccountChangePhoneRequest {}
_ bin .BareDecoder = &AccountChangePhoneRequest {}
)
func (c *AccountChangePhoneRequest ) Zero () bool {
if c == nil {
return true
}
if !(c .PhoneNumber == "" ) {
return false
}
if !(c .PhoneCodeHash == "" ) {
return false
}
if !(c .PhoneCode == "" ) {
return false
}
return true
}
func (c *AccountChangePhoneRequest ) String () string {
if c == nil {
return "AccountChangePhoneRequest(nil)"
}
type Alias AccountChangePhoneRequest
return fmt .Sprintf ("AccountChangePhoneRequest%+v" , Alias (*c ))
}
func (c *AccountChangePhoneRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetPhoneCodeHash () (value string )
GetPhoneCode () (value string )
}) {
c .PhoneNumber = from .GetPhoneNumber ()
c .PhoneCodeHash = from .GetPhoneCodeHash ()
c .PhoneCode = from .GetPhoneCode ()
}
func (*AccountChangePhoneRequest ) TypeID () uint32 {
return AccountChangePhoneRequestTypeID
}
func (*AccountChangePhoneRequest ) TypeName () string {
return "account.changePhone"
}
func (c *AccountChangePhoneRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.changePhone" ,
ID : AccountChangePhoneRequestTypeID ,
}
if c == 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 (c *AccountChangePhoneRequest ) Encode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.changePhone#70c32edb as nil" )
}
b .PutID (AccountChangePhoneRequestTypeID )
return c .EncodeBare (b )
}
func (c *AccountChangePhoneRequest ) EncodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't encode account.changePhone#70c32edb as nil" )
}
b .PutString (c .PhoneNumber )
b .PutString (c .PhoneCodeHash )
b .PutString (c .PhoneCode )
return nil
}
func (c *AccountChangePhoneRequest ) Decode (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.changePhone#70c32edb to nil" )
}
if err := b .ConsumeID (AccountChangePhoneRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.changePhone#70c32edb: %w" , err )
}
return c .DecodeBare (b )
}
func (c *AccountChangePhoneRequest ) DecodeBare (b *bin .Buffer ) error {
if c == nil {
return fmt .Errorf ("can't decode account.changePhone#70c32edb to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.changePhone#70c32edb: field phone_number: %w" , err )
}
c .PhoneNumber = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.changePhone#70c32edb: field phone_code_hash: %w" , err )
}
c .PhoneCodeHash = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.changePhone#70c32edb: field phone_code: %w" , err )
}
c .PhoneCode = value
}
return nil
}
func (c *AccountChangePhoneRequest ) GetPhoneNumber () (value string ) {
if c == nil {
return
}
return c .PhoneNumber
}
func (c *AccountChangePhoneRequest ) GetPhoneCodeHash () (value string ) {
if c == nil {
return
}
return c .PhoneCodeHash
}
func (c *AccountChangePhoneRequest ) GetPhoneCode () (value string ) {
if c == nil {
return
}
return c .PhoneCode
}
func (c *Client ) AccountChangePhone (ctx context .Context , request *AccountChangePhoneRequest ) (UserClass , error ) {
var result UserBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .User , 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 .