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 PaymentsStarGiftAuctionState struct {
Gift StarGiftClass
State StarGiftAuctionStateClass
UserState StarGiftAuctionUserState
Timeout int
Users []UserClass
Chats []ChatClass
}
const PaymentsStarGiftAuctionStateTypeID = 0x6b39f4ec
var (
_ bin .Encoder = &PaymentsStarGiftAuctionState {}
_ bin .Decoder = &PaymentsStarGiftAuctionState {}
_ bin .BareEncoder = &PaymentsStarGiftAuctionState {}
_ bin .BareDecoder = &PaymentsStarGiftAuctionState {}
)
func (s *PaymentsStarGiftAuctionState ) Zero () bool {
if s == nil {
return true
}
if !(s .Gift == nil ) {
return false
}
if !(s .State == nil ) {
return false
}
if !(s .UserState .Zero ()) {
return false
}
if !(s .Timeout == 0 ) {
return false
}
if !(s .Users == nil ) {
return false
}
if !(s .Chats == nil ) {
return false
}
return true
}
func (s *PaymentsStarGiftAuctionState ) String () string {
if s == nil {
return "PaymentsStarGiftAuctionState(nil)"
}
type Alias PaymentsStarGiftAuctionState
return fmt .Sprintf ("PaymentsStarGiftAuctionState%+v" , Alias (*s ))
}
func (s *PaymentsStarGiftAuctionState ) FillFrom (from interface {
GetGift () (value StarGiftClass )
GetState () (value StarGiftAuctionStateClass )
GetUserState () (value StarGiftAuctionUserState )
GetTimeout () (value int )
GetUsers () (value []UserClass )
GetChats () (value []ChatClass )
}) {
s .Gift = from .GetGift ()
s .State = from .GetState ()
s .UserState = from .GetUserState ()
s .Timeout = from .GetTimeout ()
s .Users = from .GetUsers ()
s .Chats = from .GetChats ()
}
func (*PaymentsStarGiftAuctionState ) TypeID () uint32 {
return PaymentsStarGiftAuctionStateTypeID
}
func (*PaymentsStarGiftAuctionState ) TypeName () string {
return "payments.starGiftAuctionState"
}
func (s *PaymentsStarGiftAuctionState ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.starGiftAuctionState" ,
ID : PaymentsStarGiftAuctionStateTypeID ,
}
if s == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Gift" ,
SchemaName : "gift" ,
},
{
Name : "State" ,
SchemaName : "state" ,
},
{
Name : "UserState" ,
SchemaName : "user_state" ,
},
{
Name : "Timeout" ,
SchemaName : "timeout" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
}
return typ
}
func (s *PaymentsStarGiftAuctionState ) Encode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starGiftAuctionState#6b39f4ec as nil" )
}
b .PutID (PaymentsStarGiftAuctionStateTypeID )
return s .EncodeBare (b )
}
func (s *PaymentsStarGiftAuctionState ) EncodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't encode payments.starGiftAuctionState#6b39f4ec as nil" )
}
if s .Gift == nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field gift is nil" )
}
if err := s .Gift .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field gift: %w" , err )
}
if s .State == nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field state is nil" )
}
if err := s .State .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field state: %w" , err )
}
if err := s .UserState .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field user_state: %w" , err )
}
b .PutInt (s .Timeout )
b .PutVectorHeader (len (s .Users ))
for idx , v := range s .Users {
if v == nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field users element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (s .Chats ))
for idx , v := range s .Chats {
if v == nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.starGiftAuctionState#6b39f4ec: field chats element with index %d: %w" , idx , err )
}
}
return nil
}
func (s *PaymentsStarGiftAuctionState ) Decode (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starGiftAuctionState#6b39f4ec to nil" )
}
if err := b .ConsumeID (PaymentsStarGiftAuctionStateTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: %w" , err )
}
return s .DecodeBare (b )
}
func (s *PaymentsStarGiftAuctionState ) DecodeBare (b *bin .Buffer ) error {
if s == nil {
return fmt .Errorf ("can't decode payments.starGiftAuctionState#6b39f4ec to nil" )
}
{
value , err := DecodeStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: field gift: %w" , err )
}
s .Gift = value
}
{
value , err := DecodeStarGiftAuctionState (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: field state: %w" , err )
}
s .State = value
}
{
if err := s .UserState .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: field user_state: %w" , err )
}
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: field timeout: %w" , err )
}
s .Timeout = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: 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.starGiftAuctionState#6b39f4ec: field users: %w" , err )
}
s .Users = append (s .Users , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.starGiftAuctionState#6b39f4ec: 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.starGiftAuctionState#6b39f4ec: field chats: %w" , err )
}
s .Chats = append (s .Chats , value )
}
}
return nil
}
func (s *PaymentsStarGiftAuctionState ) GetGift () (value StarGiftClass ) {
if s == nil {
return
}
return s .Gift
}
func (s *PaymentsStarGiftAuctionState ) GetState () (value StarGiftAuctionStateClass ) {
if s == nil {
return
}
return s .State
}
func (s *PaymentsStarGiftAuctionState ) GetUserState () (value StarGiftAuctionUserState ) {
if s == nil {
return
}
return s .UserState
}
func (s *PaymentsStarGiftAuctionState ) GetTimeout () (value int ) {
if s == nil {
return
}
return s .Timeout
}
func (s *PaymentsStarGiftAuctionState ) GetUsers () (value []UserClass ) {
if s == nil {
return
}
return s .Users
}
func (s *PaymentsStarGiftAuctionState ) GetChats () (value []ChatClass ) {
if s == nil {
return
}
return s .Chats
}
func (s *PaymentsStarGiftAuctionState ) GetStateAsModified () (ModifiedStarGiftAuctionState , bool ) {
return s .State .AsModified ()
}
func (s *PaymentsStarGiftAuctionState ) MapUsers () (value UserClassArray ) {
return UserClassArray (s .Users )
}
func (s *PaymentsStarGiftAuctionState ) MapChats () (value ChatClassArray ) {
return ChatClassArray (s .Chats )
}
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 .