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

// PaymentsValidatedRequestedInfo represents TL type `payments.validatedRequestedInfo#d1451883`.
//
// See https://core.telegram.org/constructor/payments.validatedRequestedInfo for reference.
type PaymentsValidatedRequestedInfo struct {
	// Flags field of PaymentsValidatedRequestedInfo.
	Flags bin.Fields
	// ID field of PaymentsValidatedRequestedInfo.
	//
	// Use SetID and GetID helpers.
	ID string
	// ShippingOptions field of PaymentsValidatedRequestedInfo.
	//
	// Use SetShippingOptions and GetShippingOptions helpers.
	ShippingOptions []ShippingOption
}

// PaymentsValidatedRequestedInfoTypeID is TL type id of PaymentsValidatedRequestedInfo.
const PaymentsValidatedRequestedInfoTypeID = 0xd1451883

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

func ( *PaymentsValidatedRequestedInfo) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.ID == "") {
		return false
	}
	if !(.ShippingOptions == nil) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentsValidatedRequestedInfo from given interface.
func ( *PaymentsValidatedRequestedInfo) ( interface {
	() ( string,  bool)
	() ( []ShippingOption,  bool)
}) {
	if ,  := .();  {
		.ID = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentsValidatedRequestedInfo) () tdp.Type {
	 := tdp.Type{
		Name: "payments.validatedRequestedInfo",
		ID:   PaymentsValidatedRequestedInfoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "ID",
			SchemaName: "id",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "ShippingOptions",
			SchemaName: "shipping_options",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentsValidatedRequestedInfo) () {
	if !(.ID == "") {
		.Flags.Set(0)
	}
	if !(.ShippingOptions == nil) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentsValidatedRequestedInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.validatedRequestedInfo#d1451883 as nil")
	}
	.PutID(PaymentsValidatedRequestedInfoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentsValidatedRequestedInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode payments.validatedRequestedInfo#d1451883 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode payments.validatedRequestedInfo#d1451883: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.ID)
	}
	if .Flags.Has(1) {
		.PutVectorHeader(len(.ShippingOptions))
		for ,  := range .ShippingOptions {
			if  := .Encode();  != nil {
				return fmt.Errorf("unable to encode payments.validatedRequestedInfo#d1451883: field shipping_options element with index %d: %w", , )
			}
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentsValidatedRequestedInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode payments.validatedRequestedInfo#d1451883 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode payments.validatedRequestedInfo#d1451883: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode payments.validatedRequestedInfo#d1451883: field id: %w", )
		}
		.ID = 
	}
	if .Flags.Has(1) {
		,  := .VectorHeader()
		if  != nil {
			return fmt.Errorf("unable to decode payments.validatedRequestedInfo#d1451883: field shipping_options: %w", )
		}

		if  > 0 {
			.ShippingOptions = make([]ShippingOption, 0, %bin.PreallocateLimit)
		}
		for  := 0;  < ; ++ {
			var  ShippingOption
			if  := .Decode();  != nil {
				return fmt.Errorf("unable to decode payments.validatedRequestedInfo#d1451883: field shipping_options: %w", )
			}
			.ShippingOptions = append(.ShippingOptions, )
		}
	}
	return nil
}

// SetID sets value of ID conditional field.
func ( *PaymentsValidatedRequestedInfo) ( string) {
	.Flags.Set(0)
	.ID = 
}

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

// SetShippingOptions sets value of ShippingOptions conditional field.
func ( *PaymentsValidatedRequestedInfo) ( []ShippingOption) {
	.Flags.Set(1)
	.ShippingOptions = 
}

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