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 PrepaidGiveaway struct {
ID int64
Months int
Quantity int
Date int
}
const PrepaidGiveawayTypeID = 0xb2539d54
func (p PrepaidGiveaway ) construct () PrepaidGiveawayClass { return &p }
var (
_ bin .Encoder = &PrepaidGiveaway {}
_ bin .Decoder = &PrepaidGiveaway {}
_ bin .BareEncoder = &PrepaidGiveaway {}
_ bin .BareDecoder = &PrepaidGiveaway {}
_ PrepaidGiveawayClass = &PrepaidGiveaway {}
)
func (p *PrepaidGiveaway ) Zero () bool {
if p == nil {
return true
}
if !(p .ID == 0 ) {
return false
}
if !(p .Months == 0 ) {
return false
}
if !(p .Quantity == 0 ) {
return false
}
if !(p .Date == 0 ) {
return false
}
return true
}
func (p *PrepaidGiveaway ) String () string {
if p == nil {
return "PrepaidGiveaway(nil)"
}
type Alias PrepaidGiveaway
return fmt .Sprintf ("PrepaidGiveaway%+v" , Alias (*p ))
}
func (p *PrepaidGiveaway ) FillFrom (from interface {
GetID () (value int64 )
GetMonths () (value int )
GetQuantity () (value int )
GetDate () (value int )
}) {
p .ID = from .GetID ()
p .Months = from .GetMonths ()
p .Quantity = from .GetQuantity ()
p .Date = from .GetDate ()
}
func (*PrepaidGiveaway ) TypeID () uint32 {
return PrepaidGiveawayTypeID
}
func (*PrepaidGiveaway ) TypeName () string {
return "prepaidGiveaway"
}
func (p *PrepaidGiveaway ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "prepaidGiveaway" ,
ID : PrepaidGiveawayTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Months" ,
SchemaName : "months" ,
},
{
Name : "Quantity" ,
SchemaName : "quantity" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (p *PrepaidGiveaway ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode prepaidGiveaway#b2539d54 as nil" )
}
b .PutID (PrepaidGiveawayTypeID )
return p .EncodeBare (b )
}
func (p *PrepaidGiveaway ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode prepaidGiveaway#b2539d54 as nil" )
}
b .PutLong (p .ID )
b .PutInt (p .Months )
b .PutInt (p .Quantity )
b .PutInt (p .Date )
return nil
}
func (p *PrepaidGiveaway ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode prepaidGiveaway#b2539d54 to nil" )
}
if err := b .ConsumeID (PrepaidGiveawayTypeID ); err != nil {
return fmt .Errorf ("unable to decode prepaidGiveaway#b2539d54: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PrepaidGiveaway ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode prepaidGiveaway#b2539d54 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidGiveaway#b2539d54: field id: %w" , err )
}
p .ID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidGiveaway#b2539d54: field months: %w" , err )
}
p .Months = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidGiveaway#b2539d54: field quantity: %w" , err )
}
p .Quantity = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidGiveaway#b2539d54: field date: %w" , err )
}
p .Date = value
}
return nil
}
func (p *PrepaidGiveaway ) GetID () (value int64 ) {
if p == nil {
return
}
return p .ID
}
func (p *PrepaidGiveaway ) GetMonths () (value int ) {
if p == nil {
return
}
return p .Months
}
func (p *PrepaidGiveaway ) GetQuantity () (value int ) {
if p == nil {
return
}
return p .Quantity
}
func (p *PrepaidGiveaway ) GetDate () (value int ) {
if p == nil {
return
}
return p .Date
}
type PrepaidStarsGiveaway struct {
ID int64
Stars int64
Quantity int
Boosts int
Date int
}
const PrepaidStarsGiveawayTypeID = 0x9a9d77e0
func (p PrepaidStarsGiveaway ) construct () PrepaidGiveawayClass { return &p }
var (
_ bin .Encoder = &PrepaidStarsGiveaway {}
_ bin .Decoder = &PrepaidStarsGiveaway {}
_ bin .BareEncoder = &PrepaidStarsGiveaway {}
_ bin .BareDecoder = &PrepaidStarsGiveaway {}
_ PrepaidGiveawayClass = &PrepaidStarsGiveaway {}
)
func (p *PrepaidStarsGiveaway ) Zero () bool {
if p == nil {
return true
}
if !(p .ID == 0 ) {
return false
}
if !(p .Stars == 0 ) {
return false
}
if !(p .Quantity == 0 ) {
return false
}
if !(p .Boosts == 0 ) {
return false
}
if !(p .Date == 0 ) {
return false
}
return true
}
func (p *PrepaidStarsGiveaway ) String () string {
if p == nil {
return "PrepaidStarsGiveaway(nil)"
}
type Alias PrepaidStarsGiveaway
return fmt .Sprintf ("PrepaidStarsGiveaway%+v" , Alias (*p ))
}
func (p *PrepaidStarsGiveaway ) FillFrom (from interface {
GetID () (value int64 )
GetStars () (value int64 )
GetQuantity () (value int )
GetBoosts () (value int )
GetDate () (value int )
}) {
p .ID = from .GetID ()
p .Stars = from .GetStars ()
p .Quantity = from .GetQuantity ()
p .Boosts = from .GetBoosts ()
p .Date = from .GetDate ()
}
func (*PrepaidStarsGiveaway ) TypeID () uint32 {
return PrepaidStarsGiveawayTypeID
}
func (*PrepaidStarsGiveaway ) TypeName () string {
return "prepaidStarsGiveaway"
}
func (p *PrepaidStarsGiveaway ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "prepaidStarsGiveaway" ,
ID : PrepaidStarsGiveawayTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "ID" ,
SchemaName : "id" ,
},
{
Name : "Stars" ,
SchemaName : "stars" ,
},
{
Name : "Quantity" ,
SchemaName : "quantity" ,
},
{
Name : "Boosts" ,
SchemaName : "boosts" ,
},
{
Name : "Date" ,
SchemaName : "date" ,
},
}
return typ
}
func (p *PrepaidStarsGiveaway ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode prepaidStarsGiveaway#9a9d77e0 as nil" )
}
b .PutID (PrepaidStarsGiveawayTypeID )
return p .EncodeBare (b )
}
func (p *PrepaidStarsGiveaway ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode prepaidStarsGiveaway#9a9d77e0 as nil" )
}
b .PutLong (p .ID )
b .PutLong (p .Stars )
b .PutInt (p .Quantity )
b .PutInt (p .Boosts )
b .PutInt (p .Date )
return nil
}
func (p *PrepaidStarsGiveaway ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode prepaidStarsGiveaway#9a9d77e0 to nil" )
}
if err := b .ConsumeID (PrepaidStarsGiveawayTypeID ); err != nil {
return fmt .Errorf ("unable to decode prepaidStarsGiveaway#9a9d77e0: %w" , err )
}
return p .DecodeBare (b )
}
func (p *PrepaidStarsGiveaway ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode prepaidStarsGiveaway#9a9d77e0 to nil" )
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidStarsGiveaway#9a9d77e0: field id: %w" , err )
}
p .ID = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidStarsGiveaway#9a9d77e0: field stars: %w" , err )
}
p .Stars = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidStarsGiveaway#9a9d77e0: field quantity: %w" , err )
}
p .Quantity = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidStarsGiveaway#9a9d77e0: field boosts: %w" , err )
}
p .Boosts = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode prepaidStarsGiveaway#9a9d77e0: field date: %w" , err )
}
p .Date = value
}
return nil
}
func (p *PrepaidStarsGiveaway ) GetID () (value int64 ) {
if p == nil {
return
}
return p .ID
}
func (p *PrepaidStarsGiveaway ) GetStars () (value int64 ) {
if p == nil {
return
}
return p .Stars
}
func (p *PrepaidStarsGiveaway ) GetQuantity () (value int ) {
if p == nil {
return
}
return p .Quantity
}
func (p *PrepaidStarsGiveaway ) GetBoosts () (value int ) {
if p == nil {
return
}
return p .Boosts
}
func (p *PrepaidStarsGiveaway ) GetDate () (value int ) {
if p == nil {
return
}
return p .Date
}
const PrepaidGiveawayClassName = "PrepaidGiveaway"
type PrepaidGiveawayClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PrepaidGiveawayClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetID () (value int64 )
GetQuantity () (value int )
GetDate () (value int )
}
func DecodePrepaidGiveaway (buf *bin .Buffer ) (PrepaidGiveawayClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PrepaidGiveawayTypeID :
v := PrepaidGiveaway {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PrepaidGiveawayClass: %w" , err )
}
return &v , nil
case PrepaidStarsGiveawayTypeID :
v := PrepaidStarsGiveaway {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PrepaidGiveawayClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PrepaidGiveawayClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PrepaidGiveawayBox struct {
PrepaidGiveaway PrepaidGiveawayClass
}
func (b *PrepaidGiveawayBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PrepaidGiveawayBox to nil" )
}
v , err := DecodePrepaidGiveaway (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .PrepaidGiveaway = v
return nil
}
func (b *PrepaidGiveawayBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .PrepaidGiveaway == nil {
return fmt .Errorf ("unable to encode PrepaidGiveawayClass as nil" )
}
return b .PrepaidGiveaway .Encode (buf )
}
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 .