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 PaymentsStarGiftUpgradeAttributes struct {
Attributes []StarGiftAttributeClass
}
const PaymentsStarGiftUpgradeAttributesTypeID = 0x46c6e36f
var (
_ bin .Encoder = &PaymentsStarGiftUpgradeAttributes {}
_ bin .Decoder = &PaymentsStarGiftUpgradeAttributes {}
_ bin .BareEncoder = &PaymentsStarGiftUpgradeAttributes {}
_ bin .BareDecoder = &PaymentsStarGiftUpgradeAttributes {}
)
func (s *PaymentsStarGiftUpgradeAttributes ) Zero () bool {
if s == nil {
return true
}
if !(s .Attributes == nil ) {
return false
}
return true
}
func (s *PaymentsStarGiftUpgradeAttributes ) String () string {
if s == nil {
return "PaymentsStarGiftUpgradeAttributes(nil)"
}
type Alias PaymentsStarGiftUpgradeAttributes
return fmt .Sprintf ("PaymentsStarGiftUpgradeAttributes%+v" , Alias (*s ))
}
func (s *PaymentsStarGiftUpgradeAttributes ) FillFrom (from interface {
GetAttributes () (value []StarGiftAttributeClass )
}) {
s .Attributes = from .GetAttributes ()
}
func (*PaymentsStarGiftUpgradeAttributes ) TypeID () uint32 {
return PaymentsStarGiftUpgradeAttributesTypeID
}
func (*PaymentsStarGiftUpgradeAttributes ) TypeName () string {
return "payments.starGiftUpgradeAttributes"
}
func (s *PaymentsStarGiftUpgradeAttributes ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.starGiftUpgradeAttributes" ,
ID : PaymentsStarGiftUpgradeAttributesTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Attributes" ,
SchemaName : "attributes" ,
},
}
return typ
}
func (s *PaymentsStarGiftUpgradeAttributes ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starGiftUpgradeAttributes#46c6e36f as nil" )
}
b .PutID (PaymentsStarGiftUpgradeAttributesTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsStarGiftUpgradeAttributes ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starGiftUpgradeAttributes#46c6e36f as nil" )
}
b .PutVectorHeader (len (s .Attributes ))
for idx , v := range s .Attributes {
if v == nil {
return fmt .Errorf ("unable to encode payments.starGiftUpgradeAttributes#46c6e36f: field attributes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftUpgradeAttributes#46c6e36f: field attributes element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *PaymentsStarGiftUpgradeAttributes ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starGiftUpgradeAttributes#46c6e36f to nil" )
}
if err := b .ConsumeID (PaymentsStarGiftUpgradeAttributesTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradeAttributes#46c6e36f: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsStarGiftUpgradeAttributes ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starGiftUpgradeAttributes#46c6e36f to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradeAttributes#46c6e36f: field attributes: %w" , err )
}
if headerLen > 0 {
s .Attributes = make ([]StarGiftAttributeClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeStarGiftAttribute (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradeAttributes#46c6e36f: field attributes: %w" , err )
}
s .Attributes = append (s .Attributes , value )
}
}
return nil
}
func (s *PaymentsStarGiftUpgradeAttributes ) GetAttributes () (value []StarGiftAttributeClass ) {
if s == nil {
return
}
return s .Attributes
}
func (s *PaymentsStarGiftUpgradeAttributes ) MapAttributes () (value StarGiftAttributeClassArray ) {
return StarGiftAttributeClassArray (s .Attributes )
}
The pages are generated with Golds v0.8.4 . (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 @zigo_101 (reachable from the left QR code) to get the latest news of Golds .