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 AccountGetSecureValueRequest struct {
Types []SecureValueTypeClass
}
const AccountGetSecureValueRequestTypeID = 0x73665bc2
var (
_ bin .Encoder = &AccountGetSecureValueRequest {}
_ bin .Decoder = &AccountGetSecureValueRequest {}
_ bin .BareEncoder = &AccountGetSecureValueRequest {}
_ bin .BareDecoder = &AccountGetSecureValueRequest {}
)
func (g *AccountGetSecureValueRequest ) Zero () bool {
if g == nil {
return true
}
if !(g .Types == nil ) {
return false
}
return true
}
func (g *AccountGetSecureValueRequest ) String () string {
if g == nil {
return "AccountGetSecureValueRequest(nil)"
}
type Alias AccountGetSecureValueRequest
return fmt .Sprintf ("AccountGetSecureValueRequest%+v" , Alias (*g ))
}
func (g *AccountGetSecureValueRequest ) FillFrom (from interface {
GetTypes () (value []SecureValueTypeClass )
}) {
g .Types = from .GetTypes ()
}
func (*AccountGetSecureValueRequest ) TypeID () uint32 {
return AccountGetSecureValueRequestTypeID
}
func (*AccountGetSecureValueRequest ) TypeName () string {
return "account.getSecureValue"
}
func (g *AccountGetSecureValueRequest ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "account.getSecureValue" ,
ID : AccountGetSecureValueRequestTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Types" ,
SchemaName : "types" ,
},
}
return typ
}
func (g *AccountGetSecureValueRequest ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode account.getSecureValue#73665bc2 as nil" )
}
b .PutID (AccountGetSecureValueRequestTypeID )
return g .EncodeBare (b )
}
func (g *AccountGetSecureValueRequest ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode account.getSecureValue#73665bc2 as nil" )
}
b .PutVectorHeader (len (g .Types ))
for idx , v := range g .Types {
if v == nil {
return fmt .Errorf ("unable to encode account.getSecureValue#73665bc2: field types element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode account.getSecureValue#73665bc2: field types element with index %d: %w" , idx , err )
}
}
return nil
}
func (g *AccountGetSecureValueRequest ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode account.getSecureValue#73665bc2 to nil" )
}
if err := b .ConsumeID (AccountGetSecureValueRequestTypeID ); err != nil {
return fmt .Errorf ("unable to decode account.getSecureValue#73665bc2: %w" , err )
}
return g .DecodeBare (b )
}
func (g *AccountGetSecureValueRequest ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode account.getSecureValue#73665bc2 to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode account.getSecureValue#73665bc2: field types: %w" , err )
}
if headerLen > 0 {
g .Types = make ([]SecureValueTypeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeSecureValueType (b )
if err != nil {
return fmt .Errorf ("unable to decode account.getSecureValue#73665bc2: field types: %w" , err )
}
g .Types = append (g .Types , value )
}
}
return nil
}
func (g *AccountGetSecureValueRequest ) GetTypes () (value []SecureValueTypeClass ) {
if g == nil {
return
}
return g .Types
}
func (g *AccountGetSecureValueRequest ) MapTypes () (value SecureValueTypeClassArray ) {
return SecureValueTypeClassArray (g .Types )
}
func (c *Client ) AccountGetSecureValue (ctx context .Context , types []SecureValueTypeClass ) ([]SecureValue , error ) {
var result SecureValueVector
request := &AccountGetSecureValueRequest {
Types : types ,
}
if err := c .rpc .Invoke (ctx , request , &result ); err != nil {
return nil , err
}
return []SecureValue (result .Elems ), 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 .