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

// InputPaymentCredentialsSaved represents TL type `inputPaymentCredentialsSaved#c10eb2cf`.
// Saved payment credentials
//
// See https://core.telegram.org/constructor/inputPaymentCredentialsSaved for reference.
type InputPaymentCredentialsSaved struct {
	// Credential ID
	ID string
	// Temporary password
	TmpPassword []byte
}

// InputPaymentCredentialsSavedTypeID is TL type id of InputPaymentCredentialsSaved.
const InputPaymentCredentialsSavedTypeID = 0xc10eb2cf

// construct implements constructor of InputPaymentCredentialsClass.
func ( InputPaymentCredentialsSaved) () InputPaymentCredentialsClass { return & }

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

	_ InputPaymentCredentialsClass = &InputPaymentCredentialsSaved{}
)

func ( *InputPaymentCredentialsSaved) () bool {
	if  == nil {
		return true
	}
	if !(.ID == "") {
		return false
	}
	if !(.TmpPassword == nil) {
		return false
	}

	return true
}

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

// FillFrom fills InputPaymentCredentialsSaved from given interface.
func ( *InputPaymentCredentialsSaved) ( interface {
	() ( string)
	() ( []byte)
}) {
	.ID = .()
	.TmpPassword = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPaymentCredentialsSaved) () tdp.Type {
	 := tdp.Type{
		Name: "inputPaymentCredentialsSaved",
		ID:   InputPaymentCredentialsSavedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
		},
		{
			Name:       "TmpPassword",
			SchemaName: "tmp_password",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPaymentCredentialsSaved) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentialsSaved#c10eb2cf as nil")
	}
	.PutID(InputPaymentCredentialsSavedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPaymentCredentialsSaved) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentialsSaved#c10eb2cf as nil")
	}
	.PutString(.ID)
	.PutBytes(.TmpPassword)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputPaymentCredentialsSaved) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPaymentCredentialsSaved#c10eb2cf to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode inputPaymentCredentialsSaved#c10eb2cf: field id: %w", )
		}
		.ID = 
	}
	{
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode inputPaymentCredentialsSaved#c10eb2cf: field tmp_password: %w", )
		}
		.TmpPassword = 
	}
	return nil
}

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

// GetTmpPassword returns value of TmpPassword field.
func ( *InputPaymentCredentialsSaved) () ( []byte) {
	if  == nil {
		return
	}
	return .TmpPassword
}

// InputPaymentCredentials represents TL type `inputPaymentCredentials#3417d728`.
// Payment credentials
//
// See https://core.telegram.org/constructor/inputPaymentCredentials for reference.
type InputPaymentCredentials struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Save payment credential for future use
	Save bool
	// Payment credentials
	Data DataJSON
}

// InputPaymentCredentialsTypeID is TL type id of InputPaymentCredentials.
const InputPaymentCredentialsTypeID = 0x3417d728

// construct implements constructor of InputPaymentCredentialsClass.
func ( InputPaymentCredentials) () InputPaymentCredentialsClass { return & }

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

	_ InputPaymentCredentialsClass = &InputPaymentCredentials{}
)

func ( *InputPaymentCredentials) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Save == false) {
		return false
	}
	if !(.Data.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputPaymentCredentials from given interface.
func ( *InputPaymentCredentials) ( interface {
	() ( bool)
	() ( DataJSON)
}) {
	.Save = .()
	.Data = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPaymentCredentials) () tdp.Type {
	 := tdp.Type{
		Name: "inputPaymentCredentials",
		ID:   InputPaymentCredentialsTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Save",
			SchemaName: "save",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Data",
			SchemaName: "data",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *InputPaymentCredentials) () {
	if !(.Save == false) {
		.Flags.Set(0)
	}
}

// Encode implements bin.Encoder.
func ( *InputPaymentCredentials) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentials#3417d728 as nil")
	}
	.PutID(InputPaymentCredentialsTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPaymentCredentials) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentials#3417d728 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPaymentCredentials#3417d728: field flags: %w", )
	}
	if  := .Data.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPaymentCredentials#3417d728: field data: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPaymentCredentials) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPaymentCredentials#3417d728 to nil")
	}
	if  := .ConsumeID(InputPaymentCredentialsTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPaymentCredentials#3417d728: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPaymentCredentials) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPaymentCredentials#3417d728 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode inputPaymentCredentials#3417d728: field flags: %w", )
		}
	}
	.Save = .Flags.Has(0)
	{
		if  := .Data.Decode();  != nil {
			return fmt.Errorf("unable to decode inputPaymentCredentials#3417d728: field data: %w", )
		}
	}
	return nil
}

// SetSave sets value of Save conditional field.
func ( *InputPaymentCredentials) ( bool) {
	if  {
		.Flags.Set(0)
		.Save = true
	} else {
		.Flags.Unset(0)
		.Save = false
	}
}

// GetSave returns value of Save conditional field.
func ( *InputPaymentCredentials) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// GetData returns value of Data field.
func ( *InputPaymentCredentials) () ( DataJSON) {
	if  == nil {
		return
	}
	return .Data
}

// InputPaymentCredentialsApplePay represents TL type `inputPaymentCredentialsApplePay#aa1c39f`.
// Apple pay payment credentials
//
// See https://core.telegram.org/constructor/inputPaymentCredentialsApplePay for reference.
type InputPaymentCredentialsApplePay struct {
	// Payment data
	PaymentData DataJSON
}

// InputPaymentCredentialsApplePayTypeID is TL type id of InputPaymentCredentialsApplePay.
const InputPaymentCredentialsApplePayTypeID = 0xaa1c39f

// construct implements constructor of InputPaymentCredentialsClass.
func ( InputPaymentCredentialsApplePay) () InputPaymentCredentialsClass { return & }

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

	_ InputPaymentCredentialsClass = &InputPaymentCredentialsApplePay{}
)

func ( *InputPaymentCredentialsApplePay) () bool {
	if  == nil {
		return true
	}
	if !(.PaymentData.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputPaymentCredentialsApplePay from given interface.
func ( *InputPaymentCredentialsApplePay) ( interface {
	() ( DataJSON)
}) {
	.PaymentData = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPaymentCredentialsApplePay) () tdp.Type {
	 := tdp.Type{
		Name: "inputPaymentCredentialsApplePay",
		ID:   InputPaymentCredentialsApplePayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PaymentData",
			SchemaName: "payment_data",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPaymentCredentialsApplePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentialsApplePay#aa1c39f as nil")
	}
	.PutID(InputPaymentCredentialsApplePayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPaymentCredentialsApplePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentialsApplePay#aa1c39f as nil")
	}
	if  := .PaymentData.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPaymentCredentialsApplePay#aa1c39f: field payment_data: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *InputPaymentCredentialsApplePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPaymentCredentialsApplePay#aa1c39f to nil")
	}
	{
		if  := .PaymentData.Decode();  != nil {
			return fmt.Errorf("unable to decode inputPaymentCredentialsApplePay#aa1c39f: field payment_data: %w", )
		}
	}
	return nil
}

// GetPaymentData returns value of PaymentData field.
func ( *InputPaymentCredentialsApplePay) () ( DataJSON) {
	if  == nil {
		return
	}
	return .PaymentData
}

// InputPaymentCredentialsGooglePay represents TL type `inputPaymentCredentialsGooglePay#8ac32801`.
// Google Pay payment credentials
//
// See https://core.telegram.org/constructor/inputPaymentCredentialsGooglePay for reference.
type InputPaymentCredentialsGooglePay struct {
	// Payment token
	PaymentToken DataJSON
}

// InputPaymentCredentialsGooglePayTypeID is TL type id of InputPaymentCredentialsGooglePay.
const InputPaymentCredentialsGooglePayTypeID = 0x8ac32801

// construct implements constructor of InputPaymentCredentialsClass.
func ( InputPaymentCredentialsGooglePay) () InputPaymentCredentialsClass { return & }

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

	_ InputPaymentCredentialsClass = &InputPaymentCredentialsGooglePay{}
)

func ( *InputPaymentCredentialsGooglePay) () bool {
	if  == nil {
		return true
	}
	if !(.PaymentToken.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills InputPaymentCredentialsGooglePay from given interface.
func ( *InputPaymentCredentialsGooglePay) ( interface {
	() ( DataJSON)
}) {
	.PaymentToken = .()
}

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

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

// TypeInfo returns info about TL type.
func ( *InputPaymentCredentialsGooglePay) () tdp.Type {
	 := tdp.Type{
		Name: "inputPaymentCredentialsGooglePay",
		ID:   InputPaymentCredentialsGooglePayTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PaymentToken",
			SchemaName: "payment_token",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *InputPaymentCredentialsGooglePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentialsGooglePay#8ac32801 as nil")
	}
	.PutID(InputPaymentCredentialsGooglePayTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *InputPaymentCredentialsGooglePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode inputPaymentCredentialsGooglePay#8ac32801 as nil")
	}
	if  := .PaymentToken.Encode();  != nil {
		return fmt.Errorf("unable to encode inputPaymentCredentialsGooglePay#8ac32801: field payment_token: %w", )
	}
	return nil
}

// Decode implements bin.Decoder.
func ( *InputPaymentCredentialsGooglePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPaymentCredentialsGooglePay#8ac32801 to nil")
	}
	if  := .ConsumeID(InputPaymentCredentialsGooglePayTypeID);  != nil {
		return fmt.Errorf("unable to decode inputPaymentCredentialsGooglePay#8ac32801: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *InputPaymentCredentialsGooglePay) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode inputPaymentCredentialsGooglePay#8ac32801 to nil")
	}
	{
		if  := .PaymentToken.Decode();  != nil {
			return fmt.Errorf("unable to decode inputPaymentCredentialsGooglePay#8ac32801: field payment_token: %w", )
		}
	}
	return nil
}

// GetPaymentToken returns value of PaymentToken field.
func ( *InputPaymentCredentialsGooglePay) () ( DataJSON) {
	if  == nil {
		return
	}
	return .PaymentToken
}

// InputPaymentCredentialsClassName is schema name of InputPaymentCredentialsClass.
const InputPaymentCredentialsClassName = "InputPaymentCredentials"

// InputPaymentCredentialsClass represents InputPaymentCredentials generic type.
//
// See https://core.telegram.org/type/InputPaymentCredentials for reference.
//
// Example:
//
//	g, err := tg.DecodeInputPaymentCredentials(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.InputPaymentCredentialsSaved: // inputPaymentCredentialsSaved#c10eb2cf
//	case *tg.InputPaymentCredentials: // inputPaymentCredentials#3417d728
//	case *tg.InputPaymentCredentialsApplePay: // inputPaymentCredentialsApplePay#aa1c39f
//	case *tg.InputPaymentCredentialsGooglePay: // inputPaymentCredentialsGooglePay#8ac32801
//	default: panic(v)
//	}
type InputPaymentCredentialsClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() InputPaymentCredentialsClass

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

// DecodeInputPaymentCredentials implements binary de-serialization for InputPaymentCredentialsClass.
func ( *bin.Buffer) (InputPaymentCredentialsClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case InputPaymentCredentialsSavedTypeID:
		// Decoding inputPaymentCredentialsSaved#c10eb2cf.
		 := InputPaymentCredentialsSaved{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPaymentCredentialsClass: %w", )
		}
		return &, nil
	case InputPaymentCredentialsTypeID:
		// Decoding inputPaymentCredentials#3417d728.
		 := InputPaymentCredentials{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPaymentCredentialsClass: %w", )
		}
		return &, nil
	case InputPaymentCredentialsApplePayTypeID:
		// Decoding inputPaymentCredentialsApplePay#aa1c39f.
		 := InputPaymentCredentialsApplePay{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPaymentCredentialsClass: %w", )
		}
		return &, nil
	case InputPaymentCredentialsGooglePayTypeID:
		// Decoding inputPaymentCredentialsGooglePay#8ac32801.
		 := InputPaymentCredentialsGooglePay{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode InputPaymentCredentialsClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode InputPaymentCredentialsClass: %w", bin.NewUnexpectedID())
	}
}

// InputPaymentCredentials boxes the InputPaymentCredentialsClass providing a helper.
type InputPaymentCredentialsBox struct {
	InputPaymentCredentials InputPaymentCredentialsClass
}

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

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