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 StarGiftCollection struct {
Flags bin .Fields
CollectionID int
Title string
Icon DocumentClass
GiftsCount int
Hash int64
}
const StarGiftCollectionTypeID = 0x9d6b13b0
var (
_ bin .Encoder = &StarGiftCollection {}
_ bin .Decoder = &StarGiftCollection {}
_ bin .BareEncoder = &StarGiftCollection {}
_ bin .BareDecoder = &StarGiftCollection {}
)
func (s *StarGiftCollection ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .CollectionID == 0 ) {
return false
}
if !(s .Title == "" ) {
return false
}
if !(s .Icon == nil ) {
return false
}
if !(s .GiftsCount == 0 ) {
return false
}
if !(s .Hash == 0 ) {
return false
}
return true
}
func (s *StarGiftCollection ) String () string {
if s == nil {
return "StarGiftCollection(nil)"
}
type Alias StarGiftCollection
return fmt .Sprintf ("StarGiftCollection%+v" , Alias (*s ))
}
func (s *StarGiftCollection ) FillFrom (from interface {
GetCollectionID () (value int )
GetTitle () (value string )
GetIcon () (value DocumentClass , ok bool )
GetGiftsCount () (value int )
GetHash () (value int64 )
}) {
s .CollectionID = from .GetCollectionID ()
s .Title = from .GetTitle ()
if val , ok := from .GetIcon (); ok {
s .Icon = val
}
s .GiftsCount = from .GetGiftsCount ()
s .Hash = from .GetHash ()
}
func (*StarGiftCollection ) TypeID () uint32 {
return StarGiftCollectionTypeID
}
func (*StarGiftCollection ) TypeName () string {
return "starGiftCollection"
}
func (s *StarGiftCollection ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftCollection" ,
ID : StarGiftCollectionTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "CollectionID" ,
SchemaName : "collection_id" ,
},
{
Name : "Title" ,
SchemaName : "title" ,
},
{
Name : "Icon" ,
SchemaName : "icon" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "GiftsCount" ,
SchemaName : "gifts_count" ,
},
{
Name : "Hash" ,
SchemaName : "hash" ,
},
}
return typ
}
func (s *StarGiftCollection ) SetFlags () {
if !(s .Icon == nil ) {
s .Flags .Set (0 )
}
}
func (s *StarGiftCollection ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftCollection#9d6b13b0 as nil" )
}
b .PutID (StarGiftCollectionTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftCollection ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftCollection#9d6b13b0 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftCollection#9d6b13b0: field flags: %w" , err )
}
b .PutInt (s .CollectionID )
b .PutString (s .Title )
if s .Flags .Has (0 ) {
if s .Icon == nil {
return fmt .Errorf ("unable to encode starGiftCollection#9d6b13b0: field icon is nil" )
}
if err := s .Icon .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftCollection#9d6b13b0: field icon: %w" , err )
}
}
b .PutInt (s .GiftsCount )
b .PutLong (s .Hash )
return nil
}
func (s *StarGiftCollection ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftCollection#9d6b13b0 to nil" )
}
if err := b .ConsumeID (StarGiftCollectionTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftCollection ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftCollection#9d6b13b0 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: field flags: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: field collection_id: %w" , err )
}
s .CollectionID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: field title: %w" , err )
}
s .Title = value
}
if s .Flags .Has (0 ) {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: field icon: %w" , err )
}
s .Icon = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: field gifts_count: %w" , err )
}
s .GiftsCount = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftCollection#9d6b13b0: field hash: %w" , err )
}
s .Hash = value
}
return nil
}
func (s *StarGiftCollection ) GetCollectionID () (value int ) {
if s == nil {
return
}
return s .CollectionID
}
func (s *StarGiftCollection ) GetTitle () (value string ) {
if s == nil {
return
}
return s .Title
}
func (s *StarGiftCollection ) SetIcon (value DocumentClass ) {
s .Flags .Set (0 )
s .Icon = value
}
func (s *StarGiftCollection ) GetIcon () (value DocumentClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .Icon , true
}
func (s *StarGiftCollection ) GetGiftsCount () (value int ) {
if s == nil {
return
}
return s .GiftsCount
}
func (s *StarGiftCollection ) GetHash () (value int64 ) {
if s == nil {
return
}
return s .Hash
}
func (s *StarGiftCollection ) GetIconAsNotEmpty () (*Document , bool ) {
if value , ok := s .GetIcon (); ok {
return value .AsNotEmpty ()
}
return nil , false
}
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 .