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 StarsTopupOption struct {
Flags bin .Fields
Extended bool
Stars int64
StoreProduct string
Currency string
Amount int64
}
const StarsTopupOptionTypeID = 0xbd915c0
var (
_ bin .Encoder = &StarsTopupOption {}
_ bin .Decoder = &StarsTopupOption {}
_ bin .BareEncoder = &StarsTopupOption {}
_ bin .BareDecoder = &StarsTopupOption {}
)
func (s *StarsTopupOption ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Extended == false ) {
return false
}
if !(s .Stars == 0 ) {
return false
}
if !(s .StoreProduct == "" ) {
return false
}
if !(s .Currency == "" ) {
return false
}
if !(s .Amount == 0 ) {
return false
}
return true
}
func (s *StarsTopupOption ) String () string {
if s == nil {
return "StarsTopupOption(nil)"
}
type Alias StarsTopupOption
return fmt .Sprintf ("StarsTopupOption%+v" , Alias (*s ))
}
func (s *StarsTopupOption ) FillFrom (from interface {
GetExtended () (value bool )
GetStars () (value int64 )
GetStoreProduct () (value string , ok bool )
GetCurrency () (value string )
GetAmount () (value int64 )
}) {
s .Extended = from .GetExtended ()
s .Stars = from .GetStars ()
if val , ok := from .GetStoreProduct (); ok {
s .StoreProduct = val
}
s .Currency = from .GetCurrency ()
s .Amount = from .GetAmount ()
}
func (*StarsTopupOption ) TypeID () uint32 {
return StarsTopupOptionTypeID
}
func (*StarsTopupOption ) TypeName () string {
return "starsTopupOption"
}
func (s *StarsTopupOption ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starsTopupOption" ,
ID : StarsTopupOptionTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Extended" ,
SchemaName : "extended" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "Stars" ,
SchemaName : "stars" ,
},
{
Name : "StoreProduct" ,
SchemaName : "store_product" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "Currency" ,
SchemaName : "currency" ,
},
{
Name : "Amount" ,
SchemaName : "amount" ,
},
}
return typ
}
func (s *StarsTopupOption ) SetFlags () {
if !(s .Extended == false ) {
s .Flags .Set (1 )
}
if !(s .StoreProduct == "" ) {
s .Flags .Set (0 )
}
}
func (s *StarsTopupOption ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsTopupOption#bd915c0 as nil" )
}
b .PutID (StarsTopupOptionTypeID )
return s .EncodeBare (b )
}
func (s *StarsTopupOption ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starsTopupOption#bd915c0 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starsTopupOption#bd915c0: field flags: %w" , err )
}
b .PutLong (s .Stars )
if s .Flags .Has (0 ) {
b .PutString (s .StoreProduct )
}
b .PutString (s .Currency )
b .PutLong (s .Amount )
return nil
}
func (s *StarsTopupOption ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsTopupOption#bd915c0 to nil" )
}
if err := b .ConsumeID (StarsTopupOptionTypeID ); err != nil {
return fmt .Errorf ("unable to decode starsTopupOption#bd915c0: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarsTopupOption ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starsTopupOption#bd915c0 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starsTopupOption#bd915c0: field flags: %w" , err )
}
}
s .Extended = s .Flags .Has (1 )
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsTopupOption#bd915c0: field stars: %w" , err )
}
s .Stars = value
}
if s .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode starsTopupOption#bd915c0: field store_product: %w" , err )
}
s .StoreProduct = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode starsTopupOption#bd915c0: field currency: %w" , err )
}
s .Currency = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starsTopupOption#bd915c0: field amount: %w" , err )
}
s .Amount = value
}
return nil
}
func (s *StarsTopupOption ) SetExtended (value bool ) {
if value {
s .Flags .Set (1 )
s .Extended = true
} else {
s .Flags .Unset (1 )
s .Extended = false
}
}
func (s *StarsTopupOption ) GetExtended () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *StarsTopupOption ) GetStars () (value int64 ) {
if s == nil {
return
}
return s .Stars
}
func (s *StarsTopupOption ) SetStoreProduct (value string ) {
s .Flags .Set (0 )
s .StoreProduct = value
}
func (s *StarsTopupOption ) GetStoreProduct () (value string , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .StoreProduct , true
}
func (s *StarsTopupOption ) GetCurrency () (value string ) {
if s == nil {
return
}
return s .Currency
}
func (s *StarsTopupOption ) GetAmount () (value int64 ) {
if s == nil {
return
}
return s .Amount
}
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 .