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 PaymentsGiveawayInfo struct {
Flags bin .Fields
Participating bool
PreparingResults bool
StartDate int
JoinedTooEarlyDate int
AdminDisallowedChatID int64
DisallowedCountry string
}
const PaymentsGiveawayInfoTypeID = 0x4367daa0
func (g PaymentsGiveawayInfo ) construct () PaymentsGiveawayInfoClass { return &g }
var (
_ bin .Encoder = &PaymentsGiveawayInfo {}
_ bin .Decoder = &PaymentsGiveawayInfo {}
_ bin .BareEncoder = &PaymentsGiveawayInfo {}
_ bin .BareDecoder = &PaymentsGiveawayInfo {}
_ PaymentsGiveawayInfoClass = &PaymentsGiveawayInfo {}
)
func (g *PaymentsGiveawayInfo ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Participating == false ) {
return false
}
if !(g .PreparingResults == false ) {
return false
}
if !(g .StartDate == 0 ) {
return false
}
if !(g .JoinedTooEarlyDate == 0 ) {
return false
}
if !(g .AdminDisallowedChatID == 0 ) {
return false
}
if !(g .DisallowedCountry == "" ) {
return false
}
return true
}
func (g *PaymentsGiveawayInfo ) String () string {
if g == nil {
return "PaymentsGiveawayInfo(nil)"
}
type Alias PaymentsGiveawayInfo
return fmt .Sprintf ("PaymentsGiveawayInfo%+v" , Alias (*g ))
}
func (g *PaymentsGiveawayInfo ) FillFrom (from interface {
GetParticipating () (value bool )
GetPreparingResults () (value bool )
GetStartDate () (value int )
GetJoinedTooEarlyDate () (value int , ok bool )
GetAdminDisallowedChatID () (value int64 , ok bool )
GetDisallowedCountry () (value string , ok bool )
}) {
g .Participating = from .GetParticipating ()
g .PreparingResults = from .GetPreparingResults ()
g .StartDate = from .GetStartDate ()
if val , ok := from .GetJoinedTooEarlyDate (); ok {
g .JoinedTooEarlyDate = val
}
if val , ok := from .GetAdminDisallowedChatID (); ok {
g .AdminDisallowedChatID = val
}
if val , ok := from .GetDisallowedCountry (); ok {
g .DisallowedCountry = val
}
}
func (*PaymentsGiveawayInfo ) TypeID () uint32 {
return PaymentsGiveawayInfoTypeID
}
func (*PaymentsGiveawayInfo ) TypeName () string {
return "payments.giveawayInfo"
}
func (g *PaymentsGiveawayInfo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.giveawayInfo" ,
ID : PaymentsGiveawayInfoTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Participating" ,
SchemaName : "participating" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "PreparingResults" ,
SchemaName : "preparing_results" ,
Null : !g .Flags .Has (3 ),
},
{
Name : "StartDate" ,
SchemaName : "start_date" ,
},
{
Name : "JoinedTooEarlyDate" ,
SchemaName : "joined_too_early_date" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "AdminDisallowedChatID" ,
SchemaName : "admin_disallowed_chat_id" ,
Null : !g .Flags .Has (2 ),
},
{
Name : "DisallowedCountry" ,
SchemaName : "disallowed_country" ,
Null : !g .Flags .Has (4 ),
},
}
return typ
}
func (g *PaymentsGiveawayInfo ) SetFlags () {
if !(g .Participating == false ) {
g .Flags .Set (0 )
}
if !(g .PreparingResults == false ) {
g .Flags .Set (3 )
}
if !(g .JoinedTooEarlyDate == 0 ) {
g .Flags .Set (1 )
}
if !(g .AdminDisallowedChatID == 0 ) {
g .Flags .Set (2 )
}
if !(g .DisallowedCountry == "" ) {
g .Flags .Set (4 )
}
}
func (g *PaymentsGiveawayInfo ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.giveawayInfo#4367daa0 as nil" )
}
b .PutID (PaymentsGiveawayInfoTypeID )
return g .EncodeBare (b )
}
func (g *PaymentsGiveawayInfo ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.giveawayInfo#4367daa0 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.giveawayInfo#4367daa0: field flags: %w" , err )
}
b .PutInt (g .StartDate )
if g .Flags .Has (1 ) {
b .PutInt (g .JoinedTooEarlyDate )
}
if g .Flags .Has (2 ) {
b .PutLong (g .AdminDisallowedChatID )
}
if g .Flags .Has (4 ) {
b .PutString (g .DisallowedCountry )
}
return nil
}
func (g *PaymentsGiveawayInfo ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.giveawayInfo#4367daa0 to nil" )
}
if err := b .ConsumeID (PaymentsGiveawayInfoTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfo#4367daa0: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PaymentsGiveawayInfo ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.giveawayInfo#4367daa0 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfo#4367daa0: field flags: %w" , err )
}
}
g .Participating = g .Flags .Has (0 )
g .PreparingResults = g .Flags .Has (3 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfo#4367daa0: field start_date: %w" , err )
}
g .StartDate = value
}
if g .Flags .Has (1 ) {
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfo#4367daa0: field joined_too_early_date: %w" , err )
}
g .JoinedTooEarlyDate = value
}
if g .Flags .Has (2 ) {
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfo#4367daa0: field admin_disallowed_chat_id: %w" , err )
}
g .AdminDisallowedChatID = value
}
if g .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfo#4367daa0: field disallowed_country: %w" , err )
}
g .DisallowedCountry = value
}
return nil
}
func (g *PaymentsGiveawayInfo ) SetParticipating (value bool ) {
if value {
g .Flags .Set (0 )
g .Participating = true
} else {
g .Flags .Unset (0 )
g .Participating = false
}
}
func (g *PaymentsGiveawayInfo ) GetParticipating () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (0 )
}
func (g *PaymentsGiveawayInfo ) SetPreparingResults (value bool ) {
if value {
g .Flags .Set (3 )
g .PreparingResults = true
} else {
g .Flags .Unset (3 )
g .PreparingResults = false
}
}
func (g *PaymentsGiveawayInfo ) GetPreparingResults () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (3 )
}
func (g *PaymentsGiveawayInfo ) GetStartDate () (value int ) {
if g == nil {
return
}
return g .StartDate
}
func (g *PaymentsGiveawayInfo ) SetJoinedTooEarlyDate (value int ) {
g .Flags .Set (1 )
g .JoinedTooEarlyDate = value
}
func (g *PaymentsGiveawayInfo ) GetJoinedTooEarlyDate () (value int , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (1 ) {
return value , false
}
return g .JoinedTooEarlyDate , true
}
func (g *PaymentsGiveawayInfo ) SetAdminDisallowedChatID (value int64 ) {
g .Flags .Set (2 )
g .AdminDisallowedChatID = value
}
func (g *PaymentsGiveawayInfo ) GetAdminDisallowedChatID () (value int64 , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (2 ) {
return value , false
}
return g .AdminDisallowedChatID , true
}
func (g *PaymentsGiveawayInfo ) SetDisallowedCountry (value string ) {
g .Flags .Set (4 )
g .DisallowedCountry = value
}
func (g *PaymentsGiveawayInfo ) GetDisallowedCountry () (value string , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (4 ) {
return value , false
}
return g .DisallowedCountry , true
}
type PaymentsGiveawayInfoResults struct {
Flags bin .Fields
Winner bool
Refunded bool
StartDate int
GiftCodeSlug string
FinishDate int
WinnersCount int
ActivatedCount int
}
const PaymentsGiveawayInfoResultsTypeID = 0xcd5570
func (g PaymentsGiveawayInfoResults ) construct () PaymentsGiveawayInfoClass { return &g }
var (
_ bin .Encoder = &PaymentsGiveawayInfoResults {}
_ bin .Decoder = &PaymentsGiveawayInfoResults {}
_ bin .BareEncoder = &PaymentsGiveawayInfoResults {}
_ bin .BareDecoder = &PaymentsGiveawayInfoResults {}
_ PaymentsGiveawayInfoClass = &PaymentsGiveawayInfoResults {}
)
func (g *PaymentsGiveawayInfoResults ) Zero () bool {
if g == nil {
return true
}
if !(g .Flags .Zero ()) {
return false
}
if !(g .Winner == false ) {
return false
}
if !(g .Refunded == false ) {
return false
}
if !(g .StartDate == 0 ) {
return false
}
if !(g .GiftCodeSlug == "" ) {
return false
}
if !(g .FinishDate == 0 ) {
return false
}
if !(g .WinnersCount == 0 ) {
return false
}
if !(g .ActivatedCount == 0 ) {
return false
}
return true
}
func (g *PaymentsGiveawayInfoResults ) String () string {
if g == nil {
return "PaymentsGiveawayInfoResults(nil)"
}
type Alias PaymentsGiveawayInfoResults
return fmt .Sprintf ("PaymentsGiveawayInfoResults%+v" , Alias (*g ))
}
func (g *PaymentsGiveawayInfoResults ) FillFrom (from interface {
GetWinner () (value bool )
GetRefunded () (value bool )
GetStartDate () (value int )
GetGiftCodeSlug () (value string , ok bool )
GetFinishDate () (value int )
GetWinnersCount () (value int )
GetActivatedCount () (value int )
}) {
g .Winner = from .GetWinner ()
g .Refunded = from .GetRefunded ()
g .StartDate = from .GetStartDate ()
if val , ok := from .GetGiftCodeSlug (); ok {
g .GiftCodeSlug = val
}
g .FinishDate = from .GetFinishDate ()
g .WinnersCount = from .GetWinnersCount ()
g .ActivatedCount = from .GetActivatedCount ()
}
func (*PaymentsGiveawayInfoResults ) TypeID () uint32 {
return PaymentsGiveawayInfoResultsTypeID
}
func (*PaymentsGiveawayInfoResults ) TypeName () string {
return "payments.giveawayInfoResults"
}
func (g *PaymentsGiveawayInfoResults ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "payments.giveawayInfoResults" ,
ID : PaymentsGiveawayInfoResultsTypeID ,
}
if g == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Winner" ,
SchemaName : "winner" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "Refunded" ,
SchemaName : "refunded" ,
Null : !g .Flags .Has (1 ),
},
{
Name : "StartDate" ,
SchemaName : "start_date" ,
},
{
Name : "GiftCodeSlug" ,
SchemaName : "gift_code_slug" ,
Null : !g .Flags .Has (0 ),
},
{
Name : "FinishDate" ,
SchemaName : "finish_date" ,
},
{
Name : "WinnersCount" ,
SchemaName : "winners_count" ,
},
{
Name : "ActivatedCount" ,
SchemaName : "activated_count" ,
},
}
return typ
}
func (g *PaymentsGiveawayInfoResults ) SetFlags () {
if !(g .Winner == false ) {
g .Flags .Set (0 )
}
if !(g .Refunded == false ) {
g .Flags .Set (1 )
}
if !(g .GiftCodeSlug == "" ) {
g .Flags .Set (0 )
}
}
func (g *PaymentsGiveawayInfoResults ) Encode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.giveawayInfoResults#cd5570 as nil" )
}
b .PutID (PaymentsGiveawayInfoResultsTypeID )
return g .EncodeBare (b )
}
func (g *PaymentsGiveawayInfoResults ) EncodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't encode payments.giveawayInfoResults#cd5570 as nil" )
}
g .SetFlags ()
if err := g .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode payments.giveawayInfoResults#cd5570: field flags: %w" , err )
}
b .PutInt (g .StartDate )
if g .Flags .Has (0 ) {
b .PutString (g .GiftCodeSlug )
}
b .PutInt (g .FinishDate )
b .PutInt (g .WinnersCount )
b .PutInt (g .ActivatedCount )
return nil
}
func (g *PaymentsGiveawayInfoResults ) Decode (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.giveawayInfoResults#cd5570 to nil" )
}
if err := b .ConsumeID (PaymentsGiveawayInfoResultsTypeID ); err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: %w" , err )
}
return g .DecodeBare (b )
}
func (g *PaymentsGiveawayInfoResults ) DecodeBare (b *bin .Buffer ) error {
if g == nil {
return fmt .Errorf ("can't decode payments.giveawayInfoResults#cd5570 to nil" )
}
{
if err := g .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: field flags: %w" , err )
}
}
g .Winner = g .Flags .Has (0 )
g .Refunded = g .Flags .Has (1 )
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: field start_date: %w" , err )
}
g .StartDate = value
}
if g .Flags .Has (0 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: field gift_code_slug: %w" , err )
}
g .GiftCodeSlug = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: field finish_date: %w" , err )
}
g .FinishDate = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: field winners_count: %w" , err )
}
g .WinnersCount = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode payments.giveawayInfoResults#cd5570: field activated_count: %w" , err )
}
g .ActivatedCount = value
}
return nil
}
func (g *PaymentsGiveawayInfoResults ) SetWinner (value bool ) {
if value {
g .Flags .Set (0 )
g .Winner = true
} else {
g .Flags .Unset (0 )
g .Winner = false
}
}
func (g *PaymentsGiveawayInfoResults ) GetWinner () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (0 )
}
func (g *PaymentsGiveawayInfoResults ) SetRefunded (value bool ) {
if value {
g .Flags .Set (1 )
g .Refunded = true
} else {
g .Flags .Unset (1 )
g .Refunded = false
}
}
func (g *PaymentsGiveawayInfoResults ) GetRefunded () (value bool ) {
if g == nil {
return
}
return g .Flags .Has (1 )
}
func (g *PaymentsGiveawayInfoResults ) GetStartDate () (value int ) {
if g == nil {
return
}
return g .StartDate
}
func (g *PaymentsGiveawayInfoResults ) SetGiftCodeSlug (value string ) {
g .Flags .Set (0 )
g .GiftCodeSlug = value
}
func (g *PaymentsGiveawayInfoResults ) GetGiftCodeSlug () (value string , ok bool ) {
if g == nil {
return
}
if !g .Flags .Has (0 ) {
return value , false
}
return g .GiftCodeSlug , true
}
func (g *PaymentsGiveawayInfoResults ) GetFinishDate () (value int ) {
if g == nil {
return
}
return g .FinishDate
}
func (g *PaymentsGiveawayInfoResults ) GetWinnersCount () (value int ) {
if g == nil {
return
}
return g .WinnersCount
}
func (g *PaymentsGiveawayInfoResults ) GetActivatedCount () (value int ) {
if g == nil {
return
}
return g .ActivatedCount
}
const PaymentsGiveawayInfoClassName = "payments.GiveawayInfo"
type PaymentsGiveawayInfoClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () PaymentsGiveawayInfoClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
GetStartDate () (value int )
}
func DecodePaymentsGiveawayInfo (buf *bin .Buffer ) (PaymentsGiveawayInfoClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case PaymentsGiveawayInfoTypeID :
v := PaymentsGiveawayInfo {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PaymentsGiveawayInfoClass: %w" , err )
}
return &v , nil
case PaymentsGiveawayInfoResultsTypeID :
v := PaymentsGiveawayInfoResults {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode PaymentsGiveawayInfoClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode PaymentsGiveawayInfoClass: %w" , bin .NewUnexpectedID (id ))
}
}
type PaymentsGiveawayInfoBox struct {
GiveawayInfo PaymentsGiveawayInfoClass
}
func (b *PaymentsGiveawayInfoBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode PaymentsGiveawayInfoBox to nil" )
}
v , err := DecodePaymentsGiveawayInfo (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .GiveawayInfo = v
return nil
}
func (b *PaymentsGiveawayInfoBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .GiveawayInfo == nil {
return fmt .Errorf ("unable to encode PaymentsGiveawayInfoClass as nil" )
}
return b .GiveawayInfo .Encode (buf )
}
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 .