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 HelpPremiumPromo struct {
StatusText string
StatusEntities []MessageEntityClass
VideoSections []string
Videos []DocumentClass
PeriodOptions []PremiumSubscriptionOption
Users []UserClass
}
const HelpPremiumPromoTypeID = 0x5334759c
var (
_ bin .Encoder = &HelpPremiumPromo {}
_ bin .Decoder = &HelpPremiumPromo {}
_ bin .BareEncoder = &HelpPremiumPromo {}
_ bin .BareDecoder = &HelpPremiumPromo {}
)
func (p *HelpPremiumPromo ) Zero () bool {
if p == nil {
return true
}
if !(p .StatusText == "" ) {
return false
}
if !(p .StatusEntities == nil ) {
return false
}
if !(p .VideoSections == nil ) {
return false
}
if !(p .Videos == nil ) {
return false
}
if !(p .PeriodOptions == nil ) {
return false
}
if !(p .Users == nil ) {
return false
}
return true
}
func (p *HelpPremiumPromo ) String () string {
if p == nil {
return "HelpPremiumPromo(nil)"
}
type Alias HelpPremiumPromo
return fmt .Sprintf ("HelpPremiumPromo%+v" , Alias (*p ))
}
func (p *HelpPremiumPromo ) FillFrom (from interface {
GetStatusText () (value string )
GetStatusEntities () (value []MessageEntityClass )
GetVideoSections () (value []string )
GetVideos () (value []DocumentClass )
GetPeriodOptions () (value []PremiumSubscriptionOption )
GetUsers () (value []UserClass )
}) {
p .StatusText = from .GetStatusText ()
p .StatusEntities = from .GetStatusEntities ()
p .VideoSections = from .GetVideoSections ()
p .Videos = from .GetVideos ()
p .PeriodOptions = from .GetPeriodOptions ()
p .Users = from .GetUsers ()
}
func (*HelpPremiumPromo ) TypeID () uint32 {
return HelpPremiumPromoTypeID
}
func (*HelpPremiumPromo ) TypeName () string {
return "help.premiumPromo"
}
func (p *HelpPremiumPromo ) TypeInfo () tdp .Type {
typ := tdp .Type {
Name : "help.premiumPromo" ,
ID : HelpPremiumPromoTypeID ,
}
if p == nil {
typ .Null = true
return typ
}
typ .Fields = []tdp .Field {
{
Name : "StatusText" ,
SchemaName : "status_text" ,
},
{
Name : "StatusEntities" ,
SchemaName : "status_entities" ,
},
{
Name : "VideoSections" ,
SchemaName : "video_sections" ,
},
{
Name : "Videos" ,
SchemaName : "videos" ,
},
{
Name : "PeriodOptions" ,
SchemaName : "period_options" ,
},
{
Name : "Users" ,
SchemaName : "users" ,
},
}
return typ
}
func (p *HelpPremiumPromo ) Encode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode help.premiumPromo#5334759c as nil" )
}
b .PutID (HelpPremiumPromoTypeID )
return p .EncodeBare (b )
}
func (p *HelpPremiumPromo ) EncodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't encode help.premiumPromo#5334759c as nil" )
}
b .PutString (p .StatusText )
b .PutVectorHeader (len (p .StatusEntities ))
for idx , v := range p .StatusEntities {
if v == nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .VideoSections ))
for _ , v := range p .VideoSections {
b .PutString (v )
}
b .PutVectorHeader (len (p .Videos ))
for idx , v := range p .Videos {
if v == nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field videos element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field videos element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .PeriodOptions ))
for idx , v := range p .PeriodOptions {
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field period_options element with index %d: %w" , idx , err )
}
}
b .PutVectorHeader (len (p .Users ))
for idx , v := range p .Users {
if v == nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field users element with index %d is nil" , idx )
}
if err := v .Encode (b ); err != nil {
return fmt .Errorf ("unable to encode help.premiumPromo#5334759c: field users element with index %d: %w" , idx , err )
}
}
return nil
}
func (p *HelpPremiumPromo ) Decode (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode help.premiumPromo#5334759c to nil" )
}
if err := b .ConsumeID (HelpPremiumPromoTypeID ); err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: %w" , err )
}
return p .DecodeBare (b )
}
func (p *HelpPremiumPromo ) DecodeBare (b *bin .Buffer ) error {
if p == nil {
return fmt .Errorf ("can't decode help.premiumPromo#5334759c to nil" )
}
{
value , err := b .String ()
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field status_text: %w" , err )
}
p .StatusText = value
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field status_entities: %w" , err )
}
if headerLen > 0 {
p .StatusEntities = make ([]MessageEntityClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeMessageEntity (b )
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field status_entities: %w" , err )
}
p .StatusEntities = append (p .StatusEntities , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field video_sections: %w" , err )
}
if headerLen > 0 {
p .VideoSections = 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 help.premiumPromo#5334759c: field video_sections: %w" , err )
}
p .VideoSections = append (p .VideoSections , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field videos: %w" , err )
}
if headerLen > 0 {
p .Videos = make ([]DocumentClass , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
value , err := DecodeDocument (b )
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field videos: %w" , err )
}
p .Videos = append (p .Videos , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field period_options: %w" , err )
}
if headerLen > 0 {
p .PeriodOptions = make ([]PremiumSubscriptionOption , 0 , headerLen %bin .PreallocateLimit )
}
for idx := 0 ; idx < headerLen ; idx ++ {
var value PremiumSubscriptionOption
if err := value .Decode (b ); err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field period_options: %w" , err )
}
p .PeriodOptions = append (p .PeriodOptions , value )
}
}
{
headerLen , err := b .VectorHeader ()
if err != nil {
return fmt .Errorf ("unable to decode help.premiumPromo#5334759c: field users: %w" , err )
}
if headerLen > 0 {
p .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 help.premiumPromo#5334759c: field users: %w" , err )
}
p .Users = append (p .Users , value )
}
}
return nil
}
func (p *HelpPremiumPromo ) GetStatusText () (value string ) {
if p == nil {
return
}
return p .StatusText
}
func (p *HelpPremiumPromo ) GetStatusEntities () (value []MessageEntityClass ) {
if p == nil {
return
}
return p .StatusEntities
}
func (p *HelpPremiumPromo ) GetVideoSections () (value []string ) {
if p == nil {
return
}
return p .VideoSections
}
func (p *HelpPremiumPromo ) GetVideos () (value []DocumentClass ) {
if p == nil {
return
}
return p .Videos
}
func (p *HelpPremiumPromo ) GetPeriodOptions () (value []PremiumSubscriptionOption ) {
if p == nil {
return
}
return p .PeriodOptions
}
func (p *HelpPremiumPromo ) GetUsers () (value []UserClass ) {
if p == nil {
return
}
return p .Users
}
func (p *HelpPremiumPromo ) MapStatusEntities () (value MessageEntityClassArray ) {
return MessageEntityClassArray (p .StatusEntities )
}
func (p *HelpPremiumPromo ) MapVideos () (value DocumentClassArray ) {
return DocumentClassArray (p .Videos )
}
func (p *HelpPremiumPromo ) MapUsers () (value UserClassArray ) {
return UserClassArray (p .Users )
}
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 .