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 AccountSendVerifyPhoneCodeRequest struct {
PhoneNumber string
Settings CodeSettings
}
const AccountSendVerifyPhoneCodeRequestTypeID = 0xa5a356f9
var (
_ bin .Encoder = &AccountSendVerifyPhoneCodeRequest {}
_ bin .Decoder = &AccountSendVerifyPhoneCodeRequest {}
_ bin .BareEncoder = &AccountSendVerifyPhoneCodeRequest {}
_ bin .BareDecoder = &AccountSendVerifyPhoneCodeRequest {}
)
func (s *AccountSendVerifyPhoneCodeRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .PhoneNumber == "" ) {
return false
}
if !(s .Settings .Zero ()) {
return false
}
return true
}
func (s *AccountSendVerifyPhoneCodeRequest ) String () string {
if s == nil {
return "AccountSendVerifyPhoneCodeRequest(nil)"
}
type Alias AccountSendVerifyPhoneCodeRequest
return fmt .Sprintf ("AccountSendVerifyPhoneCodeRequest%+v" , Alias (*s ))
}
func (s *AccountSendVerifyPhoneCodeRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetSettings () (value CodeSettings )
}) {
s .PhoneNumber = from .GetPhoneNumber ()
s .Settings = from .GetSettings ()
}
func (*AccountSendVerifyPhoneCodeRequest ) TypeID () uint32 {
return AccountSendVerifyPhoneCodeRequestTypeID
}
func (*AccountSendVerifyPhoneCodeRequest ) TypeName () string {
return "account.sendVerifyPhoneCode"
}
func (s *AccountSendVerifyPhoneCodeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.sendVerifyPhoneCode" ,
ID : AccountSendVerifyPhoneCodeRequestTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "PhoneNumber" ,
SchemaName : "phone_number" ,
},
{
Name : "Settings" ,
SchemaName : "settings" ,
},
}
return typ
}
func (s *AccountSendVerifyPhoneCodeRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.sendVerifyPhoneCode#a5a356f9 as nil" )
}
b .PutID (AccountSendVerifyPhoneCodeRequestTypeID )
return s .EncodeBare (b )
}
func (s *AccountSendVerifyPhoneCodeRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.sendVerifyPhoneCode#a5a356f9 as nil" )
}
b .PutString (s .PhoneNumber )
if err := s .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.sendVerifyPhoneCode#a5a356f9: field settings: %w" , err )
}
return nil
}
func (s *AccountSendVerifyPhoneCodeRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.sendVerifyPhoneCode#a5a356f9 to nil" )
}
if err := b .ConsumeID (AccountSendVerifyPhoneCodeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.sendVerifyPhoneCode#a5a356f9: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AccountSendVerifyPhoneCodeRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.sendVerifyPhoneCode#a5a356f9 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.sendVerifyPhoneCode#a5a356f9: field phone_number: %w" , err )
}
s .PhoneNumber = value
}
{
if err := s .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.sendVerifyPhoneCode#a5a356f9: field settings: %w" , err )
}
}
return nil
}
func (s *AccountSendVerifyPhoneCodeRequest ) GetPhoneNumber () (value string ) {
if s == nil {
return
}
return s .PhoneNumber
}
func (s *AccountSendVerifyPhoneCodeRequest ) GetSettings () (value CodeSettings ) {
if s == nil {
return
}
return s .Settings
}
func (c *Client ) AccountSendVerifyPhoneCode (ctx context .Context , request *AccountSendVerifyPhoneCodeRequest ) (AuthSentCodeClass , error ) {
var result AuthSentCodeBox
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return result .SentCode , 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 .