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

// WalletNftItem represents TL type `wallet.nftItem#173dfaf3`.
//
// See https://core.telegram.org/constructor/wallet.nftItem for reference.
type WalletNftItem struct {
	// Flags field of WalletNftItem.
	Flags bin.Fields
	// CollectionAddress field of WalletNftItem.
	//
	// Use SetCollectionAddress and GetCollectionAddress helpers.
	CollectionAddress string
	// Address field of WalletNftItem.
	Address string
	// OwnerAddress field of WalletNftItem.
	OwnerAddress string
	// Index field of WalletNftItem.
	Index string
	// Name field of WalletNftItem.
	//
	// Use SetName and GetName helpers.
	Name string
	// Description field of WalletNftItem.
	//
	// Use SetDescription and GetDescription helpers.
	Description string
	// Image field of WalletNftItem.
	//
	// Use SetImage and GetImage helpers.
	Image WebDocumentClass
	// ImageSmall field of WalletNftItem.
	//
	// Use SetImageSmall and GetImageSmall helpers.
	ImageSmall WebDocumentClass
	// ContentURL field of WalletNftItem.
	//
	// Use SetContentURL and GetContentURL helpers.
	ContentURL WebDocumentClass
	// Lottie field of WalletNftItem.
	//
	// Use SetLottie and GetLottie helpers.
	Lottie WebDocumentClass
	// Attributes field of WalletNftItem.
	//
	// Use SetAttributes and GetAttributes helpers.
	Attributes []WalletNftAttribute
	// Extra field of WalletNftItem.
	//
	// Use SetExtra and GetExtra helpers.
	Extra DataJSON
	// Gift field of WalletNftItem.
	//
	// Use SetGift and GetGift helpers.
	Gift StarGiftClass
}

// WalletNftItemTypeID is TL type id of WalletNftItem.
const WalletNftItemTypeID = 0x173dfaf3

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

func ( *WalletNftItem) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.CollectionAddress == "") {
		return false
	}
	if !(.Address == "") {
		return false
	}
	if !(.OwnerAddress == "") {
		return false
	}
	if !(.Index == "") {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Image == nil) {
		return false
	}
	if !(.ImageSmall == nil) {
		return false
	}
	if !(.ContentURL == nil) {
		return false
	}
	if !(.Lottie == nil) {
		return false
	}
	if !(.Attributes == nil) {
		return false
	}
	if !(.Extra.Zero()) {
		return false
	}
	if !(.Gift == nil) {
		return false
	}

	return true
}

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

// FillFrom fills WalletNftItem from given interface.
func ( *WalletNftItem) ( interface {
	() ( string,  bool)
	() ( string)
	() ( string)
	() ( string)
	() ( string,  bool)
	() ( string,  bool)
	() ( WebDocumentClass,  bool)
	() ( WebDocumentClass,  bool)
	() ( WebDocumentClass,  bool)
	() ( WebDocumentClass,  bool)
	() ( []WalletNftAttribute,  bool)
	() ( DataJSON,  bool)
	() ( StarGiftClass,  bool)
}) {
	if ,  := .();  {
		.CollectionAddress = 
	}

	.Address = .()
	.OwnerAddress = .()
	.Index = .()
	if ,  := .();  {
		.Name = 
	}

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

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

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

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

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

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

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

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

}

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

// TypeName returns name of type in TL schema.
func (*WalletNftItem) () string {
	return "wallet.nftItem"
}

// TypeInfo returns info about TL type.
func ( *WalletNftItem) () tdp.Type {
	 := tdp.Type{
		Name: "wallet.nftItem",
		ID:   WalletNftItemTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "CollectionAddress",
			SchemaName: "collection_address",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Address",
			SchemaName: "address",
		},
		{
			Name:       "OwnerAddress",
			SchemaName: "owner_address",
		},
		{
			Name:       "Index",
			SchemaName: "index",
		},
		{
			Name:       "Name",
			SchemaName: "name",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Description",
			SchemaName: "description",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Image",
			SchemaName: "image",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ImageSmall",
			SchemaName: "image_small",
			Null:       !.Flags.Has(4),
		},
		{
			Name:       "ContentURL",
			SchemaName: "content_url",
			Null:       !.Flags.Has(5),
		},
		{
			Name:       "Lottie",
			SchemaName: "lottie",
			Null:       !.Flags.Has(6),
		},
		{
			Name:       "Attributes",
			SchemaName: "attributes",
			Null:       !.Flags.Has(7),
		},
		{
			Name:       "Extra",
			SchemaName: "extra",
			Null:       !.Flags.Has(8),
		},
		{
			Name:       "Gift",
			SchemaName: "gift",
			Null:       !.Flags.Has(9),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *WalletNftItem) () {
	if !(.CollectionAddress == "") {
		.Flags.Set(0)
	}
	if !(.Name == "") {
		.Flags.Set(1)
	}
	if !(.Description == "") {
		.Flags.Set(2)
	}
	if !(.Image == nil) {
		.Flags.Set(3)
	}
	if !(.ImageSmall == nil) {
		.Flags.Set(4)
	}
	if !(.ContentURL == nil) {
		.Flags.Set(5)
	}
	if !(.Lottie == nil) {
		.Flags.Set(6)
	}
	if !(.Attributes == nil) {
		.Flags.Set(7)
	}
	if !(.Extra.Zero()) {
		.Flags.Set(8)
	}
	if !(.Gift == nil) {
		.Flags.Set(9)
	}
}

// Encode implements bin.Encoder.
func ( *WalletNftItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.nftItem#173dfaf3 as nil")
	}
	.PutID(WalletNftItemTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *WalletNftItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode wallet.nftItem#173dfaf3 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.CollectionAddress)
	}
	.PutString(.Address)
	.PutString(.OwnerAddress)
	.PutString(.Index)
	if .Flags.Has(1) {
		.PutString(.Name)
	}
	if .Flags.Has(2) {
		.PutString(.Description)
	}
	if .Flags.Has(3) {
		if .Image == nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field image is nil")
		}
		if  := .Image.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field image: %w", )
		}
	}
	if .Flags.Has(4) {
		if .ImageSmall == nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field image_small is nil")
		}
		if  := .ImageSmall.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field image_small: %w", )
		}
	}
	if .Flags.Has(5) {
		if .ContentURL == nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field content_url is nil")
		}
		if  := .ContentURL.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field content_url: %w", )
		}
	}
	if .Flags.Has(6) {
		if .Lottie == nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field lottie is nil")
		}
		if  := .Lottie.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field lottie: %w", )
		}
	}
	if .Flags.Has(7) {
		.PutVectorHeader(len(.Attributes))
		for ,  := range .Attributes {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field attributes element with index %d: %w", , )
			}
		}
	}
	if .Flags.Has(8) {
		if  := .Extra.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field extra: %w", )
		}
	}
	if .Flags.Has(9) {
		if .Gift == nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field gift is nil")
		}
		if  := .Gift.Encode();  != nil {
			return fmt.Errorf("unable to encode wallet.nftItem#173dfaf3: field gift: %w", )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *WalletNftItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.nftItem#173dfaf3 to nil")
	}
	if  := .ConsumeID(WalletNftItemTypeID);  != nil {
		return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *WalletNftItem) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode wallet.nftItem#173dfaf3 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field collection_address: %w", )
		}
		.CollectionAddress = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field address: %w", )
		}
		.Address = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field owner_address: %w", )
		}
		.OwnerAddress = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field index: %w", )
		}
		.Index = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field name: %w", )
		}
		.Name = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(3) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field image: %w", )
		}
		.Image = 
	}
	if .Flags.Has(4) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field image_small: %w", )
		}
		.ImageSmall = 
	}
	if .Flags.Has(5) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field content_url: %w", )
		}
		.ContentURL = 
	}
	if .Flags.Has(6) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field lottie: %w", )
		}
		.Lottie = 
	}
	if .Flags.Has(7) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field attributes: %w", )
		}

		if  > 0 {
			.Attributes = make([]WalletNftAttribute, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  WalletNftAttribute
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field attributes: %w", )
			}
			.Attributes = append(.Attributes, )
		}
	}
	if .Flags.Has(8) {
		if  := .Extra.Decode();  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field extra: %w", )
		}
	}
	if .Flags.Has(9) {
		,  := DecodeStarGift()
		if  != nil {
			return fmt.Errorf("unable to decode wallet.nftItem#173dfaf3: field gift: %w", )
		}
		.Gift = 
	}
	return nil
}

// SetCollectionAddress sets value of CollectionAddress conditional field.
func ( *WalletNftItem) ( string) {
	.Flags.Set(0)
	.CollectionAddress = 
}

// GetCollectionAddress returns value of CollectionAddress conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .CollectionAddress, true
}

// GetAddress returns value of Address field.
func ( *WalletNftItem) () ( string) {
	if  == nil {
		return
	}
	return .Address
}

// GetOwnerAddress returns value of OwnerAddress field.
func ( *WalletNftItem) () ( string) {
	if  == nil {
		return
	}
	return .OwnerAddress
}

// GetIndex returns value of Index field.
func ( *WalletNftItem) () ( string) {
	if  == nil {
		return
	}
	return .Index
}

// SetName sets value of Name conditional field.
func ( *WalletNftItem) ( string) {
	.Flags.Set(1)
	.Name = 
}

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

// SetDescription sets value of Description conditional field.
func ( *WalletNftItem) ( string) {
	.Flags.Set(2)
	.Description = 
}

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

// SetImage sets value of Image conditional field.
func ( *WalletNftItem) ( WebDocumentClass) {
	.Flags.Set(3)
	.Image = 
}

// GetImage returns value of Image conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .Image, true
}

// SetImageSmall sets value of ImageSmall conditional field.
func ( *WalletNftItem) ( WebDocumentClass) {
	.Flags.Set(4)
	.ImageSmall = 
}

// GetImageSmall returns value of ImageSmall conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .ImageSmall, true
}

// SetContentURL sets value of ContentURL conditional field.
func ( *WalletNftItem) ( WebDocumentClass) {
	.Flags.Set(5)
	.ContentURL = 
}

// GetContentURL returns value of ContentURL conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(5) {
		return , false
	}
	return .ContentURL, true
}

// SetLottie sets value of Lottie conditional field.
func ( *WalletNftItem) ( WebDocumentClass) {
	.Flags.Set(6)
	.Lottie = 
}

// GetLottie returns value of Lottie conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(6) {
		return , false
	}
	return .Lottie, true
}

// SetAttributes sets value of Attributes conditional field.
func ( *WalletNftItem) ( []WalletNftAttribute) {
	.Flags.Set(7)
	.Attributes = 
}

// GetAttributes returns value of Attributes conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( []WalletNftAttribute,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(7) {
		return , false
	}
	return .Attributes, true
}

// SetExtra sets value of Extra conditional field.
func ( *WalletNftItem) ( DataJSON) {
	.Flags.Set(8)
	.Extra = 
}

// GetExtra returns value of Extra conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( DataJSON,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(8) {
		return , false
	}
	return .Extra, true
}

// SetGift sets value of Gift conditional field.
func ( *WalletNftItem) ( StarGiftClass) {
	.Flags.Set(9)
	.Gift = 
}

// GetGift returns value of Gift conditional field and
// boolean which is true if field was set.
func ( *WalletNftItem) () ( StarGiftClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(9) {
		return , false
	}
	return .Gift, true
}