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 PaymentsStarGiftUpgradePreview struct {
SampleAttributes []StarGiftAttributeClass
Prices []StarGiftUpgradePrice
NextPrices []StarGiftUpgradePrice
}
const PaymentsStarGiftUpgradePreviewTypeID = 0x3de1dfed
var (
_ bin .Encoder = &PaymentsStarGiftUpgradePreview {}
_ bin .Decoder = &PaymentsStarGiftUpgradePreview {}
_ bin .BareEncoder = &PaymentsStarGiftUpgradePreview {}
_ bin .BareDecoder = &PaymentsStarGiftUpgradePreview {}
)
func (s *PaymentsStarGiftUpgradePreview ) Zero () bool {
if s == nil {
return true
}
if !(s .SampleAttributes == nil ) {
return false
}
if !(s .Prices == nil ) {
return false
}
if !(s .NextPrices == nil ) {
return false
}
return true
}
func (s *PaymentsStarGiftUpgradePreview ) String () string {
if s == nil {
return "PaymentsStarGiftUpgradePreview(nil)"
}
type Alias PaymentsStarGiftUpgradePreview
return fmt .Sprintf ("PaymentsStarGiftUpgradePreview%+v" , Alias (*s ))
}
func (s *PaymentsStarGiftUpgradePreview ) FillFrom (from interface {
GetSampleAttributes () (value []StarGiftAttributeClass )
GetPrices () (value []StarGiftUpgradePrice )
GetNextPrices () (value []StarGiftUpgradePrice )
}) {
s .SampleAttributes = from .GetSampleAttributes ()
s .Prices = from .GetPrices ()
s .NextPrices = from .GetNextPrices ()
}
func (*PaymentsStarGiftUpgradePreview ) TypeID () uint32 {
return PaymentsStarGiftUpgradePreviewTypeID
}
func (*PaymentsStarGiftUpgradePreview ) TypeName () string {
return "payments.starGiftUpgradePreview"
}
func (s *PaymentsStarGiftUpgradePreview ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.starGiftUpgradePreview" ,
ID : PaymentsStarGiftUpgradePreviewTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "SampleAttributes" ,
SchemaName : "sample_attributes" ,
},
{
Name : "Prices" ,
SchemaName : "prices" ,
},
{
Name : "NextPrices" ,
SchemaName : "next_prices" ,
},
}
return typ
}
func (s *PaymentsStarGiftUpgradePreview ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starGiftUpgradePreview#3de1dfed as nil" )
}
b .PutID (PaymentsStarGiftUpgradePreviewTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsStarGiftUpgradePreview ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starGiftUpgradePreview#3de1dfed as nil" )
}
b .PutVectorHeader (len (s .SampleAttributes ))
for idx , v := range s .SampleAttributes {
if v == nil {
return fmt .Errorf ("unable to encode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Prices ))
for idx , v := range s .Prices {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftUpgradePreview#3de1dfed: field prices element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .NextPrices ))
for idx , v := range s .NextPrices {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftUpgradePreview#3de1dfed: field next_prices element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *PaymentsStarGiftUpgradePreview ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starGiftUpgradePreview#3de1dfed to nil" )
}
if err := b .ConsumeID (PaymentsStarGiftUpgradePreviewTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradePreview#3de1dfed: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsStarGiftUpgradePreview ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starGiftUpgradePreview#3de1dfed to nil" )
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes: %w" , err )
}
if headerLen > 0 {
s .SampleAttributes = 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.starGiftUpgradePreview#3de1dfed: field sample_attributes: %w" , err )
}
s .SampleAttributes = append (s .SampleAttributes , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradePreview#3de1dfed: field prices: %w" , err )
}
if headerLen > 0 {
s .Prices = make ([]StarGiftUpgradePrice , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StarGiftUpgradePrice
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradePreview#3de1dfed: field prices: %w" , err )
}
s .Prices = append (s .Prices , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradePreview#3de1dfed: field next_prices: %w" , err )
}
if headerLen > 0 {
s .NextPrices = make ([]StarGiftUpgradePrice , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StarGiftUpgradePrice
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.starGiftUpgradePreview#3de1dfed: field next_prices: %w" , err )
}
s .NextPrices = append (s .NextPrices , value )
}
}
return nil
}
func (s *PaymentsStarGiftUpgradePreview ) GetSampleAttributes () (value []StarGiftAttributeClass ) {
if s == nil {
return
}
return s .SampleAttributes
}
func (s *PaymentsStarGiftUpgradePreview ) GetPrices () (value []StarGiftUpgradePrice ) {
if s == nil {
return
}
return s .Prices
}
func (s *PaymentsStarGiftUpgradePreview ) GetNextPrices () (value []StarGiftUpgradePrice ) {
if s == nil {
return
}
return s .NextPrices
}
func (s *PaymentsStarGiftUpgradePreview ) MapSampleAttributes () (value StarGiftAttributeClassArray ) {
return StarGiftAttributeClassArray (s .SampleAttributes )
}
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 .