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 PremiumBoostsStatus struct {
Flags bin .Fields
MyBoost bool
Level int
CurrentLevelBoosts int
Boosts int
GiftBoosts int
NextLevelBoosts int
PremiumAudience StatsPercentValue
BoostURL string
PrepaidGiveaways []PrepaidGiveaway
MyBoostSlots []int
}
const PremiumBoostsStatusTypeID = 0x4959427a
var (
_ bin .Encoder = &PremiumBoostsStatus {}
_ bin .Decoder = &PremiumBoostsStatus {}
_ bin .BareEncoder = &PremiumBoostsStatus {}
_ bin .BareDecoder = &PremiumBoostsStatus {}
)
func (b *PremiumBoostsStatus ) Zero () bool {
if b == nil {
return true
}
if !(b .Flags .Zero ()) {
return false
}
if !(b .MyBoost == false ) {
return false
}
if !(b .Level == 0 ) {
return false
}
if !(b .CurrentLevelBoosts == 0 ) {
return false
}
if !(b .Boosts == 0 ) {
return false
}
if !(b .GiftBoosts == 0 ) {
return false
}
if !(b .NextLevelBoosts == 0 ) {
return false
}
if !(b .PremiumAudience .Zero ()) {
return false
}
if !(b .BoostURL == "" ) {
return false
}
if !(b .PrepaidGiveaways == nil ) {
return false
}
if !(b .MyBoostSlots == nil ) {
return false
}
return true
}
func (b *PremiumBoostsStatus ) String () string {
if b == nil {
return "PremiumBoostsStatus(nil)"
}
type Alias PremiumBoostsStatus
return fmt .Sprintf ("PremiumBoostsStatus%+v" , Alias (*b ))
}
func (b *PremiumBoostsStatus ) FillFrom (from interface {
GetMyBoost () (value bool )
GetLevel () (value int )
GetCurrentLevelBoosts () (value int )
GetBoosts () (value int )
GetGiftBoosts () (value int , ok bool )
GetNextLevelBoosts () (value int , ok bool )
GetPremiumAudience () (value StatsPercentValue , ok bool )
GetBoostURL () (value string )
GetPrepaidGiveaways () (value []PrepaidGiveaway , ok bool )
GetMyBoostSlots () (value []int , ok bool )
}) {
b .MyBoost = from .GetMyBoost ()
b .Level = from .GetLevel ()
b .CurrentLevelBoosts = from .GetCurrentLevelBoosts ()
b .Boosts = from .GetBoosts ()
if val , ok := from .GetGiftBoosts (); ok {
b .GiftBoosts = val
}
if val , ok := from .GetNextLevelBoosts (); ok {
b .NextLevelBoosts = val
}
if val , ok := from .GetPremiumAudience (); ok {
b .PremiumAudience = val
}
b .BoostURL = from .GetBoostURL ()
if val , ok := from .GetPrepaidGiveaways (); ok {
b .PrepaidGiveaways = val
}
if val , ok := from .GetMyBoostSlots (); ok {
b .MyBoostSlots = val
}
}
func (*PremiumBoostsStatus ) TypeID () uint32 {
return PremiumBoostsStatusTypeID
}
func (*PremiumBoostsStatus ) TypeName () string {
return "premium.boostsStatus"
}
func (b *PremiumBoostsStatus ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "premium.boostsStatus" ,
ID : PremiumBoostsStatusTypeID ,
}
if b == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "MyBoost" ,
SchemaName : "my_boost" ,
Null : !b .Flags .Has (2 ),
},
{
Name : "Level" ,
SchemaName : "level" ,
},
{
Name : "CurrentLevelBoosts" ,
SchemaName : "current_level_boosts" ,
},
{
Name : "Boosts" ,
SchemaName : "boosts" ,
},
{
Name : "GiftBoosts" ,
SchemaName : "gift_boosts" ,
Null : !b .Flags .Has (4 ),
},
{
Name : "NextLevelBoosts" ,
SchemaName : "next_level_boosts" ,
Null : !b .Flags .Has (0 ),
},
{
Name : "PremiumAudience" ,
SchemaName : "premium_audience" ,
Null : !b .Flags .Has (1 ),
},
{
Name : "BoostURL" ,
SchemaName : "boost_url" ,
},
{
Name : "PrepaidGiveaways" ,
SchemaName : "prepaid_giveaways" ,
Null : !b .Flags .Has (3 ),
},
{
Name : "MyBoostSlots" ,
SchemaName : "my_boost_slots" ,
Null : !b .Flags .Has (2 ),
},
}
return typ
}
func (b *PremiumBoostsStatus ) SetFlags () {
if !(b .MyBoost == false ) {
b .Flags .Set (2 )
}
if !(b .GiftBoosts == 0 ) {
b .Flags .Set (4 )
}
if !(b .NextLevelBoosts == 0 ) {
b .Flags .Set (0 )
}
if !(b .PremiumAudience .Zero ()) {
b .Flags .Set (1 )
}
if !(b .PrepaidGiveaways == nil ) {
b .Flags .Set (3 )
}
if !(b .MyBoostSlots == nil ) {
b .Flags .Set (2 )
}
}
func (b *PremiumBoostsStatus ) Encode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode premium.boostsStatus#4959427a as nil" )
}
buf .PutID (PremiumBoostsStatusTypeID )
return b .EncodeBare (buf )
}
func (b *PremiumBoostsStatus ) EncodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't encode premium.boostsStatus#4959427a as nil" )
}
b .SetFlags ()
if err := b .Flags .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode premium.boostsStatus#4959427a: field flags: %w" , err )
}
buf .PutInt (b .Level )
buf .PutInt (b .CurrentLevelBoosts )
buf .PutInt (b .Boosts )
if b .Flags .Has (4 ) {
buf .PutInt (b .GiftBoosts )
}
if b .Flags .Has (0 ) {
buf .PutInt (b .NextLevelBoosts )
}
if b .Flags .Has (1 ) {
if err := b .PremiumAudience .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode premium.boostsStatus#4959427a: field premium_audience: %w" , err )
}
}
buf .PutString (b .BoostURL )
if b .Flags .Has (3 ) {
buf .PutVectorHeader (len (b .PrepaidGiveaways ))
for idx , v := range b .PrepaidGiveaways {
if err := v .Encode (buf ); err != nil {
return fmt .Errorf ("unable to encode premium.boostsStatus#4959427a: field prepaid_giveaways element with index %d: %w" , idx , err )
}
}
}
if b .Flags .Has (2 ) {
buf .PutVectorHeader (len (b .MyBoostSlots ))
for _ , v := range b .MyBoostSlots {
buf .PutInt (v )
}
}
return nil
}
func (b *PremiumBoostsStatus ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode premium.boostsStatus#4959427a to nil" )
}
if err := buf .ConsumeID (PremiumBoostsStatusTypeID ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: %w" , err )
}
return b .DecodeBare (buf )
}
func (b *PremiumBoostsStatus ) DecodeBare (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("can't decode premium.boostsStatus#4959427a to nil" )
}
{
if err := b .Flags .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field flags: %w" , err )
}
}
b .MyBoost = b .Flags .Has (2 )
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field level: %w" , err )
}
b .Level = value
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field current_level_boosts: %w" , err )
}
b .CurrentLevelBoosts = value
}
{
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field boosts: %w" , err )
}
b .Boosts = value
}
if b .Flags .Has (4 ) {
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field gift_boosts: %w" , err )
}
b .GiftBoosts = value
}
if b .Flags .Has (0 ) {
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field next_level_boosts: %w" , err )
}
b .NextLevelBoosts = value
}
if b .Flags .Has (1 ) {
if err := b .PremiumAudience .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field premium_audience: %w" , err )
}
}
{
value , err := buf .String ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field boost_url: %w" , err )
}
b .BoostURL = value
}
if b .Flags .Has (3 ) {
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w" , err )
}
if headerLen > 0 {
b .PrepaidGiveaways = make ([]PrepaidGiveaway , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PrepaidGiveaway
if err := value .Decode (buf ); err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w" , err )
}
b .PrepaidGiveaways = append (b .PrepaidGiveaways , value )
}
}
if b .Flags .Has (2 ) {
headerLen , err := buf .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field my_boost_slots: %w" , err )
}
if headerLen > 0 {
b .MyBoostSlots = make ([]int , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := buf .Int ()
if err != nil {
return fmt .Errorf ("unable to decode premium.boostsStatus#4959427a: field my_boost_slots: %w" , err )
}
b .MyBoostSlots = append (b .MyBoostSlots , value )
}
}
return nil
}
func (b *PremiumBoostsStatus ) SetMyBoost (value bool ) {
if value {
b .Flags .Set (2 )
b .MyBoost = true
} else {
b .Flags .Unset (2 )
b .MyBoost = false
}
}
func (b *PremiumBoostsStatus ) GetMyBoost () (value bool ) {
if b == nil {
return
}
return b .Flags .Has (2 )
}
func (b *PremiumBoostsStatus ) GetLevel () (value int ) {
if b == nil {
return
}
return b .Level
}
func (b *PremiumBoostsStatus ) GetCurrentLevelBoosts () (value int ) {
if b == nil {
return
}
return b .CurrentLevelBoosts
}
func (b *PremiumBoostsStatus ) GetBoosts () (value int ) {
if b == nil {
return
}
return b .Boosts
}
func (b *PremiumBoostsStatus ) SetGiftBoosts (value int ) {
b .Flags .Set (4 )
b .GiftBoosts = value
}
func (b *PremiumBoostsStatus ) GetGiftBoosts () (value int , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (4 ) {
return value , false
}
return b .GiftBoosts , true
}
func (b *PremiumBoostsStatus ) SetNextLevelBoosts (value int ) {
b .Flags .Set (0 )
b .NextLevelBoosts = value
}
func (b *PremiumBoostsStatus ) GetNextLevelBoosts () (value int , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (0 ) {
return value , false
}
return b .NextLevelBoosts , true
}
func (b *PremiumBoostsStatus ) SetPremiumAudience (value StatsPercentValue ) {
b .Flags .Set (1 )
b .PremiumAudience = value
}
func (b *PremiumBoostsStatus ) GetPremiumAudience () (value StatsPercentValue , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (1 ) {
return value , false
}
return b .PremiumAudience , true
}
func (b *PremiumBoostsStatus ) GetBoostURL () (value string ) {
if b == nil {
return
}
return b .BoostURL
}
func (b *PremiumBoostsStatus ) SetPrepaidGiveaways (value []PrepaidGiveaway ) {
b .Flags .Set (3 )
b .PrepaidGiveaways = value
}
func (b *PremiumBoostsStatus ) GetPrepaidGiveaways () (value []PrepaidGiveaway , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (3 ) {
return value , false
}
return b .PrepaidGiveaways , true
}
func (b *PremiumBoostsStatus ) SetMyBoostSlots (value []int ) {
b .Flags .Set (2 )
b .MyBoostSlots = value
}
func (b *PremiumBoostsStatus ) GetMyBoostSlots () (value []int , ok bool ) {
if b == nil {
return
}
if !b .Flags .Has (2 ) {
return value , false
}
return b .MyBoostSlots , true
}
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 .