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 AccountSendChangePhoneCodeRequest struct {
PhoneNumber string
Settings CodeSettings
}
const AccountSendChangePhoneCodeRequestTypeID = 0x82574ae5
var (
_ bin .Encoder = &AccountSendChangePhoneCodeRequest {}
_ bin .Decoder = &AccountSendChangePhoneCodeRequest {}
_ bin .BareEncoder = &AccountSendChangePhoneCodeRequest {}
_ bin .BareDecoder = &AccountSendChangePhoneCodeRequest {}
)
func (s *AccountSendChangePhoneCodeRequest ) Zero () bool {
if s == nil {
return true
}
if !(s .PhoneNumber == "" ) {
return false
}
if !(s .Settings .Zero ()) {
return false
}
return true
}
func (s *AccountSendChangePhoneCodeRequest ) String () string {
if s == nil {
return "AccountSendChangePhoneCodeRequest(nil)"
}
type Alias AccountSendChangePhoneCodeRequest
return fmt .Sprintf ("AccountSendChangePhoneCodeRequest%+v" , Alias (*s ))
}
func (s *AccountSendChangePhoneCodeRequest ) FillFrom (from interface {
GetPhoneNumber () (value string )
GetSettings () (value CodeSettings )
}) {
s .PhoneNumber = from .GetPhoneNumber ()
s .Settings = from .GetSettings ()
}
func (*AccountSendChangePhoneCodeRequest ) TypeID () uint32 {
return AccountSendChangePhoneCodeRequestTypeID
}
func (*AccountSendChangePhoneCodeRequest ) TypeName () string {
return "account.sendChangePhoneCode"
}
func (s *AccountSendChangePhoneCodeRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.sendChangePhoneCode" ,
ID : AccountSendChangePhoneCodeRequestTypeID ,
}
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 *AccountSendChangePhoneCodeRequest ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.sendChangePhoneCode#82574ae5 as nil" )
}
b .PutID (AccountSendChangePhoneCodeRequestTypeID )
return s .EncodeBare (b )
}
func (s *AccountSendChangePhoneCodeRequest ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode account.sendChangePhoneCode#82574ae5 as nil" )
}
b .PutString (s .PhoneNumber )
if err := s .Settings .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.sendChangePhoneCode#82574ae5: field settings: %w" , err )
}
return nil
}
func (s *AccountSendChangePhoneCodeRequest ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.sendChangePhoneCode#82574ae5 to nil" )
}
if err := b .ConsumeID (AccountSendChangePhoneCodeRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.sendChangePhoneCode#82574ae5: %w" , err )
}
return s .DecodeBare (b )
}
func (s *AccountSendChangePhoneCodeRequest ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode account.sendChangePhoneCode#82574ae5 to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode account.sendChangePhoneCode#82574ae5: field phone_number: %w" , err )
}
s .PhoneNumber = value
}
{
if err := s .Settings .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode account.sendChangePhoneCode#82574ae5: field settings: %w" , err )
}
}
return nil
}
func (s *AccountSendChangePhoneCodeRequest ) GetPhoneNumber () (value string ) {
if s == nil {
return
}
return s .PhoneNumber
}
func (s *AccountSendChangePhoneCodeRequest ) GetSettings () (value CodeSettings ) {
if s == nil {
return
}
return s .Settings
}
func (c *Client ) AccountSendChangePhoneCode (ctx context .Context , request *AccountSendChangePhoneCodeRequest ) (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 .