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

// PaymentsStarGiftUpgradeAttributes represents TL type `payments.starGiftUpgradeAttributes#46c6e36f`.
// List of just the collectible attributes that may appear for a gift type once it's
// upgraded to a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/payments.starGiftUpgradeAttributes for reference.
type PaymentsStarGiftUpgradeAttributes struct {
	// Full list of possible attributes that may be assigned when gifts of the specified type
	// are turned into collectible gifts »¹, including craft-only models marked with
	// starGiftAttributeModel².crafted.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	//  2) https://core.telegram.org/constructor/starGiftAttributeModel
	Attributes []StarGiftAttributeClass
}

// PaymentsStarGiftUpgradeAttributesTypeID is TL type id of PaymentsStarGiftUpgradeAttributes.
const PaymentsStarGiftUpgradeAttributesTypeID = 0x46c6e36f

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

func ( *PaymentsStarGiftUpgradeAttributes) () bool {
	if  == nil {
		return true
	}
	if !(.Attributes == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsStarGiftUpgradeAttributes from given interface.
func ( *PaymentsStarGiftUpgradeAttributes) ( interface {
	() ( []StarGiftAttributeClass)
}) {
	.Attributes = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsStarGiftUpgradeAttributes) () tdp.Type {
	 := tdp.Type{
		Name: "payments.starGiftUpgradeAttributes",
		ID:   PaymentsStarGiftUpgradeAttributesTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Attributes",
			SchemaName: "attributes",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsStarGiftUpgradeAttributes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftUpgradeAttributes#46c6e36f as nil")
	}
	.PutID(PaymentsStarGiftUpgradeAttributesTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsStarGiftUpgradeAttributes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.starGiftUpgradeAttributes#46c6e36f as nil")
	}
	.PutVectorHeader(len(.Attributes))
	for ,  := range .Attributes {
		if  == nil {
			return fmt.Errorf("unable to encode payments.starGiftUpgradeAttributes#46c6e36f: field attributes element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.starGiftUpgradeAttributes#46c6e36f: field attributes element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsStarGiftUpgradeAttributes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGiftUpgradeAttributes#46c6e36f to nil")
	}
	if  := .ConsumeID(PaymentsStarGiftUpgradeAttributesTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.starGiftUpgradeAttributes#46c6e36f: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsStarGiftUpgradeAttributes) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.starGiftUpgradeAttributes#46c6e36f to nil")
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.starGiftUpgradeAttributes#46c6e36f: field attributes: %w", )
		}

		if  > 0 {
			.Attributes = make([]StarGiftAttributeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStarGiftAttribute()
			if  != nil {
				return fmt.Errorf("unable to decode payments.starGiftUpgradeAttributes#46c6e36f: field attributes: %w", )
			}
			.Attributes = append(.Attributes, )
		}
	}
	return nil
}

// GetAttributes returns value of Attributes field.
func ( *PaymentsStarGiftUpgradeAttributes) () ( []StarGiftAttributeClass) {
	if  == nil {
		return
	}
	return .Attributes
}

// MapAttributes returns field Attributes wrapped in StarGiftAttributeClassArray helper.
func ( *PaymentsStarGiftUpgradeAttributes) () ( StarGiftAttributeClassArray) {
	return StarGiftAttributeClassArray(.Attributes)
}