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

// PaymentsPaymentResult represents TL type `payments.paymentResult#4e5f810d`.
// Payment result
//
// See https://core.telegram.org/constructor/payments.paymentResult for reference.
type PaymentsPaymentResult struct {
	// Info about the payment
	Updates UpdatesClass
}

// PaymentsPaymentResultTypeID is TL type id of PaymentsPaymentResult.
const PaymentsPaymentResultTypeID = 0x4e5f810d

// construct implements constructor of PaymentsPaymentResultClass.
func ( PaymentsPaymentResult) () PaymentsPaymentResultClass { return & }

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

	_ PaymentsPaymentResultClass = &PaymentsPaymentResult{}
)

func ( *PaymentsPaymentResult) () bool {
	if  == nil {
		return true
	}
	if !(.Updates == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsPaymentResult from given interface.
func ( *PaymentsPaymentResult) ( interface {
	() ( UpdatesClass)
}) {
	.Updates = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsPaymentResult) () tdp.Type {
	 := tdp.Type{
		Name: "payments.paymentResult",
		ID:   PaymentsPaymentResultTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Updates",
			SchemaName: "updates",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsPaymentResult) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentResult#4e5f810d as nil")
	}
	.PutID(PaymentsPaymentResultTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsPaymentResult) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentResult#4e5f810d as nil")
	}
	if .Updates == nil {
		return fmt.Errorf("unable to encode payments.paymentResult#4e5f810d: field updates is nil")
	}
	if  := .Updates.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.paymentResult#4e5f810d: field updates: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsPaymentResult) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.paymentResult#4e5f810d to nil")
	}
	{
		,  := DecodeUpdates()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentResult#4e5f810d: field updates: %w", )
		}
		.Updates = 
	}
	return nil
}

// GetUpdates returns value of Updates field.
func ( *PaymentsPaymentResult) () ( UpdatesClass) {
	if  == nil {
		return
	}
	return .Updates
}

// PaymentsPaymentVerificationNeeded represents TL type `payments.paymentVerificationNeeded#d8411139`.
// Payment was not successful, additional verification is needed
//
// See https://core.telegram.org/constructor/payments.paymentVerificationNeeded for reference.
type PaymentsPaymentVerificationNeeded struct {
	// URL for additional payment credentials verification
	URL string
}

// PaymentsPaymentVerificationNeededTypeID is TL type id of PaymentsPaymentVerificationNeeded.
const PaymentsPaymentVerificationNeededTypeID = 0xd8411139

// construct implements constructor of PaymentsPaymentResultClass.
func ( PaymentsPaymentVerificationNeeded) () PaymentsPaymentResultClass { return & }

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

	_ PaymentsPaymentResultClass = &PaymentsPaymentVerificationNeeded{}
)

func ( *PaymentsPaymentVerificationNeeded) () bool {
	if  == nil {
		return true
	}
	if !(.URL == "") {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsPaymentVerificationNeeded from given interface.
func ( *PaymentsPaymentVerificationNeeded) ( interface {
	() ( string)
}) {
	.URL = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsPaymentVerificationNeeded) () tdp.Type {
	 := tdp.Type{
		Name: "payments.paymentVerificationNeeded",
		ID:   PaymentsPaymentVerificationNeededTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *PaymentsPaymentVerificationNeeded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentVerificationNeeded#d8411139 as nil")
	}
	.PutID(PaymentsPaymentVerificationNeededTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsPaymentVerificationNeeded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.paymentVerificationNeeded#d8411139 as nil")
	}
	.PutString(.URL)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsPaymentVerificationNeeded) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.paymentVerificationNeeded#d8411139 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.paymentVerificationNeeded#d8411139: field url: %w", )
		}
		.URL = 
	}
	return nil
}

// GetURL returns value of URL field.
func ( *PaymentsPaymentVerificationNeeded) () ( string) {
	if  == nil {
		return
	}
	return .URL
}

// PaymentsPaymentResultClassName is schema name of PaymentsPaymentResultClass.
const PaymentsPaymentResultClassName = "payments.PaymentResult"

// PaymentsPaymentResultClass represents payments.PaymentResult generic type.
//
// See https://core.telegram.org/type/payments.PaymentResult for reference.
//
// Example:
//
//	g, err := tg.DecodePaymentsPaymentResult(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.PaymentsPaymentResult: // payments.paymentResult#4e5f810d
//	case *tg.PaymentsPaymentVerificationNeeded: // payments.paymentVerificationNeeded#d8411139
//	default: panic(v)
//	}
type PaymentsPaymentResultClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() PaymentsPaymentResultClass

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

// DecodePaymentsPaymentResult implements binary de-serialization for PaymentsPaymentResultClass.
func ( *bin.Buffer) (PaymentsPaymentResultClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case PaymentsPaymentResultTypeID:
		// Decoding payments.paymentResult#4e5f810d.
		 := PaymentsPaymentResult{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsPaymentResultClass: %w", )
		}
		return &, nil
	case PaymentsPaymentVerificationNeededTypeID:
		// Decoding payments.paymentVerificationNeeded#d8411139.
		 := PaymentsPaymentVerificationNeeded{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode PaymentsPaymentResultClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode PaymentsPaymentResultClass: %w", bin.NewUnexpectedID())
	}
}

// PaymentsPaymentResult boxes the PaymentsPaymentResultClass providing a helper.
type PaymentsPaymentResultBox struct {
	PaymentResult PaymentsPaymentResultClass
}

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

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