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 PaymentsUniqueStarGift struct {
Gift StarGiftClass
Chats []ChatClass
Users []UserClass
}
const PaymentsUniqueStarGiftTypeID = 0x416c56e8
var (
_ bin .Encoder = &PaymentsUniqueStarGift {}
_ bin .Decoder = &PaymentsUniqueStarGift {}
_ bin .BareEncoder = &PaymentsUniqueStarGift {}
_ bin .BareDecoder = &PaymentsUniqueStarGift {}
)
func (u *PaymentsUniqueStarGift ) Zero () bool {
if u == nil {
return true
}
if !(u .Gift == nil ) {
return false
}
if !(u .Chats == nil ) {
return false
}
if !(u .Users == nil ) {
return false
}
return true
}
func (u *PaymentsUniqueStarGift ) String () string {
if u == nil {
return "PaymentsUniqueStarGift(nil)"
}
type Alias PaymentsUniqueStarGift
return fmt .Sprintf ("PaymentsUniqueStarGift%+v" , Alias (*u ))
}
func (u *PaymentsUniqueStarGift ) FillFrom (from interface {
GetGift () (value StarGiftClass )
GetChats () (value []ChatClass )
GetUsers () (value []UserClass )
}) {
u .Gift = from .GetGift ()
u .Chats = from .GetChats ()
u .Users = from .GetUsers ()
}
func (*PaymentsUniqueStarGift ) TypeID () uint32 {
return PaymentsUniqueStarGiftTypeID
}
func (*PaymentsUniqueStarGift ) TypeName () string {
return "payments.uniqueStarGift"
}
func (u *PaymentsUniqueStarGift ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.uniqueStarGift" ,
ID : PaymentsUniqueStarGiftTypeID ,
}
if u == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Gift" ,
SchemaName : "gift" ,
},
{
Name : "Chats" ,
SchemaName : "chats" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (u *PaymentsUniqueStarGift ) Encode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode payments.uniqueStarGift#416c56e8 as nil" )
}
b .PutID (PaymentsUniqueStarGiftTypeID )
return u .EncodeBare (b )
}
func (u *PaymentsUniqueStarGift ) EncodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't encode payments.uniqueStarGift#416c56e8 as nil" )
}
if u .Gift == nil {
return fmt .Errorf ("unable to encode payments.uniqueStarGift#416c56e8: field gift is nil" )
}
if err := u .Gift .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.uniqueStarGift#416c56e8: field gift: %w" , err )
}
b .PutVectorHeader (len (u .Chats ))
for idx , v := range u .Chats {
if v == nil {
return fmt .Errorf ("unable to encode payments.uniqueStarGift#416c56e8: field chats element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.uniqueStarGift#416c56e8: field chats element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (u .Users ))
for idx , v := range u .Users {
if v == nil {
return fmt .Errorf ("unable to encode payments.uniqueStarGift#416c56e8: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.uniqueStarGift#416c56e8: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (u *PaymentsUniqueStarGift ) Decode (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode payments.uniqueStarGift#416c56e8 to nil" )
}
if err := b .ConsumeID (PaymentsUniqueStarGiftTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.uniqueStarGift#416c56e8: %w" , err )
}
return u .DecodeBare (b )
}
func (u *PaymentsUniqueStarGift ) DecodeBare (b *bin .Buffer ) error {
if u == nil {
return fmt .Errorf ("can't decode payments.uniqueStarGift#416c56e8 to nil" )
}
{
value , err := DecodeStarGift (b )
if err != nil {
return fmt .Errorf ("unable to decode payments.uniqueStarGift#416c56e8: field gift: %w" , err )
}
u .Gift = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.uniqueStarGift#416c56e8: field chats: %w" , err )
}
if headerLen > 0 {
u .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.uniqueStarGift#416c56e8: field chats: %w" , err )
}
u .Chats = append (u .Chats , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode payments.uniqueStarGift#416c56e8: field users: %w" , err )
}
if headerLen > 0 {
u .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.uniqueStarGift#416c56e8: field users: %w" , err )
}
u .Users = append (u .Users , value )
}
}
return nil
}
func (u *PaymentsUniqueStarGift ) GetGift () (value StarGiftClass ) {
if u == nil {
return
}
return u .Gift
}
func (u *PaymentsUniqueStarGift ) GetChats () (value []ChatClass ) {
if u == nil {
return
}
return u .Chats
}
func (u *PaymentsUniqueStarGift ) GetUsers () (value []UserClass ) {
if u == nil {
return
}
return u .Users
}
func (u *PaymentsUniqueStarGift ) MapChats () (value ChatClassArray ) {
return ChatClassArray (u .Chats )
}
func (u *PaymentsUniqueStarGift ) MapUsers () (value UserClassArray ) {
return UserClassArray (u .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 .