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 PaymentsResaleStarGifts struct {
Flags bin .Fields
Count int
Gifts []StarGiftClass
NextOffset string
Attributes []StarGiftAttributeClass
AttributesHash int64
Chats []ChatClass
Counters []StarGiftAttributeCounter
Users []UserClass
}
const PaymentsResaleStarGiftsTypeID = 0x947a12df
var (
_ bin .Encoder = &PaymentsResaleStarGifts {}
_ bin .Decoder = &PaymentsResaleStarGifts {}
_ bin .BareEncoder = &PaymentsResaleStarGifts {}
_ bin .BareDecoder = &PaymentsResaleStarGifts {}
)
func (r *PaymentsResaleStarGifts ) Zero () bool {
if r == nil {
return true
}
if !(r .Flags .Zero ()) {
return false
}
if !(r .Count == 0 ) {
return false
}
if !(r .Gifts == nil ) {
return false
}
if !(r .NextOffset == "" ) {
return false
}
if !(r .Attributes == nil ) {
return false
}
if !(r .AttributesHash == 0 ) {
return false
}
if !(r .Chats == nil ) {
return false
}
if !(r .Counters == nil ) {
return false
}
if !(r .Users == nil ) {
return false
}
return true
}
func (r *PaymentsResaleStarGifts ) String () string {
if r == nil {
return "PaymentsResaleStarGifts(nil)"
}
type Alias PaymentsResaleStarGifts
return fmt .Sprintf ("PaymentsResaleStarGifts%+v" , Alias (*r ))
}
func (r *PaymentsResaleStarGifts ) FillFrom (from interface {
GetCount () (value int )
GetGifts () (value []StarGiftClass )
GetNextOffset () (value string , ok bool )
GetAttributes () (value []StarGiftAttributeClass , ok bool )
GetAttributesHash () (value int64 , ok bool )
GetChats () (value []ChatClass )
GetCounters () (value []StarGiftAttributeCounter , ok bool )
GetUsers () (value []UserClass )
}) {
r .Count = from .GetCount ()
r .Gifts = from .GetGifts ()
if val , ok := from .GetNextOffset (); ok {
r .NextOffset = val
}
if val , ok := from .GetAttributes (); ok {
r .Attributes = val
}
if val , ok := from .GetAttributesHash (); ok {
r .AttributesHash = val
}
r .Chats = from .GetChats ()
if val , ok := from .GetCounters (); ok {
r .Counters = val
}
r .Users = from .GetUsers ()
}
func (*PaymentsResaleStarGifts ) TypeID () uint32 {
return PaymentsResaleStarGiftsTypeID
}
func (*PaymentsResaleStarGifts ) TypeName () string {
return "payments.resaleStarGifts"
}
func (r *PaymentsResaleStarGifts ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.resaleStarGifts" ,
ID : PaymentsResaleStarGiftsTypeID ,
}
if r == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Count" ,
SchemaName : "count" ,
},
{
Name : "Gifts" ,
SchemaName : "gifts" ,
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !r .Flags .Has (0 ),
},
{
Name : "Attributes" ,
SchemaName : "attributes" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "AttributesHash" ,
SchemaName : "attributes_hash" ,
Null : !r .Flags .Has (1 ),
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Counters" ,
SchemaName : "counters" ,
Null : !r .Flags .Has (2 ),
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (r *PaymentsResaleStarGifts ) SetFlags () {
if !(r .NextOffset == "" ) {
r .Flags .Set (0 )
}
if !(r .Attributes == nil ) {
r .Flags .Set (1 )
}
if !(r .AttributesHash == 0 ) {
r .Flags .Set (1 )
}
if !(r .Counters == nil ) {
r .Flags .Set (2 )
}
}
func (r *PaymentsResaleStarGifts ) Encode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode payments.resaleStarGifts#947a12df as nil" )
}
b .PutID (PaymentsResaleStarGiftsTypeID )
return r .EncodeBare (b )
}
func (r *PaymentsResaleStarGifts ) EncodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't encode payments.resaleStarGifts#947a12df as nil" )
}
r .SetFlags ()
if err := r .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field flags: %w" , err )
}
b .PutInt (r .Count )
b .PutVectorHeader (len (r .Gifts ))
for idx , v := range r .Gifts {
if v == nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field gifts element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field gifts element with index %d: %w" , idx , err )
}
}
if r .Flags .Has (0 ) {
b .PutString (r .NextOffset )
}
if r .Flags .Has (1 ) {
b .PutVectorHeader (len (r .Attributes ))
for idx , v := range r .Attributes {
if v == nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field attributes element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field attributes element with index %d: %w" , idx , err )
}
}
}
if r .Flags .Has (1 ) {
b .PutLong (r .AttributesHash )
}
b .PutVectorHeader (len (r .Chats ))
for idx , v := range r .Chats {
if v == nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field chats element with index %d: %w" , idx , err )
}
}
if r .Flags .Has (2 ) {
b .PutVectorHeader (len (r .Counters ))
for idx , v := range r .Counters {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field counters element with index %d: %w" , idx , err )
}
}
}
b .PutVectorHeader (len (r .Users ))
for idx , v := range r .Users {
if v == nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.resaleStarGifts#947a12df: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (r *PaymentsResaleStarGifts ) Decode (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode payments.resaleStarGifts#947a12df to nil" )
}
if err := b .ConsumeID (PaymentsResaleStarGiftsTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: %w" , err )
}
return r .DecodeBare (b )
}
func (r *PaymentsResaleStarGifts ) DecodeBare (b *bin .Buffer ) error {
if r == nil {
return fmt .Errorf ("can't decode payments.resaleStarGifts#947a12df to nil" )
}
{
if err := r .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field count: %w" , err )
}
r .Count = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field gifts: %w" , err )
}
if headerLen > 0 {
r .Gifts = make ([]StarGiftClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field gifts: %w" , err )
}
r .Gifts = append (r .Gifts , value )
}
}
if r .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field next_offset: %w" , err )
}
r .NextOffset = value
}
if r .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field attributes: %w" , err )
}
if headerLen > 0 {
r .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.resaleStarGifts#947a12df: field attributes: %w" , err )
}
r .Attributes = append (r .Attributes , value )
}
}
if r .Flags .Has (1 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field attributes_hash: %w" , err )
}
r .AttributesHash = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field chats: %w" , err )
}
if headerLen > 0 {
r .Chats = make ([]ChatClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeChat (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field chats: %w" , err )
}
r .Chats = append (r .Chats , value )
}
}
if r .Flags .Has (2 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field counters: %w" , err )
}
if headerLen > 0 {
r .Counters = make ([]StarGiftAttributeCounter , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StarGiftAttributeCounter
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field counters: %w" , err )
}
r .Counters = append (r .Counters , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field users: %w" , err )
}
if headerLen > 0 {
r .Users = make ([]UserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeUser (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.resaleStarGifts#947a12df: field users: %w" , err )
}
r .Users = append (r .Users , value )
}
}
return nil
}
func (r *PaymentsResaleStarGifts ) GetCount () (value int ) {
if r == nil {
return
}
return r .Count
}
func (r *PaymentsResaleStarGifts ) GetGifts () (value []StarGiftClass ) {
if r == nil {
return
}
return r .Gifts
}
func (r *PaymentsResaleStarGifts ) SetNextOffset (value string ) {
r .Flags .Set (0 )
r .NextOffset = value
}
func (r *PaymentsResaleStarGifts ) GetNextOffset () (value string , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (0 ) {
return value , false
}
return r .NextOffset , true
}
func (r *PaymentsResaleStarGifts ) SetAttributes (value []StarGiftAttributeClass ) {
r .Flags .Set (1 )
r .Attributes = value
}
func (r *PaymentsResaleStarGifts ) GetAttributes () (value []StarGiftAttributeClass , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .Attributes , true
}
func (r *PaymentsResaleStarGifts ) SetAttributesHash (value int64 ) {
r .Flags .Set (1 )
r .AttributesHash = value
}
func (r *PaymentsResaleStarGifts ) GetAttributesHash () (value int64 , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (1 ) {
return value , false
}
return r .AttributesHash , true
}
func (r *PaymentsResaleStarGifts ) GetChats () (value []ChatClass ) {
if r == nil {
return
}
return r .Chats
}
func (r *PaymentsResaleStarGifts ) SetCounters (value []StarGiftAttributeCounter ) {
r .Flags .Set (2 )
r .Counters = value
}
func (r *PaymentsResaleStarGifts ) GetCounters () (value []StarGiftAttributeCounter , ok bool ) {
if r == nil {
return
}
if !r .Flags .Has (2 ) {
return value , false
}
return r .Counters , true
}
func (r *PaymentsResaleStarGifts ) GetUsers () (value []UserClass ) {
if r == nil {
return
}
return r .Users
}
func (r *PaymentsResaleStarGifts ) MapGifts () (value StarGiftClassArray ) {
return StarGiftClassArray (r .Gifts )
}
func (r *PaymentsResaleStarGifts ) MapAttributes () (value StarGiftAttributeClassArray , ok bool ) {
if !r .Flags .Has (1 ) {
return value , false
}
return StarGiftAttributeClassArray (r .Attributes ), true
}
func (r *PaymentsResaleStarGifts ) MapChats () (value ChatClassArray ) {
return ChatClassArray (r .Chats )
}
func (r *PaymentsResaleStarGifts ) MapUsers () (value UserClassArray ) {
return UserClassArray (r .Users )
}
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 .