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

// PaymentsPaymentReceipt represents TL type `payments.paymentReceipt#70c4fe03`.
// Receipt
//
// See https://core.telegram.org/constructor/payments.paymentReceipt for reference.
type PaymentsPaymentReceipt struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Date of generation
	Date int
	// Bot ID
	BotID int64
	// Provider ID
	ProviderID int64
	// Title
	Title string
	// Description
	Description string
	// Photo
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo WebDocumentClass
	// Invoice
	Invoice Invoice
	// Info
	//
	// Use SetInfo and GetInfo helpers.
	Info PaymentRequestedInfo
	// Selected shipping option
	//
	// Use SetShipping and GetShipping helpers.
	Shipping ShippingOption
	// Tipped amount
	//
	// Use SetTipAmount and GetTipAmount helpers.
	TipAmount int64
	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	Currency string
	// Total amount in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	TotalAmount int64
	// Payment credential name
	CredentialsTitle string
	// Users
	Users []UserClass
}

// PaymentsPaymentReceiptTypeID is TL type id of PaymentsPaymentReceipt.
const PaymentsPaymentReceiptTypeID = 0x70c4fe03

// construct implements constructor of PaymentsPaymentReceiptClass.
func ( PaymentsPaymentReceipt) () PaymentsPaymentReceiptClass { return & }

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

	_ PaymentsPaymentReceiptClass = &PaymentsPaymentReceipt{}
)

func ( *PaymentsPaymentReceipt) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.ProviderID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.Invoice.Zero()) {
		return false
	}
	if !(.Info.Zero()) {
		return false
	}
	if !(.Shipping.Zero()) {
		return false
	}
	if !(.TipAmount == 0) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.TotalAmount == 0) {
		return false
	}
	if !(.CredentialsTitle == "") {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsPaymentReceipt from given interface.
func ( *PaymentsPaymentReceipt) ( interface {
	() ( int)
	() ( int64)
	() ( int64)
	() ( string)
	() ( string)
	() ( WebDocumentClass,  bool)
	() ( Invoice)
	() ( PaymentRequestedInfo,  bool)
	() ( ShippingOption,  bool)
	() ( int64,  bool)
	() ( string)
	() ( int64)
	() ( string)
	() ( []UserClass)
}) {
	.Date = .()
	.BotID = .()
	.ProviderID = .()
	.Title = .()
	.Description = .()
	if ,  := .();  {
		.Photo = 
	}

	.Invoice = .()
	if ,  := .();  {
		.Info = 
	}

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

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

	.Currency = .()
	.TotalAmount = .()
	.CredentialsTitle = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsPaymentReceipt) () tdp.Type {
	 := tdp.Type{
		Name: "payments.paymentReceipt",
		ID:   PaymentsPaymentReceiptTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "ProviderID",
			SchemaName: "provider_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Description",
			SchemaName: "description",
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Invoice",
			SchemaName: "invoice",
		},
		{
			Name:       "Info",
			SchemaName: "info",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Shipping",
			SchemaName: "shipping",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "TipAmount",
			SchemaName: "tip_amount",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "TotalAmount",
			SchemaName: "total_amount",
		},
		{
			Name:       "CredentialsTitle",
			SchemaName: "credentials_title",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsPaymentReceipt) () {
	if !(.Photo == nil) {
		.Flags.Set(2)
	}
	if !(.Info.Zero()) {
		.Flags.Set(0)
	}
	if !(.Shipping.Zero()) {
		.Flags.Set(1)
	}
	if !(.TipAmount == 0) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsPaymentReceipt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentReceipt#70c4fe03 as nil")
	}
	.PutID(PaymentsPaymentReceiptTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsPaymentReceipt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentReceipt#70c4fe03 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field flags: %w", )
	}
	.PutInt(.Date)
	.PutLong(.BotID)
	.PutLong(.ProviderID)
	.PutString(.Title)
	.PutString(.Description)
	if .Flags.Has(2) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field photo: %w", )
		}
	}
	if  := .Invoice.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field invoice: %w", )
	}
	if .Flags.Has(0) {
		if  := .Info.Encode();  != nil {
			return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field info: %w", )
		}
	}
	if .Flags.Has(1) {
		if  := .Shipping.Encode();  != nil {
			return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field shipping: %w", )
		}
	}
	if .Flags.Has(3) {
		.PutLong(.TipAmount)
	}
	.PutString(.Currency)
	.PutLong(.TotalAmount)
	.PutString(.CredentialsTitle)
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.paymentReceipt#70c4fe03: field users element with index %d: %w", , )
		}
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *PaymentsPaymentReceipt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.paymentReceipt#70c4fe03 to nil")
	}
	if  := .ConsumeID(PaymentsPaymentReceiptTypeID);  != nil {
		return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsPaymentReceipt) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.paymentReceipt#70c4fe03 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field provider_id: %w", )
		}
		.ProviderID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(2) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field photo: %w", )
		}
		.Photo = 
	}
	{
		if  := .Invoice.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field invoice: %w", )
		}
	}
	if .Flags.Has(0) {
		if  := .Info.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field info: %w", )
		}
	}
	if .Flags.Has(1) {
		if  := .Shipping.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field shipping: %w", )
		}
	}
	if .Flags.Has(3) {
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field tip_amount: %w", )
		}
		.TipAmount = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field total_amount: %w", )
		}
		.TotalAmount = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field credentials_title: %w", )
		}
		.CredentialsTitle = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode payments.paymentReceipt#70c4fe03: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

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

// GetBotID returns value of BotID field.
func ( *PaymentsPaymentReceipt) () ( int64) {
	if  == nil {
		return
	}
	return .BotID
}

// GetProviderID returns value of ProviderID field.
func ( *PaymentsPaymentReceipt) () ( int64) {
	if  == nil {
		return
	}
	return .ProviderID
}

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

// GetDescription returns value of Description field.
func ( *PaymentsPaymentReceipt) () ( string) {
	if  == nil {
		return
	}
	return .Description
}

// SetPhoto sets value of Photo conditional field.
func ( *PaymentsPaymentReceipt) ( WebDocumentClass) {
	.Flags.Set(2)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *PaymentsPaymentReceipt) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Photo, true
}

// GetInvoice returns value of Invoice field.
func ( *PaymentsPaymentReceipt) () ( Invoice) {
	if  == nil {
		return
	}
	return .Invoice
}

// SetInfo sets value of Info conditional field.
func ( *PaymentsPaymentReceipt) ( PaymentRequestedInfo) {
	.Flags.Set(0)
	.Info = 
}

// GetInfo returns value of Info conditional field and
// boolean which is true if field was set.
func ( *PaymentsPaymentReceipt) () ( PaymentRequestedInfo,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Info, true
}

// SetShipping sets value of Shipping conditional field.
func ( *PaymentsPaymentReceipt) ( ShippingOption) {
	.Flags.Set(1)
	.Shipping = 
}

// GetShipping returns value of Shipping conditional field and
// boolean which is true if field was set.
func ( *PaymentsPaymentReceipt) () ( ShippingOption,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Shipping, true
}

// SetTipAmount sets value of TipAmount conditional field.
func ( *PaymentsPaymentReceipt) ( int64) {
	.Flags.Set(3)
	.TipAmount = 
}

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

// GetCurrency returns value of Currency field.
func ( *PaymentsPaymentReceipt) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

// GetTotalAmount returns value of TotalAmount field.
func ( *PaymentsPaymentReceipt) () ( int64) {
	if  == nil {
		return
	}
	return .TotalAmount
}

// GetCredentialsTitle returns value of CredentialsTitle field.
func ( *PaymentsPaymentReceipt) () ( string) {
	if  == nil {
		return
	}
	return .CredentialsTitle
}

// GetUsers returns value of Users field.
func ( *PaymentsPaymentReceipt) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *PaymentsPaymentReceipt) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// PaymentsPaymentReceiptStars represents TL type `payments.paymentReceiptStars#dabbf83a`.
// Receipt for payment made using Telegram Stars¹.
//
// Links:
//  1. https://core.telegram.org/api/stars
//
// See https://core.telegram.org/constructor/payments.paymentReceiptStars for reference.
type PaymentsPaymentReceiptStars struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Date of generation
	Date int
	// Bot ID
	BotID int64
	// Title
	Title string
	// Description
	Description string
	// Product photo
	//
	// Use SetPhoto and GetPhoto helpers.
	Photo WebDocumentClass
	// Invoice
	Invoice Invoice
	// Currency, always XTR.
	Currency string
	// Amount of Telegram Stars¹.
	//
	// Links:
	//  1) https://core.telegram.org/api/stars
	TotalAmount int64
	// Transaction ID
	TransactionID string
	// Info about users mentioned in the other fields.
	Users []UserClass
}

// PaymentsPaymentReceiptStarsTypeID is TL type id of PaymentsPaymentReceiptStars.
const PaymentsPaymentReceiptStarsTypeID = 0xdabbf83a

// construct implements constructor of PaymentsPaymentReceiptClass.
func ( PaymentsPaymentReceiptStars) () PaymentsPaymentReceiptClass { return & }

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

	_ PaymentsPaymentReceiptClass = &PaymentsPaymentReceiptStars{}
)

func ( *PaymentsPaymentReceiptStars) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Date == 0) {
		return false
	}
	if !(.BotID == 0) {
		return false
	}
	if !(.Title == "") {
		return false
	}
	if !(.Description == "") {
		return false
	}
	if !(.Photo == nil) {
		return false
	}
	if !(.Invoice.Zero()) {
		return false
	}
	if !(.Currency == "") {
		return false
	}
	if !(.TotalAmount == 0) {
		return false
	}
	if !(.TransactionID == "") {
		return false
	}
	if !(.Users == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsPaymentReceiptStars from given interface.
func ( *PaymentsPaymentReceiptStars) ( interface {
	() ( int)
	() ( int64)
	() ( string)
	() ( string)
	() ( WebDocumentClass,  bool)
	() ( Invoice)
	() ( string)
	() ( int64)
	() ( string)
	() ( []UserClass)
}) {
	.Date = .()
	.BotID = .()
	.Title = .()
	.Description = .()
	if ,  := .();  {
		.Photo = 
	}

	.Invoice = .()
	.Currency = .()
	.TotalAmount = .()
	.TransactionID = .()
	.Users = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsPaymentReceiptStars) () tdp.Type {
	 := tdp.Type{
		Name: "payments.paymentReceiptStars",
		ID:   PaymentsPaymentReceiptStarsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Date",
			SchemaName: "date",
		},
		{
			Name:       "BotID",
			SchemaName: "bot_id",
		},
		{
			Name:       "Title",
			SchemaName: "title",
		},
		{
			Name:       "Description",
			SchemaName: "description",
		},
		{
			Name:       "Photo",
			SchemaName: "photo",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "Invoice",
			SchemaName: "invoice",
		},
		{
			Name:       "Currency",
			SchemaName: "currency",
		},
		{
			Name:       "TotalAmount",
			SchemaName: "total_amount",
		},
		{
			Name:       "TransactionID",
			SchemaName: "transaction_id",
		},
		{
			Name:       "Users",
			SchemaName: "users",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsPaymentReceiptStars) () {
	if !(.Photo == nil) {
		.Flags.Set(2)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsPaymentReceiptStars) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentReceiptStars#dabbf83a as nil")
	}
	.PutID(PaymentsPaymentReceiptStarsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsPaymentReceiptStars) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentReceiptStars#dabbf83a as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field flags: %w", )
	}
	.PutInt(.Date)
	.PutLong(.BotID)
	.PutString(.Title)
	.PutString(.Description)
	if .Flags.Has(2) {
		if .Photo == nil {
			return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field photo is nil")
		}
		if  := .Photo.Encode();  != nil {
			return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field photo: %w", )
		}
	}
	if  := .Invoice.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field invoice: %w", )
	}
	.PutString(.Currency)
	.PutLong(.TotalAmount)
	.PutString(.TransactionID)
	.PutVectorHeader(len(.Users))
	for ,  := range .Users {
		if  == nil {
			return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field users element with index %d is nil", )
		}
		if  := .Encode();  != nil {
			return fmt.Errorf("unable to encode payments.paymentReceiptStars#dabbf83a: field users element with index %d: %w", , )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsPaymentReceiptStars) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.paymentReceiptStars#dabbf83a to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field flags: %w", )
		}
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field date: %w", )
		}
		.Date = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field bot_id: %w", )
		}
		.BotID = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field title: %w", )
		}
		.Title = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field description: %w", )
		}
		.Description = 
	}
	if .Flags.Has(2) {
		,  := DecodeWebDocument()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field photo: %w", )
		}
		.Photo = 
	}
	{
		if  := .Invoice.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field invoice: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field currency: %w", )
		}
		.Currency = 
	}
	{
		,  := .Long()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field total_amount: %w", )
		}
		.TotalAmount = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field transaction_id: %w", )
		}
		.TransactionID = 
	}
	{
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field users: %w", )
		}

		if  > 0 {
			.Users = make([]UserClass, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			,  := DecodeUser()
			if  != nil {
				return fmt.Errorf("unable to decode payments.paymentReceiptStars#dabbf83a: field users: %w", )
			}
			.Users = append(.Users, )
		}
	}
	return nil
}

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

// GetBotID returns value of BotID field.
func ( *PaymentsPaymentReceiptStars) () ( int64) {
	if  == nil {
		return
	}
	return .BotID
}

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

// GetDescription returns value of Description field.
func ( *PaymentsPaymentReceiptStars) () ( string) {
	if  == nil {
		return
	}
	return .Description
}

// SetPhoto sets value of Photo conditional field.
func ( *PaymentsPaymentReceiptStars) ( WebDocumentClass) {
	.Flags.Set(2)
	.Photo = 
}

// GetPhoto returns value of Photo conditional field and
// boolean which is true if field was set.
func ( *PaymentsPaymentReceiptStars) () ( WebDocumentClass,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Photo, true
}

// GetInvoice returns value of Invoice field.
func ( *PaymentsPaymentReceiptStars) () ( Invoice) {
	if  == nil {
		return
	}
	return .Invoice
}

// GetCurrency returns value of Currency field.
func ( *PaymentsPaymentReceiptStars) () ( string) {
	if  == nil {
		return
	}
	return .Currency
}

// GetTotalAmount returns value of TotalAmount field.
func ( *PaymentsPaymentReceiptStars) () ( int64) {
	if  == nil {
		return
	}
	return .TotalAmount
}

// GetTransactionID returns value of TransactionID field.
func ( *PaymentsPaymentReceiptStars) () ( string) {
	if  == nil {
		return
	}
	return .TransactionID
}

// GetUsers returns value of Users field.
func ( *PaymentsPaymentReceiptStars) () ( []UserClass) {
	if  == nil {
		return
	}
	return .Users
}

// MapUsers returns field Users wrapped in UserClassArray helper.
func ( *PaymentsPaymentReceiptStars) () ( UserClassArray) {
	return UserClassArray(.Users)
}

// PaymentsPaymentReceiptClassName is schema name of PaymentsPaymentReceiptClass.
const PaymentsPaymentReceiptClassName = "payments.PaymentReceipt"

// PaymentsPaymentReceiptClass represents payments.PaymentReceipt generic type.
//
// See https://core.telegram.org/type/payments.PaymentReceipt for reference.
//
// Constructors:
//   - [PaymentsPaymentReceipt]
//   - [PaymentsPaymentReceiptStars]
//
// Example:
//
//	g, err := tg.DecodePaymentsPaymentReceipt(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PaymentsPaymentReceipt: // payments.paymentReceipt#70c4fe03
//	case *tg.PaymentsPaymentReceiptStars: // payments.paymentReceiptStars#dabbf83a
//	default: panic(v)
//	}
type PaymentsPaymentReceiptClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PaymentsPaymentReceiptClass

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

	// Date of generation
	GetDate() (value int)

	// Bot ID
	GetBotID() (value int64)

	// Title
	GetTitle() (value string)

	// Description
	GetDescription() (value string)

	// Photo
	GetPhoto() (value WebDocumentClass, ok bool)

	// Invoice
	GetInvoice() (value Invoice)

	// Three-letter ISO 4217 currency¹ code
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments#supported-currencies
	GetCurrency() (value string)

	// Total amount in the smallest units of the currency (integer, not float/double). For
	// example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in
	// currencies.json¹, it shows the number of digits past the decimal point for each
	// currency (2 for the majority of currencies).
	//
	// Links:
	//  1) https://core.telegram.org/bots/payments/currencies.json
	GetTotalAmount() (value int64)

	// Users
	GetUsers() (value []UserClass)
	// Users
	MapUsers() (value UserClassArray)
}

// DecodePaymentsPaymentReceipt implements binary de-serialization for PaymentsPaymentReceiptClass.
func ( *bin.Buffer) (PaymentsPaymentReceiptClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PaymentsPaymentReceiptTypeID:
		// Decoding payments.paymentReceipt#70c4fe03.
		 := PaymentsPaymentReceipt{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsPaymentReceiptClass: %w", )
		}
		return &, nil
	case PaymentsPaymentReceiptStarsTypeID:
		// Decoding payments.paymentReceiptStars#dabbf83a.
		 := PaymentsPaymentReceiptStars{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsPaymentReceiptClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PaymentsPaymentReceiptClass: %w", bin.NewUnexpectedID())
	}
}

// PaymentsPaymentReceipt boxes the PaymentsPaymentReceiptClass providing a helper.
type PaymentsPaymentReceiptBox struct {
	PaymentReceipt PaymentsPaymentReceiptClass
}

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

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