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

// PaymentsStarGiftUpgradePreview represents TL type `payments.starGiftUpgradePreview#3de1dfed`.
// A preview of the possible attributes (chosen randomly) a gift »¹ can receive after
// upgrading it to a collectible gift »², see here »³ for more info.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/api/gifts#collectible-gifts
//  3. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/payments.starGiftUpgradePreview for reference.
type PaymentsStarGiftUpgradePreview struct {
	// Possible gift attributes
	SampleAttributes []StarGiftAttributeClass
	// Contains a similar list of upgrade prices and timestamps, not as granular as in
	// next_prices (i.e. prices are approximately 1 month apart), to be used mainly to scale
	// the price graph, and to show a more general future overview of the upgrade price.
	Prices []StarGiftUpgradePrice
	// Contains the current upgrade price and a list of future prices, each associated to a
	// UNIX timestamp that indicates when the price comes in effect (the current price is
	// valid only until the next one comes into effect, and so on for all prices in the list).
	NextPrices []StarGiftUpgradePrice
}

// PaymentsStarGiftUpgradePreviewTypeID is TL type id of PaymentsStarGiftUpgradePreview.
const PaymentsStarGiftUpgradePreviewTypeID = 0x3de1dfed

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

func ( *PaymentsStarGiftUpgradePreview) () bool {
	if  == nil {
		return true
	}
	if !(.SampleAttributes == nil) {
		return false
	}
	if !(.Prices == nil) {
		return false
	}
	if !(.NextPrices == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsStarGiftUpgradePreview from given interface.
func ( *PaymentsStarGiftUpgradePreview) ( interface {
	() ( []StarGiftAttributeClass)
	() ( []StarGiftUpgradePrice)
	() ( []StarGiftUpgradePrice)
}) {
	.SampleAttributes = .()
	.Prices = .()
	.NextPrices = .()
}

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

// TypeName returns name of type in TL schema.
func (*PaymentsStarGiftUpgradePreview) () string {
	return "payments.starGiftUpgradePreview"
}

// TypeInfo returns info about TL type.
func ( *PaymentsStarGiftUpgradePreview) () tdp.Type {
	 := tdp.Type{
		Name: "payments.starGiftUpgradePreview",
		ID:   PaymentsStarGiftUpgradePreviewTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SampleAttributes",
			SchemaName: "sample_attributes",
		},
		{
			Name:       "Prices",
			SchemaName: "prices",
		},
		{
			Name:       "NextPrices",
			SchemaName: "next_prices",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftUpgradePreview) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftUpgradePreview#3de1dfed as nil")
	}
	.PutID(PaymentsStarGiftUpgradePreviewTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsStarGiftUpgradePreview) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftUpgradePreview#3de1dfed as nil")
	}
	.PutVectorHeader(len(.SampleAttributes))
	for ,  := range .SampleAttributes {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.Prices))
	for ,  := range .Prices {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftUpgradePreview#3de1dfed: field prices element with index %d: %w", , )
		}
	}
	.PutVectorHeader(len(.NextPrices))
	for ,  := range .NextPrices {
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftUpgradePreview#3de1dfed: field next_prices element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsStarGiftUpgradePreview) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGiftUpgradePreview#3de1dfed to nil")
	}
	if  := .ConsumeID(PaymentsStarGiftUpgradePreviewTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsStarGiftUpgradePreview) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGiftUpgradePreview#3de1dfed to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes: %w", )
		}

		if  > 0 {
			.SampleAttributes = make([]StarGiftAttributeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStarGiftAttribute()
			if  != nil {
				return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: field sample_attributes: %w", )
			}
			.SampleAttributes = append(.SampleAttributes, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: field prices: %w", )
		}

		if  > 0 {
			.Prices = make([]StarGiftUpgradePrice, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StarGiftUpgradePrice
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: field prices: %w", )
			}
			.Prices = append(.Prices, )
		}
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: field next_prices: %w", )
		}

		if  > 0 {
			.NextPrices = make([]StarGiftUpgradePrice, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  StarGiftUpgradePrice
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode payments.starGiftUpgradePreview#3de1dfed: field next_prices: %w", )
			}
			.NextPrices = append(.NextPrices, )
		}
	}
	return nil
}

// GetSampleAttributes returns value of SampleAttributes field.
func ( *PaymentsStarGiftUpgradePreview) () ( []StarGiftAttributeClass) {
	if  == nil {
		return
	}
	return .SampleAttributes
}

// GetPrices returns value of Prices field.
func ( *PaymentsStarGiftUpgradePreview) () ( []StarGiftUpgradePrice) {
	if  == nil {
		return
	}
	return .Prices
}

// GetNextPrices returns value of NextPrices field.
func ( *PaymentsStarGiftUpgradePreview) () ( []StarGiftUpgradePrice) {
	if  == nil {
		return
	}
	return .NextPrices
}

// MapSampleAttributes returns field SampleAttributes wrapped in StarGiftAttributeClassArray helper.
func ( *PaymentsStarGiftUpgradePreview) () ( StarGiftAttributeClassArray) {
	return StarGiftAttributeClassArray(.SampleAttributes)
}