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
var (
_ bin .Encoder = &PrepaidGiveaway {}
_ bin .Decoder = &PrepaidGiveaway {}
_ bin .BareEncoder = &PrepaidGiveaway {}
_ bin .BareDecoder = &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
}
The pages are generated with Golds v0.6.7 . (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 @Go100and1 (reachable from the left QR code) to get the latest news of Golds .