// Code generated by gotdgen, DO NOT EDIT.

package tg

import (
	
	
	
	
	

	

	
	
	
	
)

// No-op definition for keeping imports.
var (
	_ = bin.Buffer{}
	_ = context.Background()
	_ = fmt.Stringer(nil)
	_ = strings.Builder{}
	_ = errors.Is
	_ = multierr.AppendInto
	_ = sort.Ints
	_ = tdp.Format
	_ = tgerr.Error{}
	_ = tdjson.Encoder{}
)

// HelpPremiumPromo represents TL type `help.premiumPromo#5334759c`.
// Telegram Premium promotion information
// Note that the video_sections+videos fields are a list of videos, and the corresponding
// premium feature identifiers.
// They're equivalent to a section => video dictionary, with keys from video_section and
// values from videos.
// The keys in video_sections correspond to a specific feature identifier, and the
// associated promotional video should be shown when the associated feature row is
// clicked.
//
// See https://core.telegram.org/constructor/help.premiumPromo for reference.
type HelpPremiumPromo struct {
	// Description of the current state of the user's Telegram Premium subscription
	StatusText string
	// Message entities for styled text¹
	//
	// Links:
	//  1) https://core.telegram.org/api/entities
	StatusEntities []MessageEntityClass
	// A list of premium feature identifiers »¹, associated to each video
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	VideoSections []string
	// A list of videos
	Videos []DocumentClass
	// Telegram Premium subscription options
	PeriodOptions []PremiumSubscriptionOption
	// Related user information
	Users []UserClass
}

// HelpPremiumPromoTypeID is TL type id of HelpPremiumPromo.
const HelpPremiumPromoTypeID = 0x5334759c

// Ensuring interfaces in compile-time for HelpPremiumPromo.
var (
	_ bin.Encoder     = &HelpPremiumPromo{}
	_ bin.Decoder     = &HelpPremiumPromo{}
	_ bin.BareEncoder = &HelpPremiumPromo{}
	_ bin.BareDecoder = &HelpPremiumPromo{}
)

func ( *HelpPremiumPromo) () bool {
	if  == nil {
		return true
	}
	if !(.StatusText == "") {
		return false
	}
	if !(.StatusEntities == nil) {
		return false
	}
	if !(.VideoSections == nil) {
		return false
	}
	if !(.Videos == nil) {
		return false
	}
	if !(.PeriodOptions == nil) {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

// String implements fmt.Stringer.
func ( *HelpPremiumPromo) () string {
	if  == nil {
		return "HelpPremiumPromo(nil)"
	}
	type  HelpPremiumPromo
	return fmt.Sprintf("HelpPremiumPromo%+v", (*))
}

// FillFrom fills HelpPremiumPromo from given interface.
func ( *HelpPremiumPromo) ( interface {
	() ( string)
	() ( []MessageEntityClass)
	() ( []string)
	() ( []DocumentClass)
	() ( []PremiumSubscriptionOption)
	() ( []UserClass)
}) {
	.StatusText = .()
	.StatusEntities = .()
	.VideoSections = .()
	.Videos = .()
	.PeriodOptions = .()
	.Users = .()
}

// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*HelpPremiumPromo) () uint32 {
	return HelpPremiumPromoTypeID
}

// TypeName returns name of type in TL schema.
func (*HelpPremiumPromo) () string {
	return "help.premiumPromo"
}

// TypeInfo returns info about TL type.
func ( *HelpPremiumPromo) () tdp.Type {
	 := tdp.Type{
		Name: "help.premiumPromo",
		ID:   HelpPremiumPromoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.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 
}

// Encode implements bin.Encoder.
func ( *HelpPremiumPromo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.premiumPromo#5334759c as nil")
	}
	.PutID(HelpPremiumPromoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpPremiumPromo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.premiumPromo#5334759c as nil")
	}
	.PutString(.StatusText)
	.PutVectorHeader(len(.StatusEntities))
	for ,  := range .StatusEntities {
		if  == nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field status_entities element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.VideoSections))
	for ,  := range .VideoSections {
		.PutString()
	}
	.PutVectorHeader(len(.Videos))
	for ,  := range .Videos {
		if  == nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field videos element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field videos element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.PeriodOptions))
	for ,  := range .PeriodOptions {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field period_options element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode help.premiumPromo#5334759c: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *HelpPremiumPromo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.premiumPromo#5334759c to nil")
	}
	if  := .ConsumeID(HelpPremiumPromoTypeID);  != nil {
		return fmt.Errorf("unable to decode help.premiumPromo#5334759c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *HelpPremiumPromo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.premiumPromo#5334759c to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_text: %w", )
		}
		.StatusText = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_entities: %w", )
		}

		if  > 0 {
			.StatusEntities = make([]MessageEntityClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeMessageEntity()
			if  != nil {
				return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field status_entities: %w", )
			}
			.StatusEntities = append(.StatusEntities, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field video_sections: %w", )
		}

		if  > 0 {
			.VideoSections = make([]string, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .String()
			if  != nil {
				return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field video_sections: %w", )
			}
			.VideoSections = append(.VideoSections, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field videos: %w", )
		}

		if  > 0 {
			.Videos = make([]DocumentClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeDocument()
			if  != nil {
				return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field videos: %w", )
			}
			.Videos = append(.Videos, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field period_options: %w", )
		}

		if  > 0 {
			.PeriodOptions = make([]PremiumSubscriptionOption, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  PremiumSubscriptionOption
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field period_options: %w", )
			}
			.PeriodOptions = append(.PeriodOptions, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode help.premiumPromo#5334759c: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

// GetStatusText returns value of StatusText field.
func ( *HelpPremiumPromo) () ( string) {
	if  == nil {
		return
	}
	return .StatusText
}

// GetStatusEntities returns value of StatusEntities field.
func ( *HelpPremiumPromo) () ( []MessageEntityClass) {
	if  == nil {
		return
	}
	return .StatusEntities
}

// GetVideoSections returns value of VideoSections field.
func ( *HelpPremiumPromo) () ( []string) {
	if  == nil {
		return
	}
	return .VideoSections
}

// GetVideos returns value of Videos field.
func ( *HelpPremiumPromo) () ( []DocumentClass) {
	if  == nil {
		return
	}
	return .Videos
}

// GetPeriodOptions returns value of PeriodOptions field.
func ( *HelpPremiumPromo) () ( []PremiumSubscriptionOption) {
	if  == nil {
		return
	}
	return .PeriodOptions
}

// GetUsers returns value of Users field.
func ( *HelpPremiumPromo) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapStatusEntities returns field StatusEntities wrapped in MessageEntityClassArray helper.
func ( *HelpPremiumPromo) () ( MessageEntityClassArray) {
	return MessageEntityClassArray(.StatusEntities)
}

// MapVideos returns field Videos wrapped in DocumentClassArray helper.
func ( *HelpPremiumPromo) () ( DocumentClassArray) {
	return DocumentClassArray(.Videos)
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *HelpPremiumPromo) () ( UserClassArray) {
	return UserClassArray(.Users)
}