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

// StarGiftAttributeIDModel represents TL type `starGiftAttributeIdModel#48aaae3c`.
// The ID of a model of a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/starGiftAttributeIdModel for reference.
type StarGiftAttributeIDModel struct {
	// The sticker¹ representing the upgraded gift
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers
	DocumentID int64
}

// StarGiftAttributeIDModelTypeID is TL type id of StarGiftAttributeIDModel.
const StarGiftAttributeIDModelTypeID = 0x48aaae3c

// construct implements constructor of StarGiftAttributeIDClass.
func ( StarGiftAttributeIDModel) () StarGiftAttributeIDClass { return & }

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

	_ StarGiftAttributeIDClass = &StarGiftAttributeIDModel{}
)

func ( *StarGiftAttributeIDModel) () bool {
	if  == nil {
		return true
	}
	if !(.DocumentID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributeIDModel from given interface.
func ( *StarGiftAttributeIDModel) ( interface {
	() ( int64)
}) {
	.DocumentID = .()
}

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

// TypeName returns name of type in TL schema.
func (*StarGiftAttributeIDModel) () string {
	return "starGiftAttributeIdModel"
}

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeIDModel) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeIdModel",
		ID:   StarGiftAttributeIDModelTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DocumentID",
			SchemaName: "document_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeIDModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeIdModel#48aaae3c as nil")
	}
	.PutID(StarGiftAttributeIDModelTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeIDModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeIdModel#48aaae3c as nil")
	}
	.PutLong(.DocumentID)
	return nil
}

// Decode implements bin.Decoder.
func ( *StarGiftAttributeIDModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeIdModel#48aaae3c to nil")
	}
	if  := .ConsumeID(StarGiftAttributeIDModelTypeID);  != nil {
		return fmt.Errorf("unable to decode starGiftAttributeIdModel#48aaae3c: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeIDModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeIdModel#48aaae3c to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeIdModel#48aaae3c: field document_id: %w", )
		}
		.DocumentID = 
	}
	return nil
}

// GetDocumentID returns value of DocumentID field.
func ( *StarGiftAttributeIDModel) () ( int64) {
	if  == nil {
		return
	}
	return .DocumentID
}

// StarGiftAttributeIDPattern represents TL type `starGiftAttributeIdPattern#4a162433`.
// The ID of a pattern of a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/starGiftAttributeIdPattern for reference.
type StarGiftAttributeIDPattern struct {
	// The sticker¹ representing the symbol
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers
	DocumentID int64
}

// StarGiftAttributeIDPatternTypeID is TL type id of StarGiftAttributeIDPattern.
const StarGiftAttributeIDPatternTypeID = 0x4a162433

// construct implements constructor of StarGiftAttributeIDClass.
func ( StarGiftAttributeIDPattern) () StarGiftAttributeIDClass { return & }

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

	_ StarGiftAttributeIDClass = &StarGiftAttributeIDPattern{}
)

func ( *StarGiftAttributeIDPattern) () bool {
	if  == nil {
		return true
	}
	if !(.DocumentID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributeIDPattern from given interface.
func ( *StarGiftAttributeIDPattern) ( interface {
	() ( int64)
}) {
	.DocumentID = .()
}

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

// TypeName returns name of type in TL schema.
func (*StarGiftAttributeIDPattern) () string {
	return "starGiftAttributeIdPattern"
}

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeIDPattern) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeIdPattern",
		ID:   StarGiftAttributeIDPatternTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "DocumentID",
			SchemaName: "document_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeIDPattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeIdPattern#4a162433 as nil")
	}
	.PutID(StarGiftAttributeIDPatternTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeIDPattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeIdPattern#4a162433 as nil")
	}
	.PutLong(.DocumentID)
	return nil
}

// Decode implements bin.Decoder.
func ( *StarGiftAttributeIDPattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeIdPattern#4a162433 to nil")
	}
	if  := .ConsumeID(StarGiftAttributeIDPatternTypeID);  != nil {
		return fmt.Errorf("unable to decode starGiftAttributeIdPattern#4a162433: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeIDPattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeIdPattern#4a162433 to nil")
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeIdPattern#4a162433: field document_id: %w", )
		}
		.DocumentID = 
	}
	return nil
}

// GetDocumentID returns value of DocumentID field.
func ( *StarGiftAttributeIDPattern) () ( int64) {
	if  == nil {
		return
	}
	return .DocumentID
}

// StarGiftAttributeIDBackdrop represents TL type `starGiftAttributeIdBackdrop#1f01c757`.
// The ID of a backdrop of a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/starGiftAttributeIdBackdrop for reference.
type StarGiftAttributeIDBackdrop struct {
	// Unique ID of the backdrop.
	BackdropID int
}

// StarGiftAttributeIDBackdropTypeID is TL type id of StarGiftAttributeIDBackdrop.
const StarGiftAttributeIDBackdropTypeID = 0x1f01c757

// construct implements constructor of StarGiftAttributeIDClass.
func ( StarGiftAttributeIDBackdrop) () StarGiftAttributeIDClass { return & }

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

	_ StarGiftAttributeIDClass = &StarGiftAttributeIDBackdrop{}
)

func ( *StarGiftAttributeIDBackdrop) () bool {
	if  == nil {
		return true
	}
	if !(.BackdropID == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributeIDBackdrop from given interface.
func ( *StarGiftAttributeIDBackdrop) ( interface {
	() ( int)
}) {
	.BackdropID = .()
}

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

// TypeName returns name of type in TL schema.
func (*StarGiftAttributeIDBackdrop) () string {
	return "starGiftAttributeIdBackdrop"
}

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeIDBackdrop) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeIdBackdrop",
		ID:   StarGiftAttributeIDBackdropTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "BackdropID",
			SchemaName: "backdrop_id",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeIDBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeIdBackdrop#1f01c757 as nil")
	}
	.PutID(StarGiftAttributeIDBackdropTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeIDBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeIdBackdrop#1f01c757 as nil")
	}
	.PutInt(.BackdropID)
	return nil
}

// Decode implements bin.Decoder.
func ( *StarGiftAttributeIDBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeIdBackdrop#1f01c757 to nil")
	}
	if  := .ConsumeID(StarGiftAttributeIDBackdropTypeID);  != nil {
		return fmt.Errorf("unable to decode starGiftAttributeIdBackdrop#1f01c757: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeIDBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeIdBackdrop#1f01c757 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeIdBackdrop#1f01c757: field backdrop_id: %w", )
		}
		.BackdropID = 
	}
	return nil
}

// GetBackdropID returns value of BackdropID field.
func ( *StarGiftAttributeIDBackdrop) () ( int) {
	if  == nil {
		return
	}
	return .BackdropID
}

// StarGiftAttributeIDClassName is schema name of StarGiftAttributeIDClass.
const StarGiftAttributeIDClassName = "StarGiftAttributeId"

// StarGiftAttributeIDClass represents StarGiftAttributeId generic type.
//
// See https://core.telegram.org/type/StarGiftAttributeId for reference.
//
// Constructors:
//   - [StarGiftAttributeIDModel]
//   - [StarGiftAttributeIDPattern]
//   - [StarGiftAttributeIDBackdrop]
//
// Example:
//
//	g, err := tg.DecodeStarGiftAttributeID(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StarGiftAttributeIDModel: // starGiftAttributeIdModel#48aaae3c
//	case *tg.StarGiftAttributeIDPattern: // starGiftAttributeIdPattern#4a162433
//	case *tg.StarGiftAttributeIDBackdrop: // starGiftAttributeIdBackdrop#1f01c757
//	default: panic(v)
//	}
type StarGiftAttributeIDClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StarGiftAttributeIDClass

	// TypeID returns type id in TL schema.
	//
	// See https://core.telegram.org/mtproto/TL-tl#remarks.
	TypeID() uint32
	// TypeName returns name of type in TL schema.
	TypeName() string
	// String implements fmt.Stringer.
	String() string
	// Zero returns true if current object has a zero value.
	Zero() bool
}

// DecodeStarGiftAttributeID implements binary de-serialization for StarGiftAttributeIDClass.
func ( *bin.Buffer) (StarGiftAttributeIDClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StarGiftAttributeIDModelTypeID:
		// Decoding starGiftAttributeIdModel#48aaae3c.
		 := StarGiftAttributeIDModel{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeIDClass: %w", )
		}
		return &, nil
	case StarGiftAttributeIDPatternTypeID:
		// Decoding starGiftAttributeIdPattern#4a162433.
		 := StarGiftAttributeIDPattern{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeIDClass: %w", )
		}
		return &, nil
	case StarGiftAttributeIDBackdropTypeID:
		// Decoding starGiftAttributeIdBackdrop#1f01c757.
		 := StarGiftAttributeIDBackdrop{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeIDClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StarGiftAttributeIDClass: %w", bin.NewUnexpectedID())
	}
}

// StarGiftAttributeID boxes the StarGiftAttributeIDClass providing a helper.
type StarGiftAttributeIDBox struct {
	StarGiftAttributeId StarGiftAttributeIDClass
}

// Decode implements bin.Decoder for StarGiftAttributeIDBox.
func ( *StarGiftAttributeIDBox) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("unable to decode StarGiftAttributeIDBox to nil")
	}
	,  := DecodeStarGiftAttributeID()
	if  != nil {
		return fmt.Errorf("unable to decode boxed value: %w", )
	}
	.StarGiftAttributeId = 
	return nil
}

// Encode implements bin.Encode for StarGiftAttributeIDBox.
func ( *StarGiftAttributeIDBox) ( *bin.Buffer) error {
	if  == nil || .StarGiftAttributeId == nil {
		return fmt.Errorf("unable to encode StarGiftAttributeIDClass as nil")
	}
	return .StarGiftAttributeId.Encode()
}