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

// HelpPassportConfigNotModified represents TL type `help.passportConfigNotModified#bfb9f457`.
// Password configuration not modified
//
// See https://core.telegram.org/constructor/help.passportConfigNotModified for reference.
type HelpPassportConfigNotModified struct {
}

// HelpPassportConfigNotModifiedTypeID is TL type id of HelpPassportConfigNotModified.
const HelpPassportConfigNotModifiedTypeID = 0xbfb9f457

// construct implements constructor of HelpPassportConfigClass.
func ( HelpPassportConfigNotModified) () HelpPassportConfigClass { return & }

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

	_ HelpPassportConfigClass = &HelpPassportConfigNotModified{}
)

func ( *HelpPassportConfigNotModified) () bool {
	if  == nil {
		return true
	}

	return true
}

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

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

// TypeName returns name of type in TL schema.
func (*HelpPassportConfigNotModified) () string {
	return "help.passportConfigNotModified"
}

// TypeInfo returns info about TL type.
func ( *HelpPassportConfigNotModified) () tdp.Type {
	 := tdp.Type{
		Name: "help.passportConfigNotModified",
		ID:   HelpPassportConfigNotModifiedTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpPassportConfigNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.passportConfigNotModified#bfb9f457 as nil")
	}
	.PutID(HelpPassportConfigNotModifiedTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpPassportConfigNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.passportConfigNotModified#bfb9f457 as nil")
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *HelpPassportConfigNotModified) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.passportConfigNotModified#bfb9f457 to nil")
	}
	return nil
}

// HelpPassportConfig represents TL type `help.passportConfig#a098d6af`.
// Telegram passportĀ¹ configuration
//
// Links:
//  1. https://core.telegram.org/passport
//
// See https://core.telegram.org/constructor/help.passportConfig for reference.
type HelpPassportConfig struct {
	// Hash for pagination, for more info click hereĀ¹
	//
	// Links:
	//  1) https://core.telegram.org/api/offsets#hash-generation
	Hash int
	// Localization
	CountriesLangs DataJSON
}

// HelpPassportConfigTypeID is TL type id of HelpPassportConfig.
const HelpPassportConfigTypeID = 0xa098d6af

// construct implements constructor of HelpPassportConfigClass.
func ( HelpPassportConfig) () HelpPassportConfigClass { return & }

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

	_ HelpPassportConfigClass = &HelpPassportConfig{}
)

func ( *HelpPassportConfig) () bool {
	if  == nil {
		return true
	}
	if !(.Hash == 0) {
		return false
	}
	if !(.CountriesLangs.Zero()) {
		return false
	}

	return true
}

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

// FillFrom fills HelpPassportConfig from given interface.
func ( *HelpPassportConfig) ( interface {
	() ( int)
	() ( DataJSON)
}) {
	.Hash = .()
	.CountriesLangs = .()
}

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

// TypeName returns name of type in TL schema.
func (*HelpPassportConfig) () string {
	return "help.passportConfig"
}

// TypeInfo returns info about TL type.
func ( *HelpPassportConfig) () tdp.Type {
	 := tdp.Type{
		Name: "help.passportConfig",
		ID:   HelpPassportConfigTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Hash",
			SchemaName: "hash",
		},
		{
			Name:       "CountriesLangs",
			SchemaName: "countries_langs",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *HelpPassportConfig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.passportConfig#a098d6af as nil")
	}
	.PutID(HelpPassportConfigTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *HelpPassportConfig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode help.passportConfig#a098d6af as nil")
	}
	.PutInt(.Hash)
	if  := .CountriesLangs.Encode();  != nil {
		return fmt.Errorf("unable to encode help.passportConfig#a098d6af: field countries_langs: %w", )
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *HelpPassportConfig) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode help.passportConfig#a098d6af to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode help.passportConfig#a098d6af: field hash: %w", )
		}
		.Hash = 
	}
	{
		if  := .CountriesLangs.Decode();  != nil {
			return fmt.Errorf("unable to decode help.passportConfig#a098d6af: field countries_langs: %w", )
		}
	}
	return nil
}

// GetHash returns value of Hash field.
func ( *HelpPassportConfig) () ( int) {
	if  == nil {
		return
	}
	return .Hash
}

// GetCountriesLangs returns value of CountriesLangs field.
func ( *HelpPassportConfig) () ( DataJSON) {
	if  == nil {
		return
	}
	return .CountriesLangs
}

// HelpPassportConfigClassName is schema name of HelpPassportConfigClass.
const HelpPassportConfigClassName = "help.PassportConfig"

// HelpPassportConfigClass represents help.PassportConfig generic type.
//
// See https://core.telegram.org/type/help.PassportConfig for reference.
//
// Example:
//
//	g, err := tg.DecodeHelpPassportConfig(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.HelpPassportConfigNotModified: // help.passportConfigNotModified#bfb9f457
//	case *tg.HelpPassportConfig: // help.passportConfig#a098d6af
//	default: panic(v)
//	}
type HelpPassportConfigClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() HelpPassportConfigClass

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

	// AsModified tries to map HelpPassportConfigClass to HelpPassportConfig.
	AsModified() (*HelpPassportConfig, bool)
}

// AsModified tries to map HelpPassportConfigNotModified to HelpPassportConfig.
func ( *HelpPassportConfigNotModified) () (*HelpPassportConfig, bool) {
	return nil, false
}

// AsModified tries to map HelpPassportConfig to HelpPassportConfig.
func ( *HelpPassportConfig) () (*HelpPassportConfig, bool) {
	return , true
}

// DecodeHelpPassportConfig implements binary de-serialization for HelpPassportConfigClass.
func ( *bin.Buffer) (HelpPassportConfigClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case HelpPassportConfigNotModifiedTypeID:
		// Decoding help.passportConfigNotModified#bfb9f457.
		 := HelpPassportConfigNotModified{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpPassportConfigClass: %w", )
		}
		return &, nil
	case HelpPassportConfigTypeID:
		// Decoding help.passportConfig#a098d6af.
		 := HelpPassportConfig{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode HelpPassportConfigClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode HelpPassportConfigClass: %w", bin.NewUnexpectedID())
	}
}

// HelpPassportConfig boxes the HelpPassportConfigClass providing a helper.
type HelpPassportConfigBox struct {
	PassportConfig HelpPassportConfigClass
}

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

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