// 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{}
)

// PremiumBoostsStatus represents TL type `premium.boostsStatus#4959427a`.
// Contains info about the current boost status¹ of a peer.
//
// Links:
//  1. https://core.telegram.org/api/boost
//
// See https://core.telegram.org/constructor/premium.boostsStatus for reference.
type PremiumBoostsStatus struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether we're currently boosting this channel, my_boost_slots will also be set.
	MyBoost bool
	// The current boost level of the channel.
	Level int
	// The number of boosts acquired so far in the current level.
	CurrentLevelBoosts int
	// Total number of boosts acquired so far.
	Boosts int
	// The number of boosts acquired from created Telegram Premium gift codes¹ and
	// giveaways²; only returned to channel admins.
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	//  2) https://core.telegram.org/api/giveaways
	//
	// Use SetGiftBoosts and GetGiftBoosts helpers.
	GiftBoosts int
	// Total number of boosts needed to reach the next level; if absent, the next level isn't
	// available.
	//
	// Use SetNextLevelBoosts and GetNextLevelBoosts helpers.
	NextLevelBoosts int
	// Only returned to channel admins: contains the approximated number of Premium users
	// subscribed to the channel, related to the total number of subscribers.
	//
	// Use SetPremiumAudience and GetPremiumAudience helpers.
	PremiumAudience StatsPercentValue
	// Boost deep link »¹ that can be used to boost the chat.
	//
	// Links:
	//  1) https://core.telegram.org/api/links#boost-links
	BoostURL string
	// A list of prepaid giveaways¹ available for the chat; only returned to channel admins.
	//
	// Links:
	//  1) https://core.telegram.org/api/giveaways
	//
	// Use SetPrepaidGiveaways and GetPrepaidGiveaways helpers.
	PrepaidGiveaways []PrepaidGiveaway
	// Indicates which of our boost slots¹ we've assigned to this peer (populated if
	// my_boost is set).
	//
	// Links:
	//  1) https://core.telegram.org/api/boost
	//
	// Use SetMyBoostSlots and GetMyBoostSlots helpers.
	MyBoostSlots []int
}

// PremiumBoostsStatusTypeID is TL type id of PremiumBoostsStatus.
const PremiumBoostsStatusTypeID = 0x4959427a

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

func ( *PremiumBoostsStatus) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.MyBoost == false) {
		return false
	}
	if !(.Level == 0) {
		return false
	}
	if !(.CurrentLevelBoosts == 0) {
		return false
	}
	if !(.Boosts == 0) {
		return false
	}
	if !(.GiftBoosts == 0) {
		return false
	}
	if !(.NextLevelBoosts == 0) {
		return false
	}
	if !(.PremiumAudience.Zero()) {
		return false
	}
	if !(.BoostURL == "") {
		return false
	}
	if !(.PrepaidGiveaways == nil) {
		return false
	}
	if !(.MyBoostSlots == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PremiumBoostsStatus from given interface.
func ( *PremiumBoostsStatus) ( interface {
	() ( bool)
	() ( int)
	() ( int)
	() ( int)
	() ( int,  bool)
	() ( int,  bool)
	() ( StatsPercentValue,  bool)
	() ( string)
	() ( []PrepaidGiveaway,  bool)
	() ( []int,  bool)
}) {
	.MyBoost = .()
	.Level = .()
	.CurrentLevelBoosts = .()
	.Boosts = .()
	if ,  := .();  {
		.GiftBoosts = 
	}

	if ,  := .();  {
		.NextLevelBoosts = 
	}

	if ,  := .();  {
		.PremiumAudience = 
	}

	.BoostURL = .()
	if ,  := .();  {
		.PrepaidGiveaways = 
	}

	if ,  := .();  {
		.MyBoostSlots = 
	}

}

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

// TypeName returns name of type in TL schema.
func (*PremiumBoostsStatus) () string {
	return "premium.boostsStatus"
}

// TypeInfo returns info about TL type.
func ( *PremiumBoostsStatus) () tdp.Type {
	 := tdp.Type{
		Name: "premium.boostsStatus",
		ID:   PremiumBoostsStatusTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "MyBoost",
			SchemaName: "my_boost",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Level",
			SchemaName: "level",
		},
		{
			Name:       "CurrentLevelBoosts",
			SchemaName: "current_level_boosts",
		},
		{
			Name:       "Boosts",
			SchemaName: "boosts",
		},
		{
			Name:       "GiftBoosts",
			SchemaName: "gift_boosts",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "NextLevelBoosts",
			SchemaName: "next_level_boosts",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "PremiumAudience",
			SchemaName: "premium_audience",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "BoostURL",
			SchemaName: "boost_url",
		},
		{
			Name:       "PrepaidGiveaways",
			SchemaName: "prepaid_giveaways",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "MyBoostSlots",
			SchemaName: "my_boost_slots",
			Null:       !.Flags.Has(2),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PremiumBoostsStatus) () {
	if !(.MyBoost == false) {
		.Flags.Set(2)
	}
	if !(.GiftBoosts == 0) {
		.Flags.Set(4)
	}
	if !(.NextLevelBoosts == 0) {
		.Flags.Set(0)
	}
	if !(.PremiumAudience.Zero()) {
		.Flags.Set(1)
	}
	if !(.PrepaidGiveaways == nil) {
		.Flags.Set(3)
	}
	if !(.MyBoostSlots == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *PremiumBoostsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.boostsStatus#4959427a as nil")
	}
	.PutID(PremiumBoostsStatusTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PremiumBoostsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode premium.boostsStatus#4959427a as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field flags: %w", )
	}
	.PutInt(.Level)
	.PutInt(.CurrentLevelBoosts)
	.PutInt(.Boosts)
	if .Flags.Has(4) {
		.PutInt(.GiftBoosts)
	}
	if .Flags.Has(0) {
		.PutInt(.NextLevelBoosts)
	}
	if .Flags.Has(1) {
		if  := .PremiumAudience.Encode();  != nil {
			return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field premium_audience: %w", )
		}
	}
	.PutString(.BoostURL)
	if .Flags.Has(3) {
		.PutVectorHeader(len(.PrepaidGiveaways))
		for ,  := range .PrepaidGiveaways {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode premium.boostsStatus#4959427a: field prepaid_giveaways element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(2) {
		.PutVectorHeader(len(.MyBoostSlots))
		for ,  := range .MyBoostSlots {
			.PutInt()
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PremiumBoostsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.boostsStatus#4959427a to nil")
	}
	if  := .ConsumeID(PremiumBoostsStatusTypeID);  != nil {
		return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PremiumBoostsStatus) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode premium.boostsStatus#4959427a to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field flags: %w", )
		}
	}
	.MyBoost = .Flags.Has(2)
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field level: %w", )
		}
		.Level = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field current_level_boosts: %w", )
		}
		.CurrentLevelBoosts = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field boosts: %w", )
		}
		.Boosts = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field gift_boosts: %w", )
		}
		.GiftBoosts = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field next_level_boosts: %w", )
		}
		.NextLevelBoosts = 
	}
	if .Flags.Has(1) {
		if  := .PremiumAudience.Decode();  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field premium_audience: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field boost_url: %w", )
		}
		.BoostURL = 
	}
	if .Flags.Has(3) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w", )
		}

		if  > 0 {
			.PrepaidGiveaways = make([]PrepaidGiveaway, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  PrepaidGiveaway
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field prepaid_giveaways: %w", )
			}
			.PrepaidGiveaways = append(.PrepaidGiveaways, )
		}
	}
	if .Flags.Has(2) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field my_boost_slots: %w", )
		}

		if  > 0 {
			.MyBoostSlots = make([]int, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := .Int()
			if  != nil {
				return fmt.Errorf("unable to decode premium.boostsStatus#4959427a: field my_boost_slots: %w", )
			}
			.MyBoostSlots = append(.MyBoostSlots, )
		}
	}
	return nil
}

// SetMyBoost sets value of MyBoost conditional field.
func ( *PremiumBoostsStatus) ( bool) {
	if  {
		.Flags.Set(2)
		.MyBoost = true
	} else {
		.Flags.Unset(2)
		.MyBoost = false
	}
}

// GetMyBoost returns value of MyBoost conditional field.
func ( *PremiumBoostsStatus) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// GetLevel returns value of Level field.
func ( *PremiumBoostsStatus) () ( int) {
	if  == nil {
		return
	}
	return .Level
}

// GetCurrentLevelBoosts returns value of CurrentLevelBoosts field.
func ( *PremiumBoostsStatus) () ( int) {
	if  == nil {
		return
	}
	return .CurrentLevelBoosts
}

// GetBoosts returns value of Boosts field.
func ( *PremiumBoostsStatus) () ( int) {
	if  == nil {
		return
	}
	return .Boosts
}

// SetGiftBoosts sets value of GiftBoosts conditional field.
func ( *PremiumBoostsStatus) ( int) {
	.Flags.Set(4)
	.GiftBoosts = 
}

// GetGiftBoosts returns value of GiftBoosts conditional field and
// boolean which is true if field was set.
func ( *PremiumBoostsStatus) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .GiftBoosts, true
}

// SetNextLevelBoosts sets value of NextLevelBoosts conditional field.
func ( *PremiumBoostsStatus) ( int) {
	.Flags.Set(0)
	.NextLevelBoosts = 
}

// GetNextLevelBoosts returns value of NextLevelBoosts conditional field and
// boolean which is true if field was set.
func ( *PremiumBoostsStatus) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .NextLevelBoosts, true
}

// SetPremiumAudience sets value of PremiumAudience conditional field.
func ( *PremiumBoostsStatus) ( StatsPercentValue) {
	.Flags.Set(1)
	.PremiumAudience = 
}

// GetPremiumAudience returns value of PremiumAudience conditional field and
// boolean which is true if field was set.
func ( *PremiumBoostsStatus) () ( StatsPercentValue,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .PremiumAudience, true
}

// GetBoostURL returns value of BoostURL field.
func ( *PremiumBoostsStatus) () ( string) {
	if  == nil {
		return
	}
	return .BoostURL
}

// SetPrepaidGiveaways sets value of PrepaidGiveaways conditional field.
func ( *PremiumBoostsStatus) ( []PrepaidGiveaway) {
	.Flags.Set(3)
	.PrepaidGiveaways = 
}

// GetPrepaidGiveaways returns value of PrepaidGiveaways conditional field and
// boolean which is true if field was set.
func ( *PremiumBoostsStatus) () ( []PrepaidGiveaway,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .PrepaidGiveaways, true
}

// SetMyBoostSlots sets value of MyBoostSlots conditional field.
func ( *PremiumBoostsStatus) ( []int) {
	.Flags.Set(2)
	.MyBoostSlots = 
}

// GetMyBoostSlots returns value of MyBoostSlots conditional field and
// boolean which is true if field was set.
func ( *PremiumBoostsStatus) () ( []int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .MyBoostSlots, true
}