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 InputStorePaymentPremiumSubscription struct {
Flags bin .Fields
Restore bool
Upgrade bool
}
const InputStorePaymentPremiumSubscriptionTypeID = 0xa6751e66
func (i InputStorePaymentPremiumSubscription ) construct () InputStorePaymentPurposeClass { return &i }
var (
_ bin .Encoder = &InputStorePaymentPremiumSubscription {}
_ bin .Decoder = &InputStorePaymentPremiumSubscription {}
_ bin .BareEncoder = &InputStorePaymentPremiumSubscription {}
_ bin .BareDecoder = &InputStorePaymentPremiumSubscription {}
_ InputStorePaymentPurposeClass = &InputStorePaymentPremiumSubscription {}
)
func (i *InputStorePaymentPremiumSubscription ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Restore == false ) {
return false
}
if !(i .Upgrade == false ) {
return false
}
return true
}
func (i *InputStorePaymentPremiumSubscription ) String () string {
if i == nil {
return "InputStorePaymentPremiumSubscription(nil)"
}
type Alias InputStorePaymentPremiumSubscription
return fmt .Sprintf ("InputStorePaymentPremiumSubscription%+v" , Alias (*i ))
}
func (i *InputStorePaymentPremiumSubscription ) FillFrom (from interface {
GetRestore () (value bool )
GetUpgrade () (value bool )
}) {
i .Restore = from .GetRestore ()
i .Upgrade = from .GetUpgrade ()
}
func (*InputStorePaymentPremiumSubscription ) TypeID () uint32 {
return InputStorePaymentPremiumSubscriptionTypeID
}
func (*InputStorePaymentPremiumSubscription ) TypeName () string {
return "inputStorePaymentPremiumSubscription"
}
func (i *InputStorePaymentPremiumSubscription ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputStorePaymentPremiumSubscription" ,
ID : InputStorePaymentPremiumSubscriptionTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Restore" ,
SchemaName : "restore" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "Upgrade" ,
SchemaName : "upgrade" ,
Null : !i .Flags .Has (1 ),
},
}
return typ
}
func (i *InputStorePaymentPremiumSubscription ) SetFlags () {
if !(i .Restore == false ) {
i .Flags .Set (0 )
}
if !(i .Upgrade == false ) {
i .Flags .Set (1 )
}
}
func (i *InputStorePaymentPremiumSubscription ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentPremiumSubscription#a6751e66 as nil" )
}
b .PutID (InputStorePaymentPremiumSubscriptionTypeID )
return i .EncodeBare (b )
}
func (i *InputStorePaymentPremiumSubscription ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentPremiumSubscription#a6751e66 as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumSubscription#a6751e66: field flags: %w" , err )
}
return nil
}
func (i *InputStorePaymentPremiumSubscription ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentPremiumSubscription#a6751e66 to nil" )
}
if err := b .ConsumeID (InputStorePaymentPremiumSubscriptionTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumSubscription#a6751e66: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputStorePaymentPremiumSubscription ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentPremiumSubscription#a6751e66 to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumSubscription#a6751e66: field flags: %w" , err )
}
}
i .Restore = i .Flags .Has (0 )
i .Upgrade = i .Flags .Has (1 )
return nil
}
func (i *InputStorePaymentPremiumSubscription ) SetRestore (value bool ) {
if value {
i .Flags .Set (0 )
i .Restore = true
} else {
i .Flags .Unset (0 )
i .Restore = false
}
}
func (i *InputStorePaymentPremiumSubscription ) GetRestore () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (0 )
}
func (i *InputStorePaymentPremiumSubscription ) SetUpgrade (value bool ) {
if value {
i .Flags .Set (1 )
i .Upgrade = true
} else {
i .Flags .Unset (1 )
i .Upgrade = false
}
}
func (i *InputStorePaymentPremiumSubscription ) GetUpgrade () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (1 )
}
type InputStorePaymentGiftPremium struct {
UserID InputUserClass
Currency string
Amount int64
}
const InputStorePaymentGiftPremiumTypeID = 0x616f7fe8
func (i InputStorePaymentGiftPremium ) construct () InputStorePaymentPurposeClass { return &i }
var (
_ bin .Encoder = &InputStorePaymentGiftPremium {}
_ bin .Decoder = &InputStorePaymentGiftPremium {}
_ bin .BareEncoder = &InputStorePaymentGiftPremium {}
_ bin .BareDecoder = &InputStorePaymentGiftPremium {}
_ InputStorePaymentPurposeClass = &InputStorePaymentGiftPremium {}
)
func (i *InputStorePaymentGiftPremium ) Zero () bool {
if i == nil {
return true
}
if !(i .UserID == nil ) {
return false
}
if !(i .Currency == "" ) {
return false
}
if !(i .Amount == 0 ) {
return false
}
return true
}
func (i *InputStorePaymentGiftPremium ) String () string {
if i == nil {
return "InputStorePaymentGiftPremium(nil)"
}
type Alias InputStorePaymentGiftPremium
return fmt .Sprintf ("InputStorePaymentGiftPremium%+v" , Alias (*i ))
}
func (i *InputStorePaymentGiftPremium ) FillFrom (from interface {
GetUserID () (value InputUserClass )
GetCurrency () (value string )
GetAmount () (value int64 )
}) {
i .UserID = from .GetUserID ()
i .Currency = from .GetCurrency ()
i .Amount = from .GetAmount ()
}
func (*InputStorePaymentGiftPremium ) TypeID () uint32 {
return InputStorePaymentGiftPremiumTypeID
}
func (*InputStorePaymentGiftPremium ) TypeName () string {
return "inputStorePaymentGiftPremium"
}
func (i *InputStorePaymentGiftPremium ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputStorePaymentGiftPremium" ,
ID : InputStorePaymentGiftPremiumTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "UserID" ,
SchemaName : "user_id" ,
},
{
Name : "Currency" ,
SchemaName : "currency" ,
},
{
Name : "Amount" ,
SchemaName : "amount" ,
},
}
return typ
}
func (i *InputStorePaymentGiftPremium ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentGiftPremium#616f7fe8 as nil" )
}
b .PutID (InputStorePaymentGiftPremiumTypeID )
return i .EncodeBare (b )
}
func (i *InputStorePaymentGiftPremium ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentGiftPremium#616f7fe8 as nil" )
}
if i .UserID == nil {
return fmt .Errorf ("unable to encode inputStorePaymentGiftPremium#616f7fe8: field user_id is nil" )
}
if err := i .UserID .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentGiftPremium#616f7fe8: field user_id: %w" , err )
}
b .PutString (i .Currency )
b .PutLong (i .Amount )
return nil
}
func (i *InputStorePaymentGiftPremium ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentGiftPremium#616f7fe8 to nil" )
}
if err := b .ConsumeID (InputStorePaymentGiftPremiumTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentGiftPremium#616f7fe8: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputStorePaymentGiftPremium ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentGiftPremium#616f7fe8 to nil" )
}
{
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentGiftPremium#616f7fe8: field user_id: %w" , err )
}
i .UserID = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentGiftPremium#616f7fe8: field currency: %w" , err )
}
i .Currency = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentGiftPremium#616f7fe8: field amount: %w" , err )
}
i .Amount = value
}
return nil
}
func (i *InputStorePaymentGiftPremium ) GetUserID () (value InputUserClass ) {
if i == nil {
return
}
return i .UserID
}
func (i *InputStorePaymentGiftPremium ) GetCurrency () (value string ) {
if i == nil {
return
}
return i .Currency
}
func (i *InputStorePaymentGiftPremium ) GetAmount () (value int64 ) {
if i == nil {
return
}
return i .Amount
}
type InputStorePaymentPremiumGiftCode struct {
Flags bin .Fields
Users []InputUserClass
BoostPeer InputPeerClass
Currency string
Amount int64
}
const InputStorePaymentPremiumGiftCodeTypeID = 0xa3805f3f
func (i InputStorePaymentPremiumGiftCode ) construct () InputStorePaymentPurposeClass { return &i }
var (
_ bin .Encoder = &InputStorePaymentPremiumGiftCode {}
_ bin .Decoder = &InputStorePaymentPremiumGiftCode {}
_ bin .BareEncoder = &InputStorePaymentPremiumGiftCode {}
_ bin .BareDecoder = &InputStorePaymentPremiumGiftCode {}
_ InputStorePaymentPurposeClass = &InputStorePaymentPremiumGiftCode {}
)
func (i *InputStorePaymentPremiumGiftCode ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .Users == nil ) {
return false
}
if !(i .BoostPeer == nil ) {
return false
}
if !(i .Currency == "" ) {
return false
}
if !(i .Amount == 0 ) {
return false
}
return true
}
func (i *InputStorePaymentPremiumGiftCode ) String () string {
if i == nil {
return "InputStorePaymentPremiumGiftCode(nil)"
}
type Alias InputStorePaymentPremiumGiftCode
return fmt .Sprintf ("InputStorePaymentPremiumGiftCode%+v" , Alias (*i ))
}
func (i *InputStorePaymentPremiumGiftCode ) FillFrom (from interface {
GetUsers () (value []InputUserClass )
GetBoostPeer () (value InputPeerClass , ok bool )
GetCurrency () (value string )
GetAmount () (value int64 )
}) {
i .Users = from .GetUsers ()
if val , ok := from .GetBoostPeer (); ok {
i .BoostPeer = val
}
i .Currency = from .GetCurrency ()
i .Amount = from .GetAmount ()
}
func (*InputStorePaymentPremiumGiftCode ) TypeID () uint32 {
return InputStorePaymentPremiumGiftCodeTypeID
}
func (*InputStorePaymentPremiumGiftCode ) TypeName () string {
return "inputStorePaymentPremiumGiftCode"
}
func (i *InputStorePaymentPremiumGiftCode ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputStorePaymentPremiumGiftCode" ,
ID : InputStorePaymentPremiumGiftCodeTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "Users" ,
SchemaName : "users" ,
},
{
Name : "BoostPeer" ,
SchemaName : "boost_peer" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "Currency" ,
SchemaName : "currency" ,
},
{
Name : "Amount" ,
SchemaName : "amount" ,
},
}
return typ
}
func (i *InputStorePaymentPremiumGiftCode ) SetFlags () {
if !(i .BoostPeer == nil ) {
i .Flags .Set (0 )
}
}
func (i *InputStorePaymentPremiumGiftCode ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentPremiumGiftCode#a3805f3f as nil" )
}
b .PutID (InputStorePaymentPremiumGiftCodeTypeID )
return i .EncodeBare (b )
}
func (i *InputStorePaymentPremiumGiftCode ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentPremiumGiftCode#a3805f3f as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field flags: %w" , err )
}
b .PutVectorHeader (len (i .Users ))
for idx , v := range i .Users {
if v == nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field users element with index %d: %w" , idx , err )
}
}
if i .Flags .Has (0 ) {
if i .BoostPeer == nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field boost_peer is nil" )
}
if err := i .BoostPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiftCode#a3805f3f: field boost_peer: %w" , err )
}
}
b .PutString (i .Currency )
b .PutLong (i .Amount )
return nil
}
func (i *InputStorePaymentPremiumGiftCode ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentPremiumGiftCode#a3805f3f to nil" )
}
if err := b .ConsumeID (InputStorePaymentPremiumGiftCodeTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputStorePaymentPremiumGiftCode ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentPremiumGiftCode#a3805f3f to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field flags: %w" , err )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field users: %w" , err )
}
if headerLen > 0 {
i .Users = make ([]InputUserClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputUser (b )
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field users: %w" , err )
}
i .Users = append (i .Users , value )
}
}
if i .Flags .Has (0 ) {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field boost_peer: %w" , err )
}
i .BoostPeer = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field currency: %w" , err )
}
i .Currency = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiftCode#a3805f3f: field amount: %w" , err )
}
i .Amount = value
}
return nil
}
func (i *InputStorePaymentPremiumGiftCode ) GetUsers () (value []InputUserClass ) {
if i == nil {
return
}
return i .Users
}
func (i *InputStorePaymentPremiumGiftCode ) SetBoostPeer (value InputPeerClass ) {
i .Flags .Set (0 )
i .BoostPeer = value
}
func (i *InputStorePaymentPremiumGiftCode ) GetBoostPeer () (value InputPeerClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (0 ) {
return value , false
}
return i .BoostPeer , true
}
func (i *InputStorePaymentPremiumGiftCode ) GetCurrency () (value string ) {
if i == nil {
return
}
return i .Currency
}
func (i *InputStorePaymentPremiumGiftCode ) GetAmount () (value int64 ) {
if i == nil {
return
}
return i .Amount
}
func (i *InputStorePaymentPremiumGiftCode ) MapUsers () (value InputUserClassArray ) {
return InputUserClassArray (i .Users )
}
type InputStorePaymentPremiumGiveaway struct {
Flags bin .Fields
OnlyNewSubscribers bool
WinnersAreVisible bool
BoostPeer InputPeerClass
AdditionalPeers []InputPeerClass
CountriesISO2 []string
PrizeDescription string
RandomID int64
UntilDate int
Currency string
Amount int64
}
const InputStorePaymentPremiumGiveawayTypeID = 0x160544ca
func (i InputStorePaymentPremiumGiveaway ) construct () InputStorePaymentPurposeClass { return &i }
var (
_ bin .Encoder = &InputStorePaymentPremiumGiveaway {}
_ bin .Decoder = &InputStorePaymentPremiumGiveaway {}
_ bin .BareEncoder = &InputStorePaymentPremiumGiveaway {}
_ bin .BareDecoder = &InputStorePaymentPremiumGiveaway {}
_ InputStorePaymentPurposeClass = &InputStorePaymentPremiumGiveaway {}
)
func (i *InputStorePaymentPremiumGiveaway ) Zero () bool {
if i == nil {
return true
}
if !(i .Flags .Zero ()) {
return false
}
if !(i .OnlyNewSubscribers == false ) {
return false
}
if !(i .WinnersAreVisible == false ) {
return false
}
if !(i .BoostPeer == nil ) {
return false
}
if !(i .AdditionalPeers == nil ) {
return false
}
if !(i .CountriesISO2 == nil ) {
return false
}
if !(i .PrizeDescription == "" ) {
return false
}
if !(i .RandomID == 0 ) {
return false
}
if !(i .UntilDate == 0 ) {
return false
}
if !(i .Currency == "" ) {
return false
}
if !(i .Amount == 0 ) {
return false
}
return true
}
func (i *InputStorePaymentPremiumGiveaway ) String () string {
if i == nil {
return "InputStorePaymentPremiumGiveaway(nil)"
}
type Alias InputStorePaymentPremiumGiveaway
return fmt .Sprintf ("InputStorePaymentPremiumGiveaway%+v" , Alias (*i ))
}
func (i *InputStorePaymentPremiumGiveaway ) FillFrom (from interface {
GetOnlyNewSubscribers () (value bool )
GetWinnersAreVisible () (value bool )
GetBoostPeer () (value InputPeerClass )
GetAdditionalPeers () (value []InputPeerClass , ok bool )
GetCountriesISO2 () (value []string , ok bool )
GetPrizeDescription () (value string , ok bool )
GetRandomID () (value int64 )
GetUntilDate () (value int )
GetCurrency () (value string )
GetAmount () (value int64 )
}) {
i .OnlyNewSubscribers = from .GetOnlyNewSubscribers ()
i .WinnersAreVisible = from .GetWinnersAreVisible ()
i .BoostPeer = from .GetBoostPeer ()
if val , ok := from .GetAdditionalPeers (); ok {
i .AdditionalPeers = val
}
if val , ok := from .GetCountriesISO2 (); ok {
i .CountriesISO2 = val
}
if val , ok := from .GetPrizeDescription (); ok {
i .PrizeDescription = val
}
i .RandomID = from .GetRandomID ()
i .UntilDate = from .GetUntilDate ()
i .Currency = from .GetCurrency ()
i .Amount = from .GetAmount ()
}
func (*InputStorePaymentPremiumGiveaway ) TypeID () uint32 {
return InputStorePaymentPremiumGiveawayTypeID
}
func (*InputStorePaymentPremiumGiveaway ) TypeName () string {
return "inputStorePaymentPremiumGiveaway"
}
func (i *InputStorePaymentPremiumGiveaway ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "inputStorePaymentPremiumGiveaway" ,
ID : InputStorePaymentPremiumGiveawayTypeID ,
}
if i == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "OnlyNewSubscribers" ,
SchemaName : "only_new_subscribers" ,
Null : !i .Flags .Has (0 ),
},
{
Name : "WinnersAreVisible" ,
SchemaName : "winners_are_visible" ,
Null : !i .Flags .Has (3 ),
},
{
Name : "BoostPeer" ,
SchemaName : "boost_peer" ,
},
{
Name : "AdditionalPeers" ,
SchemaName : "additional_peers" ,
Null : !i .Flags .Has (1 ),
},
{
Name : "CountriesISO2" ,
SchemaName : "countries_iso2" ,
Null : !i .Flags .Has (2 ),
},
{
Name : "PrizeDescription" ,
SchemaName : "prize_description" ,
Null : !i .Flags .Has (4 ),
},
{
Name : "RandomID" ,
SchemaName : "random_id" ,
},
{
Name : "UntilDate" ,
SchemaName : "until_date" ,
},
{
Name : "Currency" ,
SchemaName : "currency" ,
},
{
Name : "Amount" ,
SchemaName : "amount" ,
},
}
return typ
}
func (i *InputStorePaymentPremiumGiveaway ) SetFlags () {
if !(i .OnlyNewSubscribers == false ) {
i .Flags .Set (0 )
}
if !(i .WinnersAreVisible == false ) {
i .Flags .Set (3 )
}
if !(i .AdditionalPeers == nil ) {
i .Flags .Set (1 )
}
if !(i .CountriesISO2 == nil ) {
i .Flags .Set (2 )
}
if !(i .PrizeDescription == "" ) {
i .Flags .Set (4 )
}
}
func (i *InputStorePaymentPremiumGiveaway ) Encode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentPremiumGiveaway#160544ca as nil" )
}
b .PutID (InputStorePaymentPremiumGiveawayTypeID )
return i .EncodeBare (b )
}
func (i *InputStorePaymentPremiumGiveaway ) EncodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't encode inputStorePaymentPremiumGiveaway#160544ca as nil" )
}
i .SetFlags ()
if err := i .Flags .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field flags: %w" , err )
}
if i .BoostPeer == nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field boost_peer is nil" )
}
if err := i .BoostPeer .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field boost_peer: %w" , err )
}
if i .Flags .Has (1 ) {
b .PutVectorHeader (len (i .AdditionalPeers ))
for idx , v := range i .AdditionalPeers {
if v == nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers element with index %d: %w" , idx , err )
}
}
}
if i .Flags .Has (2 ) {
b .PutVectorHeader (len (i .CountriesISO2 ))
for _ , v := range i .CountriesISO2 {
b .PutString (v )
}
}
if i .Flags .Has (4 ) {
b .PutString (i .PrizeDescription )
}
b .PutLong (i .RandomID )
b .PutInt (i .UntilDate )
b .PutString (i .Currency )
b .PutLong (i .Amount )
return nil
}
func (i *InputStorePaymentPremiumGiveaway ) Decode (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentPremiumGiveaway#160544ca to nil" )
}
if err := b .ConsumeID (InputStorePaymentPremiumGiveawayTypeID ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: %w" , err )
}
return i .DecodeBare (b )
}
func (i *InputStorePaymentPremiumGiveaway ) DecodeBare (b *bin .Buffer ) error {
if i == nil {
return fmt .Errorf ("can't decode inputStorePaymentPremiumGiveaway#160544ca to nil" )
}
{
if err := i .Flags .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field flags: %w" , err )
}
}
i .OnlyNewSubscribers = i .Flags .Has (0 )
i .WinnersAreVisible = i .Flags .Has (3 )
{
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field boost_peer: %w" , err )
}
i .BoostPeer = value
}
if i .Flags .Has (1 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers: %w" , err )
}
if headerLen > 0 {
i .AdditionalPeers = make ([]InputPeerClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeInputPeer (b )
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field additional_peers: %w" , err )
}
i .AdditionalPeers = append (i .AdditionalPeers , value )
}
}
if i .Flags .Has (2 ) {
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field countries_iso2: %w" , err )
}
if headerLen > 0 {
i .CountriesISO2 = make ([]string , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field countries_iso2: %w" , err )
}
i .CountriesISO2 = append (i .CountriesISO2 , value )
}
}
if i .Flags .Has (4 ) {
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field prize_description: %w" , err )
}
i .PrizeDescription = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field random_id: %w" , err )
}
i .RandomID = value
}
{
value , err := b .Int ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field until_date: %w" , err )
}
i .UntilDate = value
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field currency: %w" , err )
}
i .Currency = value
}
{
value , err := b .Long ()
if err != nil {
return fmt .Errorf ("unable to decode inputStorePaymentPremiumGiveaway#160544ca: field amount: %w" , err )
}
i .Amount = value
}
return nil
}
func (i *InputStorePaymentPremiumGiveaway ) SetOnlyNewSubscribers (value bool ) {
if value {
i .Flags .Set (0 )
i .OnlyNewSubscribers = true
} else {
i .Flags .Unset (0 )
i .OnlyNewSubscribers = false
}
}
func (i *InputStorePaymentPremiumGiveaway ) GetOnlyNewSubscribers () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (0 )
}
func (i *InputStorePaymentPremiumGiveaway ) SetWinnersAreVisible (value bool ) {
if value {
i .Flags .Set (3 )
i .WinnersAreVisible = true
} else {
i .Flags .Unset (3 )
i .WinnersAreVisible = false
}
}
func (i *InputStorePaymentPremiumGiveaway ) GetWinnersAreVisible () (value bool ) {
if i == nil {
return
}
return i .Flags .Has (3 )
}
func (i *InputStorePaymentPremiumGiveaway ) GetBoostPeer () (value InputPeerClass ) {
if i == nil {
return
}
return i .BoostPeer
}
func (i *InputStorePaymentPremiumGiveaway ) SetAdditionalPeers (value []InputPeerClass ) {
i .Flags .Set (1 )
i .AdditionalPeers = value
}
func (i *InputStorePaymentPremiumGiveaway ) GetAdditionalPeers () (value []InputPeerClass , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (1 ) {
return value , false
}
return i .AdditionalPeers , true
}
func (i *InputStorePaymentPremiumGiveaway ) SetCountriesISO2 (value []string ) {
i .Flags .Set (2 )
i .CountriesISO2 = value
}
func (i *InputStorePaymentPremiumGiveaway ) GetCountriesISO2 () (value []string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (2 ) {
return value , false
}
return i .CountriesISO2 , true
}
func (i *InputStorePaymentPremiumGiveaway ) SetPrizeDescription (value string ) {
i .Flags .Set (4 )
i .PrizeDescription = value
}
func (i *InputStorePaymentPremiumGiveaway ) GetPrizeDescription () (value string , ok bool ) {
if i == nil {
return
}
if !i .Flags .Has (4 ) {
return value , false
}
return i .PrizeDescription , true
}
func (i *InputStorePaymentPremiumGiveaway ) GetRandomID () (value int64 ) {
if i == nil {
return
}
return i .RandomID
}
func (i *InputStorePaymentPremiumGiveaway ) GetUntilDate () (value int ) {
if i == nil {
return
}
return i .UntilDate
}
func (i *InputStorePaymentPremiumGiveaway ) GetCurrency () (value string ) {
if i == nil {
return
}
return i .Currency
}
func (i *InputStorePaymentPremiumGiveaway ) GetAmount () (value int64 ) {
if i == nil {
return
}
return i .Amount
}
func (i *InputStorePaymentPremiumGiveaway ) MapAdditionalPeers () (value InputPeerClassArray , ok bool ) {
if !i .Flags .Has (1 ) {
return value , false
}
return InputPeerClassArray (i .AdditionalPeers ), true
}
const InputStorePaymentPurposeClassName = "InputStorePaymentPurpose"
type InputStorePaymentPurposeClass interface {
bin .Encoder
bin .Decoder
bin .BareEncoder
bin .BareDecoder
construct () InputStorePaymentPurposeClass
TypeID () uint32
TypeName () string
String () string
Zero () bool
}
func DecodeInputStorePaymentPurpose (buf *bin .Buffer ) (InputStorePaymentPurposeClass , error ) {
id , err := buf .PeekID ()
if err != nil {
return nil , err
}
switch id {
case InputStorePaymentPremiumSubscriptionTypeID :
v := InputStorePaymentPremiumSubscription {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputStorePaymentPurposeClass: %w" , err )
}
return &v , nil
case InputStorePaymentGiftPremiumTypeID :
v := InputStorePaymentGiftPremium {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputStorePaymentPurposeClass: %w" , err )
}
return &v , nil
case InputStorePaymentPremiumGiftCodeTypeID :
v := InputStorePaymentPremiumGiftCode {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputStorePaymentPurposeClass: %w" , err )
}
return &v , nil
case InputStorePaymentPremiumGiveawayTypeID :
v := InputStorePaymentPremiumGiveaway {}
if err := v .Decode (buf ); err != nil {
return nil , fmt .Errorf ("unable to decode InputStorePaymentPurposeClass: %w" , err )
}
return &v , nil
default :
return nil , fmt .Errorf ("unable to decode InputStorePaymentPurposeClass: %w" , bin .NewUnexpectedID (id ))
}
}
type InputStorePaymentPurposeBox struct {
InputStorePaymentPurpose InputStorePaymentPurposeClass
}
func (b *InputStorePaymentPurposeBox ) Decode (buf *bin .Buffer ) error {
if b == nil {
return fmt .Errorf ("unable to decode InputStorePaymentPurposeBox to nil" )
}
v , err := DecodeInputStorePaymentPurpose (buf )
if err != nil {
return fmt .Errorf ("unable to decode boxed value: %w" , err )
}
b .InputStorePaymentPurpose = v
return nil
}
func (b *InputStorePaymentPurposeBox ) Encode (buf *bin .Buffer ) error {
if b == nil || b .InputStorePaymentPurpose == nil {
return fmt .Errorf ("unable to encode InputStorePaymentPurposeClass as nil" )
}
return b .InputStorePaymentPurpose .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 .