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 PaymentsStarsStatus struct {
Flags bin .Fields
Balance StarsAmountClass
Subscriptions []StarsSubscription
SubscriptionsNextOffset string
SubscriptionsMissingBalance int64
History []StarsTransaction
NextOffset string
Chats []ChatClass
Users []UserClass
}
const PaymentsStarsStatusTypeID = 0x6c9ce8ed
var (
_ bin .Encoder = &PaymentsStarsStatus {}
_ bin .Decoder = &PaymentsStarsStatus {}
_ bin .BareEncoder = &PaymentsStarsStatus {}
_ bin .BareDecoder = &PaymentsStarsStatus {}
)
func (s *PaymentsStarsStatus ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Balance == nil ) {
return false
}
if !(s .Subscriptions == nil ) {
return false
}
if !(s .SubscriptionsNextOffset == "" ) {
return false
}
if !(s .SubscriptionsMissingBalance == 0 ) {
return false
}
if !(s .History == nil ) {
return false
}
if !(s .NextOffset == "" ) {
return false
}
if !(s .Chats == nil ) {
return false
}
if !(s .Users == nil ) {
return false
}
return true
}
func (s *PaymentsStarsStatus ) String () string {
if s == nil {
return "PaymentsStarsStatus(nil)"
}
type Alias PaymentsStarsStatus
return fmt .Sprintf ("PaymentsStarsStatus%+v" , Alias (*s ))
}
func (s *PaymentsStarsStatus ) FillFrom (from interface {
GetBalance () (value StarsAmountClass )
GetSubscriptions () (value []StarsSubscription , ok bool )
GetSubscriptionsNextOffset () (value string , ok bool )
GetSubscriptionsMissingBalance () (value int64 , ok bool )
GetHistory () (value []StarsTransaction , ok bool )
GetNextOffset () (value string , ok bool )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
s .Balance = from .GetBalance ()
if val , ok := from .GetSubscriptions (); ok {
s .Subscriptions = val
}
if val , ok := from .GetSubscriptionsNextOffset (); ok {
s .SubscriptionsNextOffset = val
}
if val , ok := from .GetSubscriptionsMissingBalance (); ok {
s .SubscriptionsMissingBalance = val
}
if val , ok := from .GetHistory (); ok {
s .History = val
}
if val , ok := from .GetNextOffset (); ok {
s .NextOffset = val
}
s .Chats = from .GetChats ()
s .Users = from .GetUsers ()
}
func (*PaymentsStarsStatus ) TypeID () uint32 {
return PaymentsStarsStatusTypeID
}
func (*PaymentsStarsStatus ) TypeName () string {
return "payments.starsStatus"
}
func (s *PaymentsStarsStatus ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.starsStatus" ,
ID : PaymentsStarsStatusTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Balance" ,
SchemaName : "balance" ,
},
{
Name : "Subscriptions" ,
SchemaName : "subscriptions" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "SubscriptionsNextOffset" ,
SchemaName : "subscriptions_next_offset" ,
Null : !s .Flags .Has (2 ),
},
{
Name : "SubscriptionsMissingBalance" ,
SchemaName : "subscriptions_missing_balance" ,
Null : !s .Flags .Has (4 ),
},
{
Name : "History" ,
SchemaName : "history" ,
Null : !s .Flags .Has (3 ),
},
{
Name : "NextOffset" ,
SchemaName : "next_offset" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (s *PaymentsStarsStatus ) SetFlags () {
if !(s .Subscriptions == nil ) {
s .Flags .Set (1 )
}
if !(s .SubscriptionsNextOffset == "" ) {
s .Flags .Set (2 )
}
if !(s .SubscriptionsMissingBalance == 0 ) {
s .Flags .Set (4 )
}
if !(s .History == nil ) {
s .Flags .Set (3 )
}
if !(s .NextOffset == "" ) {
s .Flags .Set (0 )
}
}
func (s *PaymentsStarsStatus ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starsStatus#6c9ce8ed as nil" )
}
b .PutID (PaymentsStarsStatusTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsStarsStatus ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starsStatus#6c9ce8ed as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field flags: %w" , err )
}
if s .Balance == nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field balance is nil" )
}
if err := s .Balance .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field balance: %w" , err )
}
if s .Flags .Has (1 ) {
b .PutVectorHeader (len (s .Subscriptions ))
for idx , v := range s .Subscriptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field subscriptions element with index %d: %w" , idx , err )
}
}
}
if s .Flags .Has (2 ) {
b .PutString (s .SubscriptionsNextOffset )
}
if s .Flags .Has (4 ) {
b .PutLong (s .SubscriptionsMissingBalance )
}
if s .Flags .Has (3 ) {
b .PutVectorHeader (len (s .History ))
for idx , v := range s .History {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field history element with index %d: %w" , idx , err )
}
}
}
if s .Flags .Has (0 ) {
b .PutString (s .NextOffset )
}
b .PutVectorHeader (len (s .Chats ))
for idx , v := range s .Chats {
if v == nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Users ))
for idx , v := range s .Users {
if v == nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starsStatus#6c9ce8ed: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *PaymentsStarsStatus ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starsStatus#6c9ce8ed to nil" )
}
if err := b .ConsumeID (PaymentsStarsStatusTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsStarsStatus ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starsStatus#6c9ce8ed to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field flags: %w" , err )
}
}
{
value , err := DecodeStarsAmount (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field balance: %w" , err )
}
s .Balance = value
}
if s .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions: %w" , err )
}
if headerLen > 0 {
s .Subscriptions = make ([]StarsSubscription , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StarsSubscription
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions: %w" , err )
}
s .Subscriptions = append (s .Subscriptions , value )
}
}
if s .Flags .Has (2 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions_next_offset: %w" , err )
}
s .SubscriptionsNextOffset = value
}
if s .Flags .Has (4 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field subscriptions_missing_balance: %w" , err )
}
s .SubscriptionsMissingBalance = value
}
if s .Flags .Has (3 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field history: %w" , err )
}
if headerLen > 0 {
s .History = make ([]StarsTransaction , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value StarsTransaction
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field history: %w" , err )
}
s .History = append (s .History , value )
}
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field next_offset: %w" , err )
}
s .NextOffset = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field chats: %w" , err )
}
if headerLen > 0 {
s .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.starsStatus#6c9ce8ed: field chats: %w" , err )
}
s .Chats = append (s .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starsStatus#6c9ce8ed: field users: %w" , err )
}
if headerLen > 0 {
s .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.starsStatus#6c9ce8ed: field users: %w" , err )
}
s .Users = append (s .Users , value )
}
}
return nil
}
func (s *PaymentsStarsStatus ) GetBalance () (value StarsAmountClass ) {
if s == nil {
return
}
return s .Balance
}
func (s *PaymentsStarsStatus ) SetSubscriptions (value []StarsSubscription ) {
s .Flags .Set (1 )
s .Subscriptions = value
}
func (s *PaymentsStarsStatus ) GetSubscriptions () (value []StarsSubscription , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (1 ) {
return value , false
}
return s .Subscriptions , true
}
func (s *PaymentsStarsStatus ) SetSubscriptionsNextOffset (value string ) {
s .Flags .Set (2 )
s .SubscriptionsNextOffset = value
}
func (s *PaymentsStarsStatus ) GetSubscriptionsNextOffset () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (2 ) {
return value , false
}
return s .SubscriptionsNextOffset , true
}
func (s *PaymentsStarsStatus ) SetSubscriptionsMissingBalance (value int64 ) {
s .Flags .Set (4 )
s .SubscriptionsMissingBalance = value
}
func (s *PaymentsStarsStatus ) GetSubscriptionsMissingBalance () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (4 ) {
return value , false
}
return s .SubscriptionsMissingBalance , true
}
func (s *PaymentsStarsStatus ) SetHistory (value []StarsTransaction ) {
s .Flags .Set (3 )
s .History = value
}
func (s *PaymentsStarsStatus ) GetHistory () (value []StarsTransaction , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (3 ) {
return value , false
}
return s .History , true
}
func (s *PaymentsStarsStatus ) SetNextOffset (value string ) {
s .Flags .Set (0 )
s .NextOffset = value
}
func (s *PaymentsStarsStatus ) GetNextOffset () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .NextOffset , true
}
func (s *PaymentsStarsStatus ) GetChats () (value []ChatClass ) {
if s == nil {
return
}
return s .Chats
}
func (s *PaymentsStarsStatus ) GetUsers () (value []UserClass ) {
if s == nil {
return
}
return s .Users
}
func (s *PaymentsStarsStatus ) MapChats () (value ChatClassArray ) {
return ChatClassArray (s .Chats )
}
func (s *PaymentsStarsStatus ) MapUsers () (value UserClassArray ) {
return UserClassArray (s .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 .