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

// StarGiftAttributeModel represents TL type `starGiftAttributeModel#565251e2`.
// The model of a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/starGiftAttributeModel for reference.
type StarGiftAttributeModel struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// This model is reserved for crafting »¹, and should be filtered out from regular
	// upgrade previews.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#crafting-collectible-gifts
	Crafted bool
	// Name of the model
	Name string
	// The sticker¹ representing the upgraded gift
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers
	Document DocumentClass
	// Rarity of this model.
	Rarity StarGiftAttributeRarityClass
}

// StarGiftAttributeModelTypeID is TL type id of StarGiftAttributeModel.
const StarGiftAttributeModelTypeID = 0x565251e2

// construct implements constructor of StarGiftAttributeClass.
func ( StarGiftAttributeModel) () StarGiftAttributeClass { return & }

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

	_ StarGiftAttributeClass = &StarGiftAttributeModel{}
)

func ( *StarGiftAttributeModel) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Crafted == false) {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.Document == nil) {
		return false
	}
	if !(.Rarity == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributeModel from given interface.
func ( *StarGiftAttributeModel) ( interface {
	() ( bool)
	() ( string)
	() ( DocumentClass)
	() ( StarGiftAttributeRarityClass)
}) {
	.Crafted = .()
	.Name = .()
	.Document = .()
	.Rarity = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeModel) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeModel",
		ID:   StarGiftAttributeModelTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Crafted",
			SchemaName: "crafted",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "Document",
			SchemaName: "document",
		},
		{
			Name:       "Rarity",
			SchemaName: "rarity",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StarGiftAttributeModel) () {
	if !(.Crafted == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeModel#565251e2 as nil")
	}
	.PutID(StarGiftAttributeModelTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeModel#565251e2 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeModel#565251e2: field flags: %w", )
	}
	.PutString(.Name)
	if .Document == nil {
		return fmt.Errorf("unable to encode starGiftAttributeModel#565251e2: field document is nil")
	}
	if  := .Document.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeModel#565251e2: field document: %w", )
	}
	if .Rarity == nil {
		return fmt.Errorf("unable to encode starGiftAttributeModel#565251e2: field rarity is nil")
	}
	if  := .Rarity.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeModel#565251e2: field rarity: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StarGiftAttributeModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeModel#565251e2 to nil")
	}
	if  := .ConsumeID(StarGiftAttributeModelTypeID);  != nil {
		return fmt.Errorf("unable to decode starGiftAttributeModel#565251e2: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeModel) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeModel#565251e2 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeModel#565251e2: field flags: %w", )
		}
	}
	.Crafted = .Flags.Has(0)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeModel#565251e2: field name: %w", )
		}
		.Name = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeModel#565251e2: field document: %w", )
		}
		.Document = 
	}
	{
		,  := DecodeStarGiftAttributeRarity()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeModel#565251e2: field rarity: %w", )
		}
		.Rarity = 
	}
	return nil
}

// SetCrafted sets value of Crafted conditional field.
func ( *StarGiftAttributeModel) ( bool) {
	if  {
		.Flags.Set(0)
		.Crafted = true
	} else {
		.Flags.Unset(0)
		.Crafted = false
	}
}

// GetCrafted returns value of Crafted conditional field.
func ( *StarGiftAttributeModel) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetName returns value of Name field.
func ( *StarGiftAttributeModel) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// GetDocument returns value of Document field.
func ( *StarGiftAttributeModel) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .Document
}

// GetRarity returns value of Rarity field.
func ( *StarGiftAttributeModel) () ( StarGiftAttributeRarityClass) {
	if  == nil {
		return
	}
	return .Rarity
}

// StarGiftAttributePattern represents TL type `starGiftAttributePattern#4e7085ea`.
// A sticker¹ applied on the backdrop of a collectible gift »² using a repeating
// pattern.
//
// Links:
//  1. https://core.telegram.org/api/stickers
//  2. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/constructor/starGiftAttributePattern for reference.
type StarGiftAttributePattern struct {
	// Name of the symbol
	Name string
	// The symbol
	Document DocumentClass
	// Rarity of this pattern.
	Rarity StarGiftAttributeRarityClass
}

// StarGiftAttributePatternTypeID is TL type id of StarGiftAttributePattern.
const StarGiftAttributePatternTypeID = 0x4e7085ea

// construct implements constructor of StarGiftAttributeClass.
func ( StarGiftAttributePattern) () StarGiftAttributeClass { return & }

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

	_ StarGiftAttributeClass = &StarGiftAttributePattern{}
)

func ( *StarGiftAttributePattern) () bool {
	if  == nil {
		return true
	}
	if !(.Name == "") {
		return false
	}
	if !(.Document == nil) {
		return false
	}
	if !(.Rarity == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributePattern from given interface.
func ( *StarGiftAttributePattern) ( interface {
	() ( string)
	() ( DocumentClass)
	() ( StarGiftAttributeRarityClass)
}) {
	.Name = .()
	.Document = .()
	.Rarity = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAttributePattern) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributePattern",
		ID:   StarGiftAttributePatternTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "Document",
			SchemaName: "document",
		},
		{
			Name:       "Rarity",
			SchemaName: "rarity",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributePattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributePattern#4e7085ea as nil")
	}
	.PutID(StarGiftAttributePatternTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributePattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributePattern#4e7085ea as nil")
	}
	.PutString(.Name)
	if .Document == nil {
		return fmt.Errorf("unable to encode starGiftAttributePattern#4e7085ea: field document is nil")
	}
	if  := .Document.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributePattern#4e7085ea: field document: %w", )
	}
	if .Rarity == nil {
		return fmt.Errorf("unable to encode starGiftAttributePattern#4e7085ea: field rarity is nil")
	}
	if  := .Rarity.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributePattern#4e7085ea: field rarity: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributePattern) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributePattern#4e7085ea to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributePattern#4e7085ea: field name: %w", )
		}
		.Name = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributePattern#4e7085ea: field document: %w", )
		}
		.Document = 
	}
	{
		,  := DecodeStarGiftAttributeRarity()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributePattern#4e7085ea: field rarity: %w", )
		}
		.Rarity = 
	}
	return nil
}

// GetName returns value of Name field.
func ( *StarGiftAttributePattern) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

// GetDocument returns value of Document field.
func ( *StarGiftAttributePattern) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .Document
}

// GetRarity returns value of Rarity field.
func ( *StarGiftAttributePattern) () ( StarGiftAttributeRarityClass) {
	if  == nil {
		return
	}
	return .Rarity
}

// StarGiftAttributeBackdrop represents TL type `starGiftAttributeBackdrop#9f2504e4`.
// The backdrop of a collectible gift »¹.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/starGiftAttributeBackdrop for reference.
type StarGiftAttributeBackdrop struct {
	// Name of the backdrop
	Name string
	// Unique ID of the backdrop
	BackdropID int
	// Color of the center of the backdrop in RGB24 format.
	CenterColor int
	// Color of the edges of the backdrop in RGB24 format.
	EdgeColor int
	// Color of the starGiftAttributePattern¹ applied on the backdrop in RGB24 format.
	//
	// Links:
	//  1) https://core.telegram.org/constructor/starGiftAttributePattern
	PatternColor int
	// Color of the text on the backdrop in RGB24 format.
	TextColor int
	// Rarity of this backdrop.
	Rarity StarGiftAttributeRarityClass
}

// StarGiftAttributeBackdropTypeID is TL type id of StarGiftAttributeBackdrop.
const StarGiftAttributeBackdropTypeID = 0x9f2504e4

// construct implements constructor of StarGiftAttributeClass.
func ( StarGiftAttributeBackdrop) () StarGiftAttributeClass { return & }

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

	_ StarGiftAttributeClass = &StarGiftAttributeBackdrop{}
)

func ( *StarGiftAttributeBackdrop) () bool {
	if  == nil {
		return true
	}
	if !(.Name == "") {
		return false
	}
	if !(.BackdropID == 0) {
		return false
	}
	if !(.CenterColor == 0) {
		return false
	}
	if !(.EdgeColor == 0) {
		return false
	}
	if !(.PatternColor == 0) {
		return false
	}
	if !(.TextColor == 0) {
		return false
	}
	if !(.Rarity == nil) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributeBackdrop from given interface.
func ( *StarGiftAttributeBackdrop) ( interface {
	() ( string)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( int)
	() ( StarGiftAttributeRarityClass)
}) {
	.Name = .()
	.BackdropID = .()
	.CenterColor = .()
	.EdgeColor = .()
	.PatternColor = .()
	.TextColor = .()
	.Rarity = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeBackdrop) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeBackdrop",
		ID:   StarGiftAttributeBackdropTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Name",
			SchemaName: "name",
		},
		{
			Name:       "BackdropID",
			SchemaName: "backdrop_id",
		},
		{
			Name:       "CenterColor",
			SchemaName: "center_color",
		},
		{
			Name:       "EdgeColor",
			SchemaName: "edge_color",
		},
		{
			Name:       "PatternColor",
			SchemaName: "pattern_color",
		},
		{
			Name:       "TextColor",
			SchemaName: "text_color",
		},
		{
			Name:       "Rarity",
			SchemaName: "rarity",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeBackdrop#9f2504e4 as nil")
	}
	.PutID(StarGiftAttributeBackdropTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeBackdrop#9f2504e4 as nil")
	}
	.PutString(.Name)
	.PutInt(.BackdropID)
	.PutInt(.CenterColor)
	.PutInt(.EdgeColor)
	.PutInt(.PatternColor)
	.PutInt(.TextColor)
	if .Rarity == nil {
		return fmt.Errorf("unable to encode starGiftAttributeBackdrop#9f2504e4: field rarity is nil")
	}
	if  := .Rarity.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeBackdrop#9f2504e4: field rarity: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *StarGiftAttributeBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeBackdrop#9f2504e4 to nil")
	}
	if  := .ConsumeID(StarGiftAttributeBackdropTypeID);  != nil {
		return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeBackdrop) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeBackdrop#9f2504e4 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field name: %w", )
		}
		.Name = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field backdrop_id: %w", )
		}
		.BackdropID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field center_color: %w", )
		}
		.CenterColor = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field edge_color: %w", )
		}
		.EdgeColor = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field pattern_color: %w", )
		}
		.PatternColor = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field text_color: %w", )
		}
		.TextColor = 
	}
	{
		,  := DecodeStarGiftAttributeRarity()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeBackdrop#9f2504e4: field rarity: %w", )
		}
		.Rarity = 
	}
	return nil
}

// GetName returns value of Name field.
func ( *StarGiftAttributeBackdrop) () ( string) {
	if  == nil {
		return
	}
	return .Name
}

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

// GetCenterColor returns value of CenterColor field.
func ( *StarGiftAttributeBackdrop) () ( int) {
	if  == nil {
		return
	}
	return .CenterColor
}

// GetEdgeColor returns value of EdgeColor field.
func ( *StarGiftAttributeBackdrop) () ( int) {
	if  == nil {
		return
	}
	return .EdgeColor
}

// GetPatternColor returns value of PatternColor field.
func ( *StarGiftAttributeBackdrop) () ( int) {
	if  == nil {
		return
	}
	return .PatternColor
}

// GetTextColor returns value of TextColor field.
func ( *StarGiftAttributeBackdrop) () ( int) {
	if  == nil {
		return
	}
	return .TextColor
}

// GetRarity returns value of Rarity field.
func ( *StarGiftAttributeBackdrop) () ( StarGiftAttributeRarityClass) {
	if  == nil {
		return
	}
	return .Rarity
}

// StarGiftAttributeOriginalDetails represents TL type `starGiftAttributeOriginalDetails#e0bff26c`.
// Info about the sender, receiver and message attached to the original gift »¹, before
// it was upgraded to a collectible gift »².
//
// Links:
//  1. https://core.telegram.org/api/gifts
//  2. https://core.telegram.org/api/gifts#collectible-gifts
//
// See https://core.telegram.org/constructor/starGiftAttributeOriginalDetails for reference.
type StarGiftAttributeOriginalDetails struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Original sender of the gift, absent if the gift was private.
	//
	// Use SetSenderID and GetSenderID helpers.
	SenderID PeerClass
	// Original receiver of the gift.
	RecipientID PeerClass
	// When was the gift sent.
	Date int
	// Original message attached to the gift, if present.
	//
	// Use SetMessage and GetMessage helpers.
	Message TextWithEntities
}

// StarGiftAttributeOriginalDetailsTypeID is TL type id of StarGiftAttributeOriginalDetails.
const StarGiftAttributeOriginalDetailsTypeID = 0xe0bff26c

// construct implements constructor of StarGiftAttributeClass.
func ( StarGiftAttributeOriginalDetails) () StarGiftAttributeClass { return & }

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

	_ StarGiftAttributeClass = &StarGiftAttributeOriginalDetails{}
)

func ( *StarGiftAttributeOriginalDetails) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.SenderID == nil) {
		return false
	}
	if !(.RecipientID == nil) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.Message.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftAttributeOriginalDetails from given interface.
func ( *StarGiftAttributeOriginalDetails) ( interface {
	() ( PeerClass,  bool)
	() ( PeerClass)
	() ( int)
	() ( TextWithEntities,  bool)
}) {
	if ,  := .();  {
		.SenderID = 
	}

	.RecipientID = .()
	.Date = .()
	if ,  := .();  {
		.Message = 
	}

}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftAttributeOriginalDetails) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftAttributeOriginalDetails",
		ID:   StarGiftAttributeOriginalDetailsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "SenderID",
			SchemaName: "sender_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "RecipientID",
			SchemaName: "recipient_id",
		},
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "Message",
			SchemaName: "message",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StarGiftAttributeOriginalDetails) () {
	if !(.SenderID == nil) {
		.Flags.Set(0)
	}
	if !(.Message.Zero()) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *StarGiftAttributeOriginalDetails) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeOriginalDetails#e0bff26c as nil")
	}
	.PutID(StarGiftAttributeOriginalDetailsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftAttributeOriginalDetails) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftAttributeOriginalDetails#e0bff26c as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field flags: %w", )
	}
	if .Flags.Has(0) {
		if .SenderID == nil {
			return fmt.Errorf("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field sender_id is nil")
		}
		if  := .SenderID.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field sender_id: %w", )
		}
	}
	if .RecipientID == nil {
		return fmt.Errorf("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field recipient_id is nil")
	}
	if  := .RecipientID.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field recipient_id: %w", )
	}
	.PutInt(.Date)
	if .Flags.Has(1) {
		if  := .Message.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftAttributeOriginalDetails#e0bff26c: field message: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftAttributeOriginalDetails) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftAttributeOriginalDetails#e0bff26c to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field sender_id: %w", )
		}
		.SenderID = 
	}
	{
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field recipient_id: %w", )
		}
		.RecipientID = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field date: %w", )
		}
		.Date = 
	}
	if .Flags.Has(1) {
		if  := .Message.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftAttributeOriginalDetails#e0bff26c: field message: %w", )
		}
	}
	return nil
}

// SetSenderID sets value of SenderID conditional field.
func ( *StarGiftAttributeOriginalDetails) ( PeerClass) {
	.Flags.Set(0)
	.SenderID = 
}

// GetSenderID returns value of SenderID conditional field and
// boolean which is true if field was set.
func ( *StarGiftAttributeOriginalDetails) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .SenderID, true
}

// GetRecipientID returns value of RecipientID field.
func ( *StarGiftAttributeOriginalDetails) () ( PeerClass) {
	if  == nil {
		return
	}
	return .RecipientID
}

// GetDate returns value of Date field.
func ( *StarGiftAttributeOriginalDetails) () ( int) {
	if  == nil {
		return
	}
	return .Date
}

// SetMessage sets value of Message conditional field.
func ( *StarGiftAttributeOriginalDetails) ( TextWithEntities) {
	.Flags.Set(1)
	.Message = 
}

// GetMessage returns value of Message conditional field and
// boolean which is true if field was set.
func ( *StarGiftAttributeOriginalDetails) () ( TextWithEntities,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Message, true
}

// StarGiftAttributeClassName is schema name of StarGiftAttributeClass.
const StarGiftAttributeClassName = "StarGiftAttribute"

// StarGiftAttributeClass represents StarGiftAttribute generic type.
//
// See https://core.telegram.org/type/StarGiftAttribute for reference.
//
// Constructors:
//   - [StarGiftAttributeModel]
//   - [StarGiftAttributePattern]
//   - [StarGiftAttributeBackdrop]
//   - [StarGiftAttributeOriginalDetails]
//
// Example:
//
//	g, err := tg.DecodeStarGiftAttribute(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StarGiftAttributeModel: // starGiftAttributeModel#565251e2
//	case *tg.StarGiftAttributePattern: // starGiftAttributePattern#4e7085ea
//	case *tg.StarGiftAttributeBackdrop: // starGiftAttributeBackdrop#9f2504e4
//	case *tg.StarGiftAttributeOriginalDetails: // starGiftAttributeOriginalDetails#e0bff26c
//	default: panic(v)
//	}
type StarGiftAttributeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StarGiftAttributeClass

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

// DecodeStarGiftAttribute implements binary de-serialization for StarGiftAttributeClass.
func ( *bin.Buffer) (StarGiftAttributeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StarGiftAttributeModelTypeID:
		// Decoding starGiftAttributeModel#565251e2.
		 := StarGiftAttributeModel{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeClass: %w", )
		}
		return &, nil
	case StarGiftAttributePatternTypeID:
		// Decoding starGiftAttributePattern#4e7085ea.
		 := StarGiftAttributePattern{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeClass: %w", )
		}
		return &, nil
	case StarGiftAttributeBackdropTypeID:
		// Decoding starGiftAttributeBackdrop#9f2504e4.
		 := StarGiftAttributeBackdrop{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeClass: %w", )
		}
		return &, nil
	case StarGiftAttributeOriginalDetailsTypeID:
		// Decoding starGiftAttributeOriginalDetails#e0bff26c.
		 := StarGiftAttributeOriginalDetails{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftAttributeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StarGiftAttributeClass: %w", bin.NewUnexpectedID())
	}
}

// StarGiftAttribute boxes the StarGiftAttributeClass providing a helper.
type StarGiftAttributeBox struct {
	StarGiftAttribute StarGiftAttributeClass
}

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

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