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 StarGiftAuctionUserState struct {
Flags bin .Fields
Returned bool
BidAmount int64
BidDate int
MinBidAmount int64
BidPeer PeerClass
AcquiredCount int
}
const StarGiftAuctionUserStateTypeID = 0x2eeed1c4
var (
_ bin .Encoder = &StarGiftAuctionUserState {}
_ bin .Decoder = &StarGiftAuctionUserState {}
_ bin .BareEncoder = &StarGiftAuctionUserState {}
_ bin .BareDecoder = &StarGiftAuctionUserState {}
)
func (s *StarGiftAuctionUserState ) Zero () bool {
if s == nil {
return true
}
if !(s .Flags .Zero ()) {
return false
}
if !(s .Returned == false ) {
return false
}
if !(s .BidAmount == 0 ) {
return false
}
if !(s .BidDate == 0 ) {
return false
}
if !(s .MinBidAmount == 0 ) {
return false
}
if !(s .BidPeer == nil ) {
return false
}
if !(s .AcquiredCount == 0 ) {
return false
}
return true
}
func (s *StarGiftAuctionUserState ) String () string {
if s == nil {
return "StarGiftAuctionUserState(nil)"
}
type Alias StarGiftAuctionUserState
return fmt .Sprintf ("StarGiftAuctionUserState%+v" , Alias (*s ))
}
func (s *StarGiftAuctionUserState ) FillFrom (from interface {
GetReturned () (value bool )
GetBidAmount () (value int64 , ok bool )
GetBidDate () (value int , ok bool )
GetMinBidAmount () (value int64 , ok bool )
GetBidPeer () (value PeerClass , ok bool )
GetAcquiredCount () (value int )
}) {
s .Returned = from .GetReturned ()
if val , ok := from .GetBidAmount (); ok {
s .BidAmount = val
}
if val , ok := from .GetBidDate (); ok {
s .BidDate = val
}
if val , ok := from .GetMinBidAmount (); ok {
s .MinBidAmount = val
}
if val , ok := from .GetBidPeer (); ok {
s .BidPeer = val
}
s .AcquiredCount = from .GetAcquiredCount ()
}
func (*StarGiftAuctionUserState ) TypeID () uint32 {
return StarGiftAuctionUserStateTypeID
}
func (*StarGiftAuctionUserState ) TypeName () string {
return "starGiftAuctionUserState"
}
func (s *StarGiftAuctionUserState ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "starGiftAuctionUserState" ,
ID : StarGiftAuctionUserStateTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Returned" ,
SchemaName : "returned" ,
Null : !s .Flags .Has (1 ),
},
{
Name : "BidAmount" ,
SchemaName : "bid_amount" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "BidDate" ,
SchemaName : "bid_date" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "MinBidAmount" ,
SchemaName : "min_bid_amount" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "BidPeer" ,
SchemaName : "bid_peer" ,
Null : !s .Flags .Has (0 ),
},
{
Name : "AcquiredCount" ,
SchemaName : "acquired_count" ,
},
}
return typ
}
func (s *StarGiftAuctionUserState ) SetFlags () {
if !(s .Returned == false ) {
s .Flags .Set (1 )
}
if !(s .BidAmount == 0 ) {
s .Flags .Set (0 )
}
if !(s .BidDate == 0 ) {
s .Flags .Set (0 )
}
if !(s .MinBidAmount == 0 ) {
s .Flags .Set (0 )
}
if !(s .BidPeer == nil ) {
s .Flags .Set (0 )
}
}
func (s *StarGiftAuctionUserState ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionUserState#2eeed1c4 as nil" )
}
b .PutID (StarGiftAuctionUserStateTypeID )
return s .EncodeBare (b )
}
func (s *StarGiftAuctionUserState ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode starGiftAuctionUserState#2eeed1c4 as nil" )
}
s .SetFlags ()
if err := s .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAuctionUserState#2eeed1c4: field flags: %w" , err )
}
if s .Flags .Has (0 ) {
b .PutLong (s .BidAmount )
}
if s .Flags .Has (0 ) {
b .PutInt (s .BidDate )
}
if s .Flags .Has (0 ) {
b .PutLong (s .MinBidAmount )
}
if s .Flags .Has (0 ) {
if s .BidPeer == nil {
return fmt .Errorf ("unable to encode starGiftAuctionUserState#2eeed1c4: field bid_peer is nil" )
}
if err := s .BidPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode starGiftAuctionUserState#2eeed1c4: field bid_peer: %w" , err )
}
}
b .PutInt (s .AcquiredCount )
return nil
}
func (s *StarGiftAuctionUserState ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionUserState#2eeed1c4 to nil" )
}
if err := b .ConsumeID (StarGiftAuctionUserStateTypeID ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: %w" , err )
}
return s .DecodeBare (b )
}
func (s *StarGiftAuctionUserState ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode starGiftAuctionUserState#2eeed1c4 to nil" )
}
{
if err := s .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: field flags: %w" , err )
}
}
s .Returned = s .Flags .Has (1 )
if s .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: field bid_amount: %w" , err )
}
s .BidAmount = value
}
if s .Flags .Has (0 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: field bid_date: %w" , err )
}
s .BidDate = value
}
if s .Flags .Has (0 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: field min_bid_amount: %w" , err )
}
s .MinBidAmount = value
}
if s .Flags .Has (0 ) {
value , err := DecodePeer (b )
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: field bid_peer: %w" , err )
}
s .BidPeer = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode starGiftAuctionUserState#2eeed1c4: field acquired_count: %w" , err )
}
s .AcquiredCount = value
}
return nil
}
func (s *StarGiftAuctionUserState ) SetReturned (value bool ) {
if value {
s .Flags .Set (1 )
s .Returned = true
} else {
s .Flags .Unset (1 )
s .Returned = false
}
}
func (s *StarGiftAuctionUserState ) GetReturned () (value bool ) {
if s == nil {
return
}
return s .Flags .Has (1 )
}
func (s *StarGiftAuctionUserState ) SetBidAmount (value int64 ) {
s .Flags .Set (0 )
s .BidAmount = value
}
func (s *StarGiftAuctionUserState ) GetBidAmount () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .BidAmount , true
}
func (s *StarGiftAuctionUserState ) SetBidDate (value int ) {
s .Flags .Set (0 )
s .BidDate = value
}
func (s *StarGiftAuctionUserState ) GetBidDate () (value int , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .BidDate , true
}
func (s *StarGiftAuctionUserState ) SetMinBidAmount (value int64 ) {
s .Flags .Set (0 )
s .MinBidAmount = value
}
func (s *StarGiftAuctionUserState ) GetMinBidAmount () (value int64 , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .MinBidAmount , true
}
func (s *StarGiftAuctionUserState ) SetBidPeer (value PeerClass ) {
s .Flags .Set (0 )
s .BidPeer = value
}
func (s *StarGiftAuctionUserState ) GetBidPeer () (value PeerClass , ok bool ) {
if s == nil {
return
}
if !s .Flags .Has (0 ) {
return value , false
}
return s .BidPeer , true
}
func (s *StarGiftAuctionUserState ) GetAcquiredCount () (value int ) {
if s == nil {
return
}
return s .AcquiredCount
}
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 .