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

// PaymentRequestedInfo represents TL type `paymentRequestedInfo#909c3f94`.
// Order info provided by the user
//
// See https://core.telegram.org/constructor/paymentRequestedInfo for reference.
type PaymentRequestedInfo struct {
	// Flags, see TL conditional fieldsĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// User's full name
	//
	// Use SetName and GetName helpers.
	Name string
	// User's phone number
	//
	// Use SetPhone and GetPhone helpers.
	Phone string
	// User's email address
	//
	// Use SetEmail and GetEmail helpers.
	Email string
	// User's shipping address
	//
	// Use SetShippingAddress and GetShippingAddress helpers.
	ShippingAddress PostAddress
}

// PaymentRequestedInfoTypeID is TL type id of PaymentRequestedInfo.
const PaymentRequestedInfoTypeID = 0x909c3f94

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

func ( *PaymentRequestedInfo) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Name == "") {
		return false
	}
	if !(.Phone == "") {
		return false
	}
	if !(.Email == "") {
		return false
	}
	if !(.ShippingAddress.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills PaymentRequestedInfo from given interface.
func ( *PaymentRequestedInfo) ( interface {
	() ( string,  bool)
	() ( string,  bool)
	() ( string,  bool)
	() ( PostAddress,  bool)
}) {
	if ,  := .();  {
		.Name = 
	}

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

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

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

}

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

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

// TypeInfo returns info about TL type.
func ( *PaymentRequestedInfo) () tdp.Type {
	 := tdp.Type{
		Name: "paymentRequestedInfo",
		ID:   PaymentRequestedInfoTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Name",
			SchemaName: "name",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Phone",
			SchemaName: "phone",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Email",
			SchemaName: "email",
			Null:       !.Flags.Has(2),
		},
		{
			Name:       "ShippingAddress",
			SchemaName: "shipping_address",
			Null:       !.Flags.Has(3),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *PaymentRequestedInfo) () {
	if !(.Name == "") {
		.Flags.Set(0)
	}
	if !(.Phone == "") {
		.Flags.Set(1)
	}
	if !(.Email == "") {
		.Flags.Set(2)
	}
	if !(.ShippingAddress.Zero()) {
		.Flags.Set(3)
	}
}

// Encode implements bin.Encoder.
func ( *PaymentRequestedInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode paymentRequestedInfo#909c3f94 as nil")
	}
	.PutID(PaymentRequestedInfoTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *PaymentRequestedInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode paymentRequestedInfo#909c3f94 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode paymentRequestedInfo#909c3f94: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutString(.Name)
	}
	if .Flags.Has(1) {
		.PutString(.Phone)
	}
	if .Flags.Has(2) {
		.PutString(.Email)
	}
	if .Flags.Has(3) {
		if  := .ShippingAddress.Encode();  != nil {
			return fmt.Errorf("unable to encode paymentRequestedInfo#909c3f94: field shipping_address: %w", )
		}
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *PaymentRequestedInfo) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode paymentRequestedInfo#909c3f94 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode paymentRequestedInfo#909c3f94: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode paymentRequestedInfo#909c3f94: field name: %w", )
		}
		.Name = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode paymentRequestedInfo#909c3f94: field phone: %w", )
		}
		.Phone = 
	}
	if .Flags.Has(2) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode paymentRequestedInfo#909c3f94: field email: %w", )
		}
		.Email = 
	}
	if .Flags.Has(3) {
		if  := .ShippingAddress.Decode();  != nil {
			return fmt.Errorf("unable to decode paymentRequestedInfo#909c3f94: field shipping_address: %w", )
		}
	}
	return nil
}

// SetName sets value of Name conditional field.
func ( *PaymentRequestedInfo) ( string) {
	.Flags.Set(0)
	.Name = 
}

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

// SetPhone sets value of Phone conditional field.
func ( *PaymentRequestedInfo) ( string) {
	.Flags.Set(1)
	.Phone = 
}

// GetPhone returns value of Phone conditional field and
// boolean which is true if field was set.
func ( *PaymentRequestedInfo) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .Phone, true
}

// SetEmail sets value of Email conditional field.
func ( *PaymentRequestedInfo) ( string) {
	.Flags.Set(2)
	.Email = 
}

// GetEmail returns value of Email conditional field and
// boolean which is true if field was set.
func ( *PaymentRequestedInfo) () ( string,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(2) {
		return , false
	}
	return .Email, true
}

// SetShippingAddress sets value of ShippingAddress conditional field.
func ( *PaymentRequestedInfo) ( PostAddress) {
	.Flags.Set(3)
	.ShippingAddress = 
}

// GetShippingAddress returns value of ShippingAddress conditional field and
// boolean which is true if field was set.
func ( *PaymentRequestedInfo) () ( PostAddress,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .ShippingAddress, true
}