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

// Ensuring interfaces in compile-time for PaymentsPaymentReceipt.
var (
	_ bin.Encoder     = &PaymentsPaymentReceipt{}
	_ bin.Decoder     = &PaymentsPaymentReceipt{}
	_ bin.BareEncoder = &PaymentsPaymentReceipt{}
	_ bin.BareDecoder = &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)
}