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

// StarGift represents TL type `starGift#313a9547`.
// Represents a star gift, see here »¹ for more info.
//
// Links:
//  1. https://core.telegram.org/api/gifts
//
// See https://core.telegram.org/constructor/starGift for reference.
type StarGift struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether this is a limited-supply gift.
	Limited bool
	// Whether this gift sold out and cannot be bought anymore.
	SoldOut bool
	// Whether this is a birthday-themed gift
	Birthday bool
	// This gift can only be bought by users with a Premium¹ subscription.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	RequirePremium bool
	// If set, the maximum number of gifts of this type that can be owned by a single user is
	// limited and specified in per_user_total, and the remaining slots for the current user
	// in per_user_remains.
	LimitedPerUser bool
	// If set, collectible gifts of this type may be used to generate a message color palette
	// and pattern »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/colors#collectible-message-palettes
	PeerColorAvailable bool
	// If set, this is a collectible gift that can only be bought through a collectible gift
	// auction »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/auctions
	Auction bool
	// Identifier of the gift
	ID int64
	// Sticker¹ that represents the gift.
	//
	// Links:
	//  1) https://core.telegram.org/api/stickers
	Sticker DocumentClass
	// Price of the gift in Telegram Stars¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	Stars int64
	// For limited-supply gifts: the remaining number of gifts that may be bought.
	//
	// Use SetAvailabilityRemains and GetAvailabilityRemains helpers.
	AvailabilityRemains int
	// For limited-supply gifts: the total number of gifts that was available in the initial
	// supply.
	//
	// Use SetAvailabilityTotal and GetAvailabilityTotal helpers.
	AvailabilityTotal int
	// The total number of (upgraded to collectibles¹) gifts of this type currently on
	// resale²
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	//  2) https://core.telegram.org/api/gifts#reselling-collectible-gifts
	//
	// Use SetAvailabilityResale and GetAvailabilityResale helpers.
	AvailabilityResale int64
	// The receiver of this gift may convert it to this many Telegram Stars, instead of
	// displaying it on their profile page.convert_stars will be equal to stars only if the
	// gift was bought using recently bought Telegram Stars, otherwise it will be less than
	// stars.
	ConvertStars int64
	// For sold out gifts only: when was the gift first bought.
	//
	// Use SetFirstSaleDate and GetFirstSaleDate helpers.
	FirstSaleDate int
	// For sold out gifts only: when was the gift last bought.
	//
	// Use SetLastSaleDate and GetLastSaleDate helpers.
	LastSaleDate int
	// The number of Telegram Stars the user can pay to convert the gift into a collectible
	// gift »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gifts
	//
	// Use SetUpgradeStars and GetUpgradeStars helpers.
	UpgradeStars int64
	// The minimum price in Stars¹ for gifts of this type currently on resale².
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	//  2) https://core.telegram.org/api/gifts#reselling-collectible-gifts
	//
	// Use SetResellMinStars and GetResellMinStars helpers.
	ResellMinStars int64
	// Title of the gift
	//
	// Use SetTitle and GetTitle helpers.
	Title string
	// This gift was released by the specified peer.
	//
	// Use SetReleasedBy and GetReleasedBy helpers.
	ReleasedBy PeerClass
	// Maximum number of gifts of this type that can be owned by any user.
	//
	// Use SetPerUserTotal and GetPerUserTotal helpers.
	PerUserTotal int
	// Remaining number of gifts of this type that can be owned by the current user.
	//
	// Use SetPerUserRemains and GetPerUserRemains helpers.
	PerUserRemains int
	// If set, the specified gift possibly cannot be sent until the specified date, see here
	// »¹ for the full flow.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts
	//
	// Use SetLockedUntilDate and GetLockedUntilDate helpers.
	LockedUntilDate int
	// Always set for gifts that can be bought on auctions »¹, contains the auction deep
	// link slug »².
	//
	// Links:
	//  1) https://core.telegram.org/api/auctions
	//  2) https://core.telegram.org/api/links#auction-links
	//
	// Use SetAuctionSlug and GetAuctionSlug helpers.
	AuctionSlug string
	// Always set for gifts that can be bought on auctions »¹, contains the number of gifts
	// of this kind that are distributed on every round.
	//
	// Links:
	//  1) https://core.telegram.org/api/auctions
	//
	// Use SetGiftsPerRound and GetGiftsPerRound helpers.
	GiftsPerRound int
	// Always set for gifts that can be bought on auctions »¹, contains the UNIX timestamp
	// indicating when will the auction start (or when the auction started, if it points to
	// the past).
	//
	// Links:
	//  1) https://core.telegram.org/api/auctions
	//
	// Use SetAuctionStartDate and GetAuctionStartDate helpers.
	AuctionStartDate int
	// Total number of possible collectible variants »¹ for this gift type.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#listing-all-possible-collectible-variants
	//
	// Use SetUpgradeVariants and GetUpgradeVariants helpers.
	UpgradeVariants int
	// Default background palette for this gift type, used when rendering gift cards and
	// previews before a specific collectible backdrop is chosen.
	//
	// Use SetBackground and GetBackground helpers.
	Background StarGiftBackground
}

// StarGiftTypeID is TL type id of StarGift.
const StarGiftTypeID = 0x313a9547

// construct implements constructor of StarGiftClass.
func ( StarGift) () StarGiftClass { return & }

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

	_ StarGiftClass = &StarGift{}
)

func ( *StarGift) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Limited == false) {
		return false
	}
	if !(.SoldOut == false) {
		return false
	}
	if !(.Birthday == false) {
		return false
	}
	if !(.RequirePremium == false) {
		return false
	}
	if !(.LimitedPerUser == false) {
		return false
	}
	if !(.PeerColorAvailable == false) {
		return false
	}
	if !(.Auction == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.Sticker == nil) {
		return false
	}
	if !(.Stars == 0) {
		return false
	}
	if !(.AvailabilityRemains == 0) {
		return false
	}
	if !(.AvailabilityTotal == 0) {
		return false
	}
	if !(.AvailabilityResale == 0) {
		return false
	}
	if !(.ConvertStars == 0) {
		return false
	}
	if !(.FirstSaleDate == 0) {
		return false
	}
	if !(.LastSaleDate == 0) {
		return false
	}
	if !(.UpgradeStars == 0) {
		return false
	}
	if !(.ResellMinStars == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.ReleasedBy == nil) {
		return false
	}
	if !(.PerUserTotal == 0) {
		return false
	}
	if !(.PerUserRemains == 0) {
		return false
	}
	if !(.LockedUntilDate == 0) {
		return false
	}
	if !(.AuctionSlug == "") {
		return false
	}
	if !(.GiftsPerRound == 0) {
		return false
	}
	if !(.AuctionStartDate == 0) {
		return false
	}
	if !(.UpgradeVariants == 0) {
		return false
	}
	if !(.Background.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills StarGift from given interface.
func ( *StarGift) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64)
	() ( DocumentClass)
	() ( int64)
	() ( int,  bool)
	() ( int,  bool)
	() ( int64,  bool)
	() ( int64)
	() ( int,  bool)
	() ( int,  bool)
	() ( int64,  bool)
	() ( int64,  bool)
	() ( string,  bool)
	() ( PeerClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( string,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( int,  bool)
	() ( StarGiftBackground,  bool)
}) {
	.Limited = .()
	.SoldOut = .()
	.Birthday = .()
	.RequirePremium = .()
	.LimitedPerUser = .()
	.PeerColorAvailable = .()
	.Auction = .()
	.ID = .()
	.Sticker = .()
	.Stars = .()
	if ,  := .();  {
		.AvailabilityRemains = 
	}

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

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

	.ConvertStars = .()
	if ,  := .();  {
		.FirstSaleDate = 
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *StarGift) () tdp.Type {
	 := tdp.Type{
		Name: "starGift",
		ID:   StarGiftTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Limited",
			SchemaName: "limited",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "SoldOut",
			SchemaName: "sold_out",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Birthday",
			SchemaName: "birthday",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "RequirePremium",
			SchemaName: "require_premium",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "LimitedPerUser",
			SchemaName: "limited_per_user",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "PeerColorAvailable",
			SchemaName: "peer_color_available",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "Auction",
			SchemaName: "auction",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "Sticker",
			SchemaName: "sticker",
		},
		{
			Name:       "Stars",
			SchemaName: "stars",
		},
		{
			Name:       "AvailabilityRemains",
			SchemaName: "availability_remains",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "AvailabilityTotal",
			SchemaName: "availability_total",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "AvailabilityResale",
			SchemaName: "availability_resale",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ConvertStars",
			SchemaName: "convert_stars",
		},
		{
			Name:       "FirstSaleDate",
			SchemaName: "first_sale_date",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "LastSaleDate",
			SchemaName: "last_sale_date",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "UpgradeStars",
			SchemaName: "upgrade_stars",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ResellMinStars",
			SchemaName: "resell_min_stars",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "Title",
			SchemaName: "title",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "ReleasedBy",
			SchemaName: "released_by",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "PerUserTotal",
			SchemaName: "per_user_total",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "PerUserRemains",
			SchemaName: "per_user_remains",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "LockedUntilDate",
			SchemaName: "locked_until_date",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "AuctionSlug",
			SchemaName: "auction_slug",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "GiftsPerRound",
			SchemaName: "gifts_per_round",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "AuctionStartDate",
			SchemaName: "auction_start_date",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "UpgradeVariants",
			SchemaName: "upgrade_variants",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "Background",
			SchemaName: "background",
			Null:       !.Flags.Has(13),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StarGift) () {
	if !(.Limited == false) {
		.Flags.Set(0)
	}
	if !(.SoldOut == false) {
		.Flags.Set(1)
	}
	if !(.Birthday == false) {
		.Flags.Set(2)
	}
	if !(.RequirePremium == false) {
		.Flags.Set(7)
	}
	if !(.LimitedPerUser == false) {
		.Flags.Set(8)
	}
	if !(.PeerColorAvailable == false) {
		.Flags.Set(10)
	}
	if !(.Auction == false) {
		.Flags.Set(11)
	}
	if !(.AvailabilityRemains == 0) {
		.Flags.Set(0)
	}
	if !(.AvailabilityTotal == 0) {
		.Flags.Set(0)
	}
	if !(.AvailabilityResale == 0) {
		.Flags.Set(4)
	}
	if !(.FirstSaleDate == 0) {
		.Flags.Set(1)
	}
	if !(.LastSaleDate == 0) {
		.Flags.Set(1)
	}
	if !(.UpgradeStars == 0) {
		.Flags.Set(3)
	}
	if !(.ResellMinStars == 0) {
		.Flags.Set(4)
	}
	if !(.Title == "") {
		.Flags.Set(5)
	}
	if !(.ReleasedBy == nil) {
		.Flags.Set(6)
	}
	if !(.PerUserTotal == 0) {
		.Flags.Set(8)
	}
	if !(.PerUserRemains == 0) {
		.Flags.Set(8)
	}
	if !(.LockedUntilDate == 0) {
		.Flags.Set(9)
	}
	if !(.AuctionSlug == "") {
		.Flags.Set(11)
	}
	if !(.GiftsPerRound == 0) {
		.Flags.Set(11)
	}
	if !(.AuctionStartDate == 0) {
		.Flags.Set(11)
	}
	if !(.UpgradeVariants == 0) {
		.Flags.Set(12)
	}
	if !(.Background.Zero()) {
		.Flags.Set(13)
	}
}

// Encode implements bin.Encoder.
func ( *StarGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGift#313a9547 as nil")
	}
	.PutID(StarGiftTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGift#313a9547 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode starGift#313a9547: field flags: %w", )
	}
	.PutLong(.ID)
	if .Sticker == nil {
		return fmt.Errorf("unable to encode starGift#313a9547: field sticker is nil")
	}
	if  := .Sticker.Encode();  != nil {
		return fmt.Errorf("unable to encode starGift#313a9547: field sticker: %w", )
	}
	.PutLong(.Stars)
	if .Flags.Has(0) {
		.PutInt(.AvailabilityRemains)
	}
	if .Flags.Has(0) {
		.PutInt(.AvailabilityTotal)
	}
	if .Flags.Has(4) {
		.PutLong(.AvailabilityResale)
	}
	.PutLong(.ConvertStars)
	if .Flags.Has(1) {
		.PutInt(.FirstSaleDate)
	}
	if .Flags.Has(1) {
		.PutInt(.LastSaleDate)
	}
	if .Flags.Has(3) {
		.PutLong(.UpgradeStars)
	}
	if .Flags.Has(4) {
		.PutLong(.ResellMinStars)
	}
	if .Flags.Has(5) {
		.PutString(.Title)
	}
	if .Flags.Has(6) {
		if .ReleasedBy == nil {
			return fmt.Errorf("unable to encode starGift#313a9547: field released_by is nil")
		}
		if  := .ReleasedBy.Encode();  != nil {
			return fmt.Errorf("unable to encode starGift#313a9547: field released_by: %w", )
		}
	}
	if .Flags.Has(8) {
		.PutInt(.PerUserTotal)
	}
	if .Flags.Has(8) {
		.PutInt(.PerUserRemains)
	}
	if .Flags.Has(9) {
		.PutInt(.LockedUntilDate)
	}
	if .Flags.Has(11) {
		.PutString(.AuctionSlug)
	}
	if .Flags.Has(11) {
		.PutInt(.GiftsPerRound)
	}
	if .Flags.Has(11) {
		.PutInt(.AuctionStartDate)
	}
	if .Flags.Has(12) {
		.PutInt(.UpgradeVariants)
	}
	if .Flags.Has(13) {
		if  := .Background.Encode();  != nil {
			return fmt.Errorf("unable to encode starGift#313a9547: field background: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGift) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGift#313a9547 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field flags: %w", )
		}
	}
	.Limited = .Flags.Has(0)
	.SoldOut = .Flags.Has(1)
	.Birthday = .Flags.Has(2)
	.RequirePremium = .Flags.Has(7)
	.LimitedPerUser = .Flags.Has(8)
	.PeerColorAvailable = .Flags.Has(10)
	.Auction = .Flags.Has(11)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field id: %w", )
		}
		.ID = 
	}
	{
		,  := DecodeDocument()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field sticker: %w", )
		}
		.Sticker = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field stars: %w", )
		}
		.Stars = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field availability_remains: %w", )
		}
		.AvailabilityRemains = 
	}
	if .Flags.Has(0) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field availability_total: %w", )
		}
		.AvailabilityTotal = 
	}
	if .Flags.Has(4) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field availability_resale: %w", )
		}
		.AvailabilityResale = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field convert_stars: %w", )
		}
		.ConvertStars = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field first_sale_date: %w", )
		}
		.FirstSaleDate = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field last_sale_date: %w", )
		}
		.LastSaleDate = 
	}
	if .Flags.Has(3) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field upgrade_stars: %w", )
		}
		.UpgradeStars = 
	}
	if .Flags.Has(4) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field resell_min_stars: %w", )
		}
		.ResellMinStars = 
	}
	if .Flags.Has(5) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field title: %w", )
		}
		.Title = 
	}
	if .Flags.Has(6) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field released_by: %w", )
		}
		.ReleasedBy = 
	}
	if .Flags.Has(8) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field per_user_total: %w", )
		}
		.PerUserTotal = 
	}
	if .Flags.Has(8) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field per_user_remains: %w", )
		}
		.PerUserRemains = 
	}
	if .Flags.Has(9) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field locked_until_date: %w", )
		}
		.LockedUntilDate = 
	}
	if .Flags.Has(11) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field auction_slug: %w", )
		}
		.AuctionSlug = 
	}
	if .Flags.Has(11) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field gifts_per_round: %w", )
		}
		.GiftsPerRound = 
	}
	if .Flags.Has(11) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field auction_start_date: %w", )
		}
		.AuctionStartDate = 
	}
	if .Flags.Has(12) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field upgrade_variants: %w", )
		}
		.UpgradeVariants = 
	}
	if .Flags.Has(13) {
		if  := .Background.Decode();  != nil {
			return fmt.Errorf("unable to decode starGift#313a9547: field background: %w", )
		}
	}
	return nil
}

// SetLimited sets value of Limited conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(0)
		.Limited = true
	} else {
		.Flags.Unset(0)
		.Limited = false
	}
}

// GetLimited returns value of Limited conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetSoldOut sets value of SoldOut conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(1)
		.SoldOut = true
	} else {
		.Flags.Unset(1)
		.SoldOut = false
	}
}

// GetSoldOut returns value of SoldOut conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// SetBirthday sets value of Birthday conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(2)
		.Birthday = true
	} else {
		.Flags.Unset(2)
		.Birthday = false
	}
}

// GetBirthday returns value of Birthday conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(2)
}

// SetRequirePremium sets value of RequirePremium conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(7)
		.RequirePremium = true
	} else {
		.Flags.Unset(7)
		.RequirePremium = false
	}
}

// GetRequirePremium returns value of RequirePremium conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetLimitedPerUser sets value of LimitedPerUser conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(8)
		.LimitedPerUser = true
	} else {
		.Flags.Unset(8)
		.LimitedPerUser = false
	}
}

// GetLimitedPerUser returns value of LimitedPerUser conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(8)
}

// SetPeerColorAvailable sets value of PeerColorAvailable conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(10)
		.PeerColorAvailable = true
	} else {
		.Flags.Unset(10)
		.PeerColorAvailable = false
	}
}

// GetPeerColorAvailable returns value of PeerColorAvailable conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(10)
}

// SetAuction sets value of Auction conditional field.
func ( *StarGift) ( bool) {
	if  {
		.Flags.Set(11)
		.Auction = true
	} else {
		.Flags.Unset(11)
		.Auction = false
	}
}

// GetAuction returns value of Auction conditional field.
func ( *StarGift) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(11)
}

// GetID returns value of ID field.
func ( *StarGift) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetSticker returns value of Sticker field.
func ( *StarGift) () ( DocumentClass) {
	if  == nil {
		return
	}
	return .Sticker
}

// GetStars returns value of Stars field.
func ( *StarGift) () ( int64) {
	if  == nil {
		return
	}
	return .Stars
}

// SetAvailabilityRemains sets value of AvailabilityRemains conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(0)
	.AvailabilityRemains = 
}

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

// SetAvailabilityTotal sets value of AvailabilityTotal conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(0)
	.AvailabilityTotal = 
}

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

// SetAvailabilityResale sets value of AvailabilityResale conditional field.
func ( *StarGift) ( int64) {
	.Flags.Set(4)
	.AvailabilityResale = 
}

// GetAvailabilityResale returns value of AvailabilityResale conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .AvailabilityResale, true
}

// GetConvertStars returns value of ConvertStars field.
func ( *StarGift) () ( int64) {
	if  == nil {
		return
	}
	return .ConvertStars
}

// SetFirstSaleDate sets value of FirstSaleDate conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(1)
	.FirstSaleDate = 
}

// GetFirstSaleDate returns value of FirstSaleDate conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .FirstSaleDate, true
}

// SetLastSaleDate sets value of LastSaleDate conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(1)
	.LastSaleDate = 
}

// GetLastSaleDate returns value of LastSaleDate conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .LastSaleDate, true
}

// SetUpgradeStars sets value of UpgradeStars conditional field.
func ( *StarGift) ( int64) {
	.Flags.Set(3)
	.UpgradeStars = 
}

// GetUpgradeStars returns value of UpgradeStars conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .UpgradeStars, true
}

// SetResellMinStars sets value of ResellMinStars conditional field.
func ( *StarGift) ( int64) {
	.Flags.Set(4)
	.ResellMinStars = 
}

// GetResellMinStars returns value of ResellMinStars conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .ResellMinStars, true
}

// SetTitle sets value of Title conditional field.
func ( *StarGift) ( string) {
	.Flags.Set(5)
	.Title = 
}

// GetTitle returns value of Title conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .Title, true
}

// SetReleasedBy sets value of ReleasedBy conditional field.
func ( *StarGift) ( PeerClass) {
	.Flags.Set(6)
	.ReleasedBy = 
}

// GetReleasedBy returns value of ReleasedBy conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .ReleasedBy, true
}

// SetPerUserTotal sets value of PerUserTotal conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(8)
	.PerUserTotal = 
}

// GetPerUserTotal returns value of PerUserTotal conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .PerUserTotal, true
}

// SetPerUserRemains sets value of PerUserRemains conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(8)
	.PerUserRemains = 
}

// GetPerUserRemains returns value of PerUserRemains conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .PerUserRemains, true
}

// SetLockedUntilDate sets value of LockedUntilDate conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(9)
	.LockedUntilDate = 
}

// GetLockedUntilDate returns value of LockedUntilDate conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(9) {
		return , false
	}
	return .LockedUntilDate, true
}

// SetAuctionSlug sets value of AuctionSlug conditional field.
func ( *StarGift) ( string) {
	.Flags.Set(11)
	.AuctionSlug = 
}

// GetAuctionSlug returns value of AuctionSlug conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(11) {
		return , false
	}
	return .AuctionSlug, true
}

// SetGiftsPerRound sets value of GiftsPerRound conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(11)
	.GiftsPerRound = 
}

// GetGiftsPerRound returns value of GiftsPerRound conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(11) {
		return , false
	}
	return .GiftsPerRound, true
}

// SetAuctionStartDate sets value of AuctionStartDate conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(11)
	.AuctionStartDate = 
}

// GetAuctionStartDate returns value of AuctionStartDate conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(11) {
		return , false
	}
	return .AuctionStartDate, true
}

// SetUpgradeVariants sets value of UpgradeVariants conditional field.
func ( *StarGift) ( int) {
	.Flags.Set(12)
	.UpgradeVariants = 
}

// GetUpgradeVariants returns value of UpgradeVariants conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(12) {
		return , false
	}
	return .UpgradeVariants, true
}

// SetBackground sets value of Background conditional field.
func ( *StarGift) ( StarGiftBackground) {
	.Flags.Set(13)
	.Background = 
}

// GetBackground returns value of Background conditional field and
// boolean which is true if field was set.
func ( *StarGift) () ( StarGiftBackground,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(13) {
		return , false
	}
	return .Background, true
}

// StarGiftUnique represents TL type `starGiftUnique#85f0a9cd`.
// Represents a collectible star gift, see here »¹ for more info.
// The sticker that represents the gift is contained in a starGiftAttributeModel¹ object
// in attributes.
//
// Links:
//  1. https://core.telegram.org/api/gifts#collectible-gifts
//  2. https://core.telegram.org/constructor/starGiftAttributeModel
//
// See https://core.telegram.org/constructor/starGiftUnique for reference.
type StarGiftUnique struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// This gift can only be bought by users with a Premium¹ subscription.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	RequirePremium bool
	// Whether the gift can be bought only using Toncoins.
	ResaleTonOnly bool
	// A chat theme associated to this gift is available, see here »¹ for more info on how
	// to use it.
	//
	// Links:
	//  1) https://core.telegram.org/api/themes#chat-themes
	ThemeAvailable bool
	// This gift was already used as an ingredient for crafting another collectible gift »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#crafting-collectible-gifts
	Burned bool
	// This collectible gift was obtained by crafting »¹, not by upgrading a regular gift.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#crafting-collectible-gifts
	Crafted bool
	// Unique identifier of this collectible gift.
	ID int64
	// ID of the regular gift from which this gift was upgraded (all collectible gifts
	// upgraded from the same gift will have the same gift_id, with different attributes).
	GiftID int64
	// Collectible title.
	Title string
	// Slug that can be used to create a collectible gift deep link »¹, or elsewhere in the
	// API where a collectible slug is accepted².
	//
	// Links:
	//  1) https://core.telegram.org/api/links#collectible-gift-link
	//  2) https://core.telegram.org/api/gifts
	Slug string
	// Unique identifier of this collectible gift among all (already upgraded) collectible
	// gifts of the same type.
	Num int
	// The owner of the gift.
	//
	// Use SetOwnerID and GetOwnerID helpers.
	OwnerID PeerClass
	// The name of the owner if neither owner_id nor owner_address are set.
	//
	// Use SetOwnerName and GetOwnerName helpers.
	OwnerName string
	// For NFTs on the TON blockchain¹, contains the address of the owner (append it to the
	// ton_blockchain_explorer_url client configuration value »² to obtain a link with
	// information about the address).
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#withdraw-a-collectible-gift-to-the-ton-blockchain
	//  2) https://core.telegram.org/api/config#ton-blockchain-explorer-url
	//
	// Use SetOwnerAddress and GetOwnerAddress helpers.
	OwnerAddress string
	// Collectible attributes
	Attributes []StarGiftAttributeClass
	// Total number of gifts of the same type that were upgraded to a collectible gift.
	AvailabilityIssued int
	// Total number of gifts of the same type that can be upgraded or were already upgraded
	// to a collectible gift.
	AvailabilityTotal int
	// For NFTs on the TON blockchain¹, contains the address of the NFT (append it to the
	// ton_blockchain_explorer_url client configuration value »² to obtain a link with
	// information about the address).
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#withdraw-a-collectible-gift-to-the-ton-blockchain
	//  2) https://core.telegram.org/api/config#ton-blockchain-explorer-url
	//
	// Use SetGiftAddress and GetGiftAddress helpers.
	GiftAddress string
	// Resale price of the gift.
	//
	// Use SetResellAmount and GetResellAmount helpers.
	ResellAmount []StarsAmountClass
	// This gift was released by the specified peer.
	//
	// Use SetReleasedBy and GetReleasedBy helpers.
	ReleasedBy PeerClass
	// Estimated price of the gift.
	//
	// Use SetValueAmount and GetValueAmount helpers.
	ValueAmount int64
	// Currency for the gift's estimated price.
	//
	// Use SetValueCurrency and GetValueCurrency helpers.
	ValueCurrency string
	// Estimated price of the gift in USD cents.
	//
	// Use SetValueUsdAmount and GetValueUsdAmount helpers.
	ValueUsdAmount int64
	// The current chat where the associated chat theme¹ is installed, if any (gift-based
	// themes can only be installed in one chat at a time).
	//
	// Links:
	//  1) https://core.telegram.org/api/themes#chat-themes
	//
	// Use SetThemePeer and GetThemePeer helpers.
	ThemePeer PeerClass
	// Can contain a collectible message palette »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/colors#collectible-message-palettes
	//
	// Use SetPeerColor and GetPeerColor helpers.
	PeerColor PeerColorClass
	// If set, the gift is currently hosted on the specified user or channel profile even
	// though ownership belongs to a TON wallet. The owner may transfer, resell or export the
	// gift, while the host or owner may show it on the profile, use it as a theme/status and
	// add it to a collection.
	//
	// Use SetHostID and GetHostID helpers.
	HostID PeerClass
	// If set, you can send a purchase offer for this gift »¹: the minimum offer price is
	// specified in this flag.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#collectible-gift-purchase-offers
	//
	// Use SetOfferMinStars and GetOfferMinStars helpers.
	OfferMinStars int
	// Success probability, per 1000, contributed by this gift when it is used for crafting
	// »¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/gifts#crafting-collectible-gifts
	//
	// Use SetCraftChancePermille and GetCraftChancePermille helpers.
	CraftChancePermille int
}

// StarGiftUniqueTypeID is TL type id of StarGiftUnique.
const StarGiftUniqueTypeID = 0x85f0a9cd

// construct implements constructor of StarGiftClass.
func ( StarGiftUnique) () StarGiftClass { return & }

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

	_ StarGiftClass = &StarGiftUnique{}
)

func ( *StarGiftUnique) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.RequirePremium == false) {
		return false
	}
	if !(.ResaleTonOnly == false) {
		return false
	}
	if !(.ThemeAvailable == false) {
		return false
	}
	if !(.Burned == false) {
		return false
	}
	if !(.Crafted == false) {
		return false
	}
	if !(.ID == 0) {
		return false
	}
	if !(.GiftID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Slug == "") {
		return false
	}
	if !(.Num == 0) {
		return false
	}
	if !(.OwnerID == nil) {
		return false
	}
	if !(.OwnerName == "") {
		return false
	}
	if !(.OwnerAddress == "") {
		return false
	}
	if !(.Attributes == nil) {
		return false
	}
	if !(.AvailabilityIssued == 0) {
		return false
	}
	if !(.AvailabilityTotal == 0) {
		return false
	}
	if !(.GiftAddress == "") {
		return false
	}
	if !(.ResellAmount == nil) {
		return false
	}
	if !(.ReleasedBy == nil) {
		return false
	}
	if !(.ValueAmount == 0) {
		return false
	}
	if !(.ValueCurrency == "") {
		return false
	}
	if !(.ValueUsdAmount == 0) {
		return false
	}
	if !(.ThemePeer == nil) {
		return false
	}
	if !(.PeerColor == nil) {
		return false
	}
	if !(.HostID == nil) {
		return false
	}
	if !(.OfferMinStars == 0) {
		return false
	}
	if !(.CraftChancePermille == 0) {
		return false
	}

	return true
}

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

// FillFrom fills StarGiftUnique from given interface.
func ( *StarGiftUnique) ( interface {
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( bool)
	() ( int64)
	() ( int64)
	() ( string)
	() ( string)
	() ( int)
	() ( PeerClass,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( []StarGiftAttributeClass)
	() ( int)
	() ( int)
	() ( string,  bool)
	() ( []StarsAmountClass,  bool)
	() ( PeerClass,  bool)
	() ( int64,  bool)
	() ( string,  bool)
	() ( int64,  bool)
	() ( PeerClass,  bool)
	() ( PeerColorClass,  bool)
	() ( PeerClass,  bool)
	() ( int,  bool)
	() ( int,  bool)
}) {
	.RequirePremium = .()
	.ResaleTonOnly = .()
	.ThemeAvailable = .()
	.Burned = .()
	.Crafted = .()
	.ID = .()
	.GiftID = .()
	.Title = .()
	.Slug = .()
	.Num = .()
	if ,  := .();  {
		.OwnerID = 
	}

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

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

	.Attributes = .()
	.AvailabilityIssued = .()
	.AvailabilityTotal = .()
	if ,  := .();  {
		.GiftAddress = 
	}

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

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

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

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

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

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

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

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *StarGiftUnique) () tdp.Type {
	 := tdp.Type{
		Name: "starGiftUnique",
		ID:   StarGiftUniqueTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "RequirePremium",
			SchemaName: "require_premium",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "ResaleTonOnly",
			SchemaName: "resale_ton_only",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "ThemeAvailable",
			SchemaName: "theme_available",
			Null:       !.Flags.Has(9),
		},
		{
			Name:       "Burned",
			SchemaName: "burned",
			Null:       !.Flags.Has(14),
		},
		{
			Name:       "Crafted",
			SchemaName: "crafted",
			Null:       !.Flags.Has(15),
		},
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "GiftID",
			SchemaName: "gift_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Slug",
			SchemaName: "slug",
		},
		{
			Name:       "Num",
			SchemaName: "num",
		},
		{
			Name:       "OwnerID",
			SchemaName: "owner_id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "OwnerName",
			SchemaName: "owner_name",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "OwnerAddress",
			SchemaName: "owner_address",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Attributes",
			SchemaName: "attributes",
		},
		{
			Name:       "AvailabilityIssued",
			SchemaName: "availability_issued",
		},
		{
			Name:       "AvailabilityTotal",
			SchemaName: "availability_total",
		},
		{
			Name:       "GiftAddress",
			SchemaName: "gift_address",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ResellAmount",
			SchemaName: "resell_amount",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ReleasedBy",
			SchemaName: "released_by",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "ValueAmount",
			SchemaName: "value_amount",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ValueCurrency",
			SchemaName: "value_currency",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ValueUsdAmount",
			SchemaName: "value_usd_amount",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "ThemePeer",
			SchemaName: "theme_peer",
			Null:       !.Flags.Has(10),
		},
		{
			Name:       "PeerColor",
			SchemaName: "peer_color",
			Null:       !.Flags.Has(11),
		},
		{
			Name:       "HostID",
			SchemaName: "host_id",
			Null:       !.Flags.Has(12),
		},
		{
			Name:       "OfferMinStars",
			SchemaName: "offer_min_stars",
			Null:       !.Flags.Has(13),
		},
		{
			Name:       "CraftChancePermille",
			SchemaName: "craft_chance_permille",
			Null:       !.Flags.Has(16),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *StarGiftUnique) () {
	if !(.RequirePremium == false) {
		.Flags.Set(6)
	}
	if !(.ResaleTonOnly == false) {
		.Flags.Set(7)
	}
	if !(.ThemeAvailable == false) {
		.Flags.Set(9)
	}
	if !(.Burned == false) {
		.Flags.Set(14)
	}
	if !(.Crafted == false) {
		.Flags.Set(15)
	}
	if !(.OwnerID == nil) {
		.Flags.Set(0)
	}
	if !(.OwnerName == "") {
		.Flags.Set(1)
	}
	if !(.OwnerAddress == "") {
		.Flags.Set(2)
	}
	if !(.GiftAddress == "") {
		.Flags.Set(3)
	}
	if !(.ResellAmount == nil) {
		.Flags.Set(4)
	}
	if !(.ReleasedBy == nil) {
		.Flags.Set(5)
	}
	if !(.ValueAmount == 0) {
		.Flags.Set(8)
	}
	if !(.ValueCurrency == "") {
		.Flags.Set(8)
	}
	if !(.ValueUsdAmount == 0) {
		.Flags.Set(8)
	}
	if !(.ThemePeer == nil) {
		.Flags.Set(10)
	}
	if !(.PeerColor == nil) {
		.Flags.Set(11)
	}
	if !(.HostID == nil) {
		.Flags.Set(12)
	}
	if !(.OfferMinStars == 0) {
		.Flags.Set(13)
	}
	if !(.CraftChancePermille == 0) {
		.Flags.Set(16)
	}
}

// Encode implements bin.Encoder.
func ( *StarGiftUnique) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftUnique#85f0a9cd as nil")
	}
	.PutID(StarGiftUniqueTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *StarGiftUnique) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode starGiftUnique#85f0a9cd as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field flags: %w", )
	}
	.PutLong(.ID)
	.PutLong(.GiftID)
	.PutString(.Title)
	.PutString(.Slug)
	.PutInt(.Num)
	if .Flags.Has(0) {
		if .OwnerID == nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field owner_id is nil")
		}
		if  := .OwnerID.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field owner_id: %w", )
		}
	}
	if .Flags.Has(1) {
		.PutString(.OwnerName)
	}
	if .Flags.Has(2) {
		.PutString(.OwnerAddress)
	}
	.PutVectorHeader(len(.Attributes))
	for ,  := range .Attributes {
		if  == nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field attributes element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field attributes element with index %d: %w", , )
		}
	}
	.PutInt(.AvailabilityIssued)
	.PutInt(.AvailabilityTotal)
	if .Flags.Has(3) {
		.PutString(.GiftAddress)
	}
	if .Flags.Has(4) {
		.PutVectorHeader(len(.ResellAmount))
		for ,  := range .ResellAmount {
			if  == nil {
				return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field resell_amount element with index %d is nil", )
			}
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field resell_amount element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(5) {
		if .ReleasedBy == nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field released_by is nil")
		}
		if  := .ReleasedBy.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field released_by: %w", )
		}
	}
	if .Flags.Has(8) {
		.PutLong(.ValueAmount)
	}
	if .Flags.Has(8) {
		.PutString(.ValueCurrency)
	}
	if .Flags.Has(8) {
		.PutLong(.ValueUsdAmount)
	}
	if .Flags.Has(10) {
		if .ThemePeer == nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field theme_peer is nil")
		}
		if  := .ThemePeer.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field theme_peer: %w", )
		}
	}
	if .Flags.Has(11) {
		if .PeerColor == nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field peer_color is nil")
		}
		if  := .PeerColor.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field peer_color: %w", )
		}
	}
	if .Flags.Has(12) {
		if .HostID == nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field host_id is nil")
		}
		if  := .HostID.Encode();  != nil {
			return fmt.Errorf("unable to encode starGiftUnique#85f0a9cd: field host_id: %w", )
		}
	}
	if .Flags.Has(13) {
		.PutInt(.OfferMinStars)
	}
	if .Flags.Has(16) {
		.PutInt(.CraftChancePermille)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *StarGiftUnique) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode starGiftUnique#85f0a9cd to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field flags: %w", )
		}
	}
	.RequirePremium = .Flags.Has(6)
	.ResaleTonOnly = .Flags.Has(7)
	.ThemeAvailable = .Flags.Has(9)
	.Burned = .Flags.Has(14)
	.Crafted = .Flags.Has(15)
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field gift_id: %w", )
		}
		.GiftID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field slug: %w", )
		}
		.Slug = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field num: %w", )
		}
		.Num = 
	}
	if .Flags.Has(0) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field owner_id: %w", )
		}
		.OwnerID = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field owner_name: %w", )
		}
		.OwnerName = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field owner_address: %w", )
		}
		.OwnerAddress = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field attributes: %w", )
		}

		if  > 0 {
			.Attributes = make([]StarGiftAttributeClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStarGiftAttribute()
			if  != nil {
				return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field attributes: %w", )
			}
			.Attributes = append(.Attributes, )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field availability_issued: %w", )
		}
		.AvailabilityIssued = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field availability_total: %w", )
		}
		.AvailabilityTotal = 
	}
	if .Flags.Has(3) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field gift_address: %w", )
		}
		.GiftAddress = 
	}
	if .Flags.Has(4) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field resell_amount: %w", )
		}

		if  > 0 {
			.ResellAmount = make([]StarsAmountClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeStarsAmount()
			if  != nil {
				return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field resell_amount: %w", )
			}
			.ResellAmount = append(.ResellAmount, )
		}
	}
	if .Flags.Has(5) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field released_by: %w", )
		}
		.ReleasedBy = 
	}
	if .Flags.Has(8) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field value_amount: %w", )
		}
		.ValueAmount = 
	}
	if .Flags.Has(8) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field value_currency: %w", )
		}
		.ValueCurrency = 
	}
	if .Flags.Has(8) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field value_usd_amount: %w", )
		}
		.ValueUsdAmount = 
	}
	if .Flags.Has(10) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field theme_peer: %w", )
		}
		.ThemePeer = 
	}
	if .Flags.Has(11) {
		,  := DecodePeerColor()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field peer_color: %w", )
		}
		.PeerColor = 
	}
	if .Flags.Has(12) {
		,  := DecodePeer()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field host_id: %w", )
		}
		.HostID = 
	}
	if .Flags.Has(13) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field offer_min_stars: %w", )
		}
		.OfferMinStars = 
	}
	if .Flags.Has(16) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode starGiftUnique#85f0a9cd: field craft_chance_permille: %w", )
		}
		.CraftChancePermille = 
	}
	return nil
}

// SetRequirePremium sets value of RequirePremium conditional field.
func ( *StarGiftUnique) ( bool) {
	if  {
		.Flags.Set(6)
		.RequirePremium = true
	} else {
		.Flags.Unset(6)
		.RequirePremium = false
	}
}

// GetRequirePremium returns value of RequirePremium conditional field.
func ( *StarGiftUnique) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(6)
}

// SetResaleTonOnly sets value of ResaleTonOnly conditional field.
func ( *StarGiftUnique) ( bool) {
	if  {
		.Flags.Set(7)
		.ResaleTonOnly = true
	} else {
		.Flags.Unset(7)
		.ResaleTonOnly = false
	}
}

// GetResaleTonOnly returns value of ResaleTonOnly conditional field.
func ( *StarGiftUnique) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(7)
}

// SetThemeAvailable sets value of ThemeAvailable conditional field.
func ( *StarGiftUnique) ( bool) {
	if  {
		.Flags.Set(9)
		.ThemeAvailable = true
	} else {
		.Flags.Unset(9)
		.ThemeAvailable = false
	}
}

// GetThemeAvailable returns value of ThemeAvailable conditional field.
func ( *StarGiftUnique) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(9)
}

// SetBurned sets value of Burned conditional field.
func ( *StarGiftUnique) ( bool) {
	if  {
		.Flags.Set(14)
		.Burned = true
	} else {
		.Flags.Unset(14)
		.Burned = false
	}
}

// GetBurned returns value of Burned conditional field.
func ( *StarGiftUnique) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(14)
}

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

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

// GetID returns value of ID field.
func ( *StarGiftUnique) () ( int64) {
	if  == nil {
		return
	}
	return .ID
}

// GetGiftID returns value of GiftID field.
func ( *StarGiftUnique) () ( int64) {
	if  == nil {
		return
	}
	return .GiftID
}

// GetTitle returns value of Title field.
func ( *StarGiftUnique) () ( string) {
	if  == nil {
		return
	}
	return .Title
}

// GetSlug returns value of Slug field.
func ( *StarGiftUnique) () ( string) {
	if  == nil {
		return
	}
	return .Slug
}

// GetNum returns value of Num field.
func ( *StarGiftUnique) () ( int) {
	if  == nil {
		return
	}
	return .Num
}

// SetOwnerID sets value of OwnerID conditional field.
func ( *StarGiftUnique) ( PeerClass) {
	.Flags.Set(0)
	.OwnerID = 
}

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

// SetOwnerName sets value of OwnerName conditional field.
func ( *StarGiftUnique) ( string) {
	.Flags.Set(1)
	.OwnerName = 
}

// GetOwnerName returns value of OwnerName conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .OwnerName, true
}

// SetOwnerAddress sets value of OwnerAddress conditional field.
func ( *StarGiftUnique) ( string) {
	.Flags.Set(2)
	.OwnerAddress = 
}

// GetOwnerAddress returns value of OwnerAddress conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .OwnerAddress, true
}

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

// GetAvailabilityIssued returns value of AvailabilityIssued field.
func ( *StarGiftUnique) () ( int) {
	if  == nil {
		return
	}
	return .AvailabilityIssued
}

// GetAvailabilityTotal returns value of AvailabilityTotal field.
func ( *StarGiftUnique) () ( int) {
	if  == nil {
		return
	}
	return .AvailabilityTotal
}

// SetGiftAddress sets value of GiftAddress conditional field.
func ( *StarGiftUnique) ( string) {
	.Flags.Set(3)
	.GiftAddress = 
}

// GetGiftAddress returns value of GiftAddress conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .GiftAddress, true
}

// SetResellAmount sets value of ResellAmount conditional field.
func ( *StarGiftUnique) ( []StarsAmountClass) {
	.Flags.Set(4)
	.ResellAmount = 
}

// GetResellAmount returns value of ResellAmount conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( []StarsAmountClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .ResellAmount, true
}

// SetReleasedBy sets value of ReleasedBy conditional field.
func ( *StarGiftUnique) ( PeerClass) {
	.Flags.Set(5)
	.ReleasedBy = 
}

// GetReleasedBy returns value of ReleasedBy conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .ReleasedBy, true
}

// SetValueAmount sets value of ValueAmount conditional field.
func ( *StarGiftUnique) ( int64) {
	.Flags.Set(8)
	.ValueAmount = 
}

// GetValueAmount returns value of ValueAmount conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .ValueAmount, true
}

// SetValueCurrency sets value of ValueCurrency conditional field.
func ( *StarGiftUnique) ( string) {
	.Flags.Set(8)
	.ValueCurrency = 
}

// GetValueCurrency returns value of ValueCurrency conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .ValueCurrency, true
}

// SetValueUsdAmount sets value of ValueUsdAmount conditional field.
func ( *StarGiftUnique) ( int64) {
	.Flags.Set(8)
	.ValueUsdAmount = 
}

// GetValueUsdAmount returns value of ValueUsdAmount conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( int64,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .ValueUsdAmount, true
}

// SetThemePeer sets value of ThemePeer conditional field.
func ( *StarGiftUnique) ( PeerClass) {
	.Flags.Set(10)
	.ThemePeer = 
}

// GetThemePeer returns value of ThemePeer conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(10) {
		return , false
	}
	return .ThemePeer, true
}

// SetPeerColor sets value of PeerColor conditional field.
func ( *StarGiftUnique) ( PeerColorClass) {
	.Flags.Set(11)
	.PeerColor = 
}

// GetPeerColor returns value of PeerColor conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( PeerColorClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(11) {
		return , false
	}
	return .PeerColor, true
}

// SetHostID sets value of HostID conditional field.
func ( *StarGiftUnique) ( PeerClass) {
	.Flags.Set(12)
	.HostID = 
}

// GetHostID returns value of HostID conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( PeerClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(12) {
		return , false
	}
	return .HostID, true
}

// SetOfferMinStars sets value of OfferMinStars conditional field.
func ( *StarGiftUnique) ( int) {
	.Flags.Set(13)
	.OfferMinStars = 
}

// GetOfferMinStars returns value of OfferMinStars conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(13) {
		return , false
	}
	return .OfferMinStars, true
}

// SetCraftChancePermille sets value of CraftChancePermille conditional field.
func ( *StarGiftUnique) ( int) {
	.Flags.Set(16)
	.CraftChancePermille = 
}

// GetCraftChancePermille returns value of CraftChancePermille conditional field and
// boolean which is true if field was set.
func ( *StarGiftUnique) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(16) {
		return , false
	}
	return .CraftChancePermille, true
}

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

// MapResellAmount returns field ResellAmount wrapped in StarsAmountClassArray helper.
func ( *StarGiftUnique) () ( StarsAmountClassArray,  bool) {
	if !.Flags.Has(4) {
		return , false
	}
	return StarsAmountClassArray(.ResellAmount), true
}

// StarGiftClassName is schema name of StarGiftClass.
const StarGiftClassName = "StarGift"

// StarGiftClass represents StarGift generic type.
//
// See https://core.telegram.org/type/StarGift for reference.
//
// Constructors:
//   - [StarGift]
//   - [StarGiftUnique]
//
// Example:
//
//	g, err := tg.DecodeStarGift(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.StarGift: // starGift#313a9547
//	case *tg.StarGiftUnique: // starGiftUnique#85f0a9cd
//	default: panic(v)
//	}
type StarGiftClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() StarGiftClass

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

	// This gift can only be bought by users with a Premium¹ subscription.
	//
	// Links:
	//  1) https://core.telegram.org/api/premium
	GetRequirePremium() (value bool)

	// Identifier of the gift
	GetID() (value int64)

	// This gift was released by the specified peer.
	GetReleasedBy() (value PeerClass, ok bool)
}

// AsInputStarGiftAuction tries to map StarGift to InputStarGiftAuction.
func ( *StarGift) () *InputStarGiftAuction {
	 := new(InputStarGiftAuction)
	.GiftID = .GetID()

	return 
}

// DecodeStarGift implements binary de-serialization for StarGiftClass.
func ( *bin.Buffer) (StarGiftClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case StarGiftTypeID:
		// Decoding starGift#313a9547.
		 := StarGift{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftClass: %w", )
		}
		return &, nil
	case StarGiftUniqueTypeID:
		// Decoding starGiftUnique#85f0a9cd.
		 := StarGiftUnique{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode StarGiftClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode StarGiftClass: %w", bin.NewUnexpectedID())
	}
}

// StarGift boxes the StarGiftClass providing a helper.
type StarGiftBox struct {
	StarGift StarGiftClass
}

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

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