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

// AuthSentCodeTypeApp represents TL type `auth.sentCodeTypeApp#3dbb5986`.
// The code was sent through the telegram app
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeApp for reference.
type AuthSentCodeTypeApp struct {
	// Length of the code in bytes
	Length int
}

// AuthSentCodeTypeAppTypeID is TL type id of AuthSentCodeTypeApp.
const AuthSentCodeTypeAppTypeID = 0x3dbb5986

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeApp) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeApp{}
)

func ( *AuthSentCodeTypeApp) () bool {
	if  == nil {
		return true
	}
	if !(.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeApp from given interface.
func ( *AuthSentCodeTypeApp) ( interface {
	() ( int)
}) {
	.Length = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeApp) () string {
	return "auth.sentCodeTypeApp"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeApp) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeApp",
		ID:   AuthSentCodeTypeAppTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeApp#3dbb5986 as nil")
	}
	.PutID(AuthSentCodeTypeAppTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeApp#3dbb5986 as nil")
	}
	.PutInt(.Length)
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthSentCodeTypeApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeApp#3dbb5986 to nil")
	}
	if  := .ConsumeID(AuthSentCodeTypeAppTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.sentCodeTypeApp#3dbb5986: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeApp) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeApp#3dbb5986 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeApp#3dbb5986: field length: %w", )
		}
		.Length = 
	}
	return nil
}

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeApp) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// AuthSentCodeTypeSMS represents TL type `auth.sentCodeTypeSms#c000bba2`.
// The code was sent via SMS
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeSms for reference.
type AuthSentCodeTypeSMS struct {
	// Length of the code in bytes
	Length int
}

// AuthSentCodeTypeSMSTypeID is TL type id of AuthSentCodeTypeSMS.
const AuthSentCodeTypeSMSTypeID = 0xc000bba2

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeSMS) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeSMS{}
)

func ( *AuthSentCodeTypeSMS) () bool {
	if  == nil {
		return true
	}
	if !(.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeSMS from given interface.
func ( *AuthSentCodeTypeSMS) ( interface {
	() ( int)
}) {
	.Length = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeSMS) () string {
	return "auth.sentCodeTypeSms"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeSMS) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeSms",
		ID:   AuthSentCodeTypeSMSTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeSms#c000bba2 as nil")
	}
	.PutID(AuthSentCodeTypeSMSTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeSms#c000bba2 as nil")
	}
	.PutInt(.Length)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeSms#c000bba2 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeSms#c000bba2: field length: %w", )
		}
		.Length = 
	}
	return nil
}

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeSMS) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// AuthSentCodeTypeCall represents TL type `auth.sentCodeTypeCall#5353e5a7`.
// The code will be sent via a phone call: a synthesized voice will tell the user which
// verification code to input.
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeCall for reference.
type AuthSentCodeTypeCall struct {
	// Length of the verification code
	Length int
}

// AuthSentCodeTypeCallTypeID is TL type id of AuthSentCodeTypeCall.
const AuthSentCodeTypeCallTypeID = 0x5353e5a7

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeCall) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeCall{}
)

func ( *AuthSentCodeTypeCall) () bool {
	if  == nil {
		return true
	}
	if !(.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeCall from given interface.
func ( *AuthSentCodeTypeCall) ( interface {
	() ( int)
}) {
	.Length = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeCall) () string {
	return "auth.sentCodeTypeCall"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeCall) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeCall",
		ID:   AuthSentCodeTypeCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeCall#5353e5a7 as nil")
	}
	.PutID(AuthSentCodeTypeCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeCall#5353e5a7 as nil")
	}
	.PutInt(.Length)
	return nil
}

// Decode implements bin.Decoder.
func ( *AuthSentCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeCall#5353e5a7 to nil")
	}
	if  := .ConsumeID(AuthSentCodeTypeCallTypeID);  != nil {
		return fmt.Errorf("unable to decode auth.sentCodeTypeCall#5353e5a7: %w", )
	}
	return .DecodeBare()
}

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeCall#5353e5a7 to nil")
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeCall#5353e5a7: field length: %w", )
		}
		.Length = 
	}
	return nil
}

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeCall) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// AuthSentCodeTypeFlashCall represents TL type `auth.sentCodeTypeFlashCall#ab03c6d9`.
// The code will be sent via a flash phone call, that will be closed immediately. The
// phone code will then be the phone number itself, just make sure that the phone number
// matches the specified pattern.
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeFlashCall for reference.
type AuthSentCodeTypeFlashCall struct {
	// pattern¹ to match
	//
	// Links:
	//  1) https://core.telegram.org/api/pattern
	Pattern string
}

// AuthSentCodeTypeFlashCallTypeID is TL type id of AuthSentCodeTypeFlashCall.
const AuthSentCodeTypeFlashCallTypeID = 0xab03c6d9

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeFlashCall) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeFlashCall{}
)

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

	return true
}

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

// FillFrom fills AuthSentCodeTypeFlashCall from given interface.
func ( *AuthSentCodeTypeFlashCall) ( interface {
	() ( string)
}) {
	.Pattern = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeFlashCall) () string {
	return "auth.sentCodeTypeFlashCall"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeFlashCall) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeFlashCall",
		ID:   AuthSentCodeTypeFlashCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Pattern",
			SchemaName: "pattern",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeFlashCall#ab03c6d9 as nil")
	}
	.PutID(AuthSentCodeTypeFlashCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeFlashCall#ab03c6d9 as nil")
	}
	.PutString(.Pattern)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeFlashCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeFlashCall#ab03c6d9 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFlashCall#ab03c6d9: field pattern: %w", )
		}
		.Pattern = 
	}
	return nil
}

// GetPattern returns value of Pattern field.
func ( *AuthSentCodeTypeFlashCall) () ( string) {
	if  == nil {
		return
	}
	return .Pattern
}

// AuthSentCodeTypeMissedCall represents TL type `auth.sentCodeTypeMissedCall#82006484`.
// The code will be sent via a flash phone call, that will be closed immediately. The
// last digits of the phone number that calls are the code that must be entered manually
// by the user.
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeMissedCall for reference.
type AuthSentCodeTypeMissedCall struct {
	// Prefix of the phone number from which the call will be made
	Prefix string
	// Length of the verification code
	Length int
}

// AuthSentCodeTypeMissedCallTypeID is TL type id of AuthSentCodeTypeMissedCall.
const AuthSentCodeTypeMissedCallTypeID = 0x82006484

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeMissedCall) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeMissedCall{}
)

func ( *AuthSentCodeTypeMissedCall) () bool {
	if  == nil {
		return true
	}
	if !(.Prefix == "") {
		return false
	}
	if !(.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeMissedCall from given interface.
func ( *AuthSentCodeTypeMissedCall) ( interface {
	() ( string)
	() ( int)
}) {
	.Prefix = .()
	.Length = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeMissedCall) () string {
	return "auth.sentCodeTypeMissedCall"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeMissedCall) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeMissedCall",
		ID:   AuthSentCodeTypeMissedCallTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Prefix",
			SchemaName: "prefix",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeMissedCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeMissedCall#82006484 as nil")
	}
	.PutID(AuthSentCodeTypeMissedCallTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeMissedCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeMissedCall#82006484 as nil")
	}
	.PutString(.Prefix)
	.PutInt(.Length)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeMissedCall) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeMissedCall#82006484 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeMissedCall#82006484: field prefix: %w", )
		}
		.Prefix = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeMissedCall#82006484: field length: %w", )
		}
		.Length = 
	}
	return nil
}

// GetPrefix returns value of Prefix field.
func ( *AuthSentCodeTypeMissedCall) () ( string) {
	if  == nil {
		return
	}
	return .Prefix
}

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeMissedCall) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// AuthSentCodeTypeEmailCode represents TL type `auth.sentCodeTypeEmailCode#f450f59b`.
// The code was sent via the previously configured login email »¹
//
// Links:
//  1. https://core.telegram.org/api/auth#email-verification
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeEmailCode for reference.
type AuthSentCodeTypeEmailCode struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether authorization through Apple ID is allowed
	AppleSigninAllowed bool
	// Whether authorization through Google ID is allowed
	GoogleSigninAllowed bool
	// Pattern¹ of the email
	//
	// Links:
	//  1) https://core.telegram.org/api/pattern
	EmailPattern string
	// Length of the sent verification code
	Length int
	// Clients should wait for the specified amount of seconds before allowing the user to
	// invoke auth.resetLoginEmail¹ (will be 0 for Premium² users).
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.resetLoginEmail
	//  2) https://core.telegram.org/api/premium
	//
	// Use SetResetAvailablePeriod and GetResetAvailablePeriod helpers.
	ResetAvailablePeriod int
	// An email reset was already requested, and will occur at the specified date.
	//
	// Use SetResetPendingDate and GetResetPendingDate helpers.
	ResetPendingDate int
}

// AuthSentCodeTypeEmailCodeTypeID is TL type id of AuthSentCodeTypeEmailCode.
const AuthSentCodeTypeEmailCodeTypeID = 0xf450f59b

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeEmailCode) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeEmailCode{}
)

func ( *AuthSentCodeTypeEmailCode) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.AppleSigninAllowed == false) {
		return false
	}
	if !(.GoogleSigninAllowed == false) {
		return false
	}
	if !(.EmailPattern == "") {
		return false
	}
	if !(.Length == 0) {
		return false
	}
	if !(.ResetAvailablePeriod == 0) {
		return false
	}
	if !(.ResetPendingDate == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeEmailCode from given interface.
func ( *AuthSentCodeTypeEmailCode) ( interface {
	() ( bool)
	() ( bool)
	() ( string)
	() ( int)
	() ( int,  bool)
	() ( int,  bool)
}) {
	.AppleSigninAllowed = .()
	.GoogleSigninAllowed = .()
	.EmailPattern = .()
	.Length = .()
	if ,  := .();  {
		.ResetAvailablePeriod = 
	}

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

}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeEmailCode) () string {
	return "auth.sentCodeTypeEmailCode"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeEmailCode) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeEmailCode",
		ID:   AuthSentCodeTypeEmailCodeTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AppleSigninAllowed",
			SchemaName: "apple_signin_allowed",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "GoogleSigninAllowed",
			SchemaName: "google_signin_allowed",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "EmailPattern",
			SchemaName: "email_pattern",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
		{
			Name:       "ResetAvailablePeriod",
			SchemaName: "reset_available_period",
			Null:       !.Flags.Has(3),
		},
		{
			Name:       "ResetPendingDate",
			SchemaName: "reset_pending_date",
			Null:       !.Flags.Has(4),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AuthSentCodeTypeEmailCode) () {
	if !(.AppleSigninAllowed == false) {
		.Flags.Set(0)
	}
	if !(.GoogleSigninAllowed == false) {
		.Flags.Set(1)
	}
	if !(.ResetAvailablePeriod == 0) {
		.Flags.Set(3)
	}
	if !(.ResetPendingDate == 0) {
		.Flags.Set(4)
	}
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeEmailCode#f450f59b as nil")
	}
	.PutID(AuthSentCodeTypeEmailCodeTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeEmailCode#f450f59b as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.sentCodeTypeEmailCode#f450f59b: field flags: %w", )
	}
	.PutString(.EmailPattern)
	.PutInt(.Length)
	if .Flags.Has(3) {
		.PutInt(.ResetAvailablePeriod)
	}
	if .Flags.Has(4) {
		.PutInt(.ResetPendingDate)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeEmailCode) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeEmailCode#f450f59b to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#f450f59b: field flags: %w", )
		}
	}
	.AppleSigninAllowed = .Flags.Has(0)
	.GoogleSigninAllowed = .Flags.Has(1)
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#f450f59b: field email_pattern: %w", )
		}
		.EmailPattern = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#f450f59b: field length: %w", )
		}
		.Length = 
	}
	if .Flags.Has(3) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#f450f59b: field reset_available_period: %w", )
		}
		.ResetAvailablePeriod = 
	}
	if .Flags.Has(4) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeEmailCode#f450f59b: field reset_pending_date: %w", )
		}
		.ResetPendingDate = 
	}
	return nil
}

// SetAppleSigninAllowed sets value of AppleSigninAllowed conditional field.
func ( *AuthSentCodeTypeEmailCode) ( bool) {
	if  {
		.Flags.Set(0)
		.AppleSigninAllowed = true
	} else {
		.Flags.Unset(0)
		.AppleSigninAllowed = false
	}
}

// GetAppleSigninAllowed returns value of AppleSigninAllowed conditional field.
func ( *AuthSentCodeTypeEmailCode) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetGoogleSigninAllowed sets value of GoogleSigninAllowed conditional field.
func ( *AuthSentCodeTypeEmailCode) ( bool) {
	if  {
		.Flags.Set(1)
		.GoogleSigninAllowed = true
	} else {
		.Flags.Unset(1)
		.GoogleSigninAllowed = false
	}
}

// GetGoogleSigninAllowed returns value of GoogleSigninAllowed conditional field.
func ( *AuthSentCodeTypeEmailCode) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// GetEmailPattern returns value of EmailPattern field.
func ( *AuthSentCodeTypeEmailCode) () ( string) {
	if  == nil {
		return
	}
	return .EmailPattern
}

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeEmailCode) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// SetResetAvailablePeriod sets value of ResetAvailablePeriod conditional field.
func ( *AuthSentCodeTypeEmailCode) ( int) {
	.Flags.Set(3)
	.ResetAvailablePeriod = 
}

// GetResetAvailablePeriod returns value of ResetAvailablePeriod conditional field and
// boolean which is true if field was set.
func ( *AuthSentCodeTypeEmailCode) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(3) {
		return , false
	}
	return .ResetAvailablePeriod, true
}

// SetResetPendingDate sets value of ResetPendingDate conditional field.
func ( *AuthSentCodeTypeEmailCode) ( int) {
	.Flags.Set(4)
	.ResetPendingDate = 
}

// GetResetPendingDate returns value of ResetPendingDate conditional field and
// boolean which is true if field was set.
func ( *AuthSentCodeTypeEmailCode) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(4) {
		return , false
	}
	return .ResetPendingDate, true
}

// AuthSentCodeTypeSetUpEmailRequired represents TL type `auth.sentCodeTypeSetUpEmailRequired#a5491dea`.
// The user should add and verify an email address in order to login as described here
// »¹.
//
// Links:
//  1. https://core.telegram.org/api/auth#email-verification
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeSetUpEmailRequired for reference.
type AuthSentCodeTypeSetUpEmailRequired struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Whether authorization through Apple ID is allowed
	AppleSigninAllowed bool
	// Whether authorization through Google ID is allowed
	GoogleSigninAllowed bool
}

// AuthSentCodeTypeSetUpEmailRequiredTypeID is TL type id of AuthSentCodeTypeSetUpEmailRequired.
const AuthSentCodeTypeSetUpEmailRequiredTypeID = 0xa5491dea

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeSetUpEmailRequired) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeSetUpEmailRequired{}
)

func ( *AuthSentCodeTypeSetUpEmailRequired) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.AppleSigninAllowed == false) {
		return false
	}
	if !(.GoogleSigninAllowed == false) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeSetUpEmailRequired from given interface.
func ( *AuthSentCodeTypeSetUpEmailRequired) ( interface {
	() ( bool)
	() ( bool)
}) {
	.AppleSigninAllowed = .()
	.GoogleSigninAllowed = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeSetUpEmailRequired) () string {
	return "auth.sentCodeTypeSetUpEmailRequired"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeSetUpEmailRequired) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeSetUpEmailRequired",
		ID:   AuthSentCodeTypeSetUpEmailRequiredTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "AppleSigninAllowed",
			SchemaName: "apple_signin_allowed",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "GoogleSigninAllowed",
			SchemaName: "google_signin_allowed",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AuthSentCodeTypeSetUpEmailRequired) () {
	if !(.AppleSigninAllowed == false) {
		.Flags.Set(0)
	}
	if !(.GoogleSigninAllowed == false) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeSetUpEmailRequired) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeSetUpEmailRequired#a5491dea as nil")
	}
	.PutID(AuthSentCodeTypeSetUpEmailRequiredTypeID)
	return .EncodeBare()
}

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

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeSetUpEmailRequired) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeSetUpEmailRequired#a5491dea to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeSetUpEmailRequired#a5491dea: field flags: %w", )
		}
	}
	.AppleSigninAllowed = .Flags.Has(0)
	.GoogleSigninAllowed = .Flags.Has(1)
	return nil
}

// SetAppleSigninAllowed sets value of AppleSigninAllowed conditional field.
func ( *AuthSentCodeTypeSetUpEmailRequired) ( bool) {
	if  {
		.Flags.Set(0)
		.AppleSigninAllowed = true
	} else {
		.Flags.Unset(0)
		.AppleSigninAllowed = false
	}
}

// GetAppleSigninAllowed returns value of AppleSigninAllowed conditional field.
func ( *AuthSentCodeTypeSetUpEmailRequired) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(0)
}

// SetGoogleSigninAllowed sets value of GoogleSigninAllowed conditional field.
func ( *AuthSentCodeTypeSetUpEmailRequired) ( bool) {
	if  {
		.Flags.Set(1)
		.GoogleSigninAllowed = true
	} else {
		.Flags.Unset(1)
		.GoogleSigninAllowed = false
	}
}

// GetGoogleSigninAllowed returns value of GoogleSigninAllowed conditional field.
func ( *AuthSentCodeTypeSetUpEmailRequired) () ( bool) {
	if  == nil {
		return
	}
	return .Flags.Has(1)
}

// AuthSentCodeTypeFragmentSMS represents TL type `auth.sentCodeTypeFragmentSms#d9565c39`.
// The code was delivered via fragment.com¹.
//
// Links:
//  1. https://fragment.com
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeFragmentSms for reference.
type AuthSentCodeTypeFragmentSMS struct {
	// Open the specified URL to log into fragment.com¹ with the wallet that owns the
	// specified phone number and view the code.
	//
	// Links:
	//  1) https://fragment.com
	URL string
	// Length of the delivered code.
	Length int
}

// AuthSentCodeTypeFragmentSMSTypeID is TL type id of AuthSentCodeTypeFragmentSMS.
const AuthSentCodeTypeFragmentSMSTypeID = 0xd9565c39

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeFragmentSMS) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeFragmentSMS{}
)

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

	return true
}

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

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

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeFragmentSMS) () string {
	return "auth.sentCodeTypeFragmentSms"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeFragmentSMS) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeFragmentSms",
		ID:   AuthSentCodeTypeFragmentSMSTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "URL",
			SchemaName: "url",
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeFragmentSms#d9565c39 as nil")
	}
	.PutID(AuthSentCodeTypeFragmentSMSTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeFragmentSms#d9565c39 as nil")
	}
	.PutString(.URL)
	.PutInt(.Length)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeFragmentSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeFragmentSms#d9565c39 to nil")
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFragmentSms#d9565c39: field url: %w", )
		}
		.URL = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFragmentSms#d9565c39: field length: %w", )
		}
		.Length = 
	}
	return nil
}

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

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeFragmentSMS) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// AuthSentCodeTypeFirebaseSMS represents TL type `auth.sentCodeTypeFirebaseSms#e57b1432`.
// An authentication code should be delivered via SMS after Firebase attestation, as
// described in the auth documentation »¹.
//
// Links:
//  1. https://core.telegram.org/api/auth
//
// See https://core.telegram.org/constructor/auth.sentCodeTypeFirebaseSms for reference.
type AuthSentCodeTypeFirebaseSMS struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// On Android, the nonce to be used as described in the auth documentation »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/auth
	//
	// Use SetNonce and GetNonce helpers.
	Nonce []byte
	// On iOS, must be compared with the receipt extracted from the received push
	// notification.
	//
	// Use SetReceipt and GetReceipt helpers.
	Receipt string
	// On iOS: if a push notification with the ios_push_secret isn't received within
	// push_timeout seconds, the next_type authentication method must be used, with auth
	// resendCode¹.
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.resendCode
	//
	// Use SetPushTimeout and GetPushTimeout helpers.
	PushTimeout int
	// Length of the code that will be delivered.
	Length int
}

// AuthSentCodeTypeFirebaseSMSTypeID is TL type id of AuthSentCodeTypeFirebaseSMS.
const AuthSentCodeTypeFirebaseSMSTypeID = 0xe57b1432

// construct implements constructor of AuthSentCodeTypeClass.
func ( AuthSentCodeTypeFirebaseSMS) () AuthSentCodeTypeClass { return & }

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

	_ AuthSentCodeTypeClass = &AuthSentCodeTypeFirebaseSMS{}
)

func ( *AuthSentCodeTypeFirebaseSMS) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.Nonce == nil) {
		return false
	}
	if !(.Receipt == "") {
		return false
	}
	if !(.PushTimeout == 0) {
		return false
	}
	if !(.Length == 0) {
		return false
	}

	return true
}

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

// FillFrom fills AuthSentCodeTypeFirebaseSMS from given interface.
func ( *AuthSentCodeTypeFirebaseSMS) ( interface {
	() ( []byte,  bool)
	() ( string,  bool)
	() ( int,  bool)
	() ( int)
}) {
	if ,  := .();  {
		.Nonce = 
	}

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

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

	.Length = .()
}

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

// TypeName returns name of type in TL schema.
func (*AuthSentCodeTypeFirebaseSMS) () string {
	return "auth.sentCodeTypeFirebaseSms"
}

// TypeInfo returns info about TL type.
func ( *AuthSentCodeTypeFirebaseSMS) () tdp.Type {
	 := tdp.Type{
		Name: "auth.sentCodeTypeFirebaseSms",
		ID:   AuthSentCodeTypeFirebaseSMSTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "Nonce",
			SchemaName: "nonce",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "Receipt",
			SchemaName: "receipt",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "PushTimeout",
			SchemaName: "push_timeout",
			Null:       !.Flags.Has(1),
		},
		{
			Name:       "Length",
			SchemaName: "length",
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AuthSentCodeTypeFirebaseSMS) () {
	if !(.Nonce == nil) {
		.Flags.Set(0)
	}
	if !(.Receipt == "") {
		.Flags.Set(1)
	}
	if !(.PushTimeout == 0) {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AuthSentCodeTypeFirebaseSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeFirebaseSms#e57b1432 as nil")
	}
	.PutID(AuthSentCodeTypeFirebaseSMSTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthSentCodeTypeFirebaseSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.sentCodeTypeFirebaseSms#e57b1432 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.sentCodeTypeFirebaseSms#e57b1432: field flags: %w", )
	}
	if .Flags.Has(0) {
		.PutBytes(.Nonce)
	}
	if .Flags.Has(1) {
		.PutString(.Receipt)
	}
	if .Flags.Has(1) {
		.PutInt(.PushTimeout)
	}
	.PutInt(.Length)
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthSentCodeTypeFirebaseSMS) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.sentCodeTypeFirebaseSms#e57b1432 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field flags: %w", )
		}
	}
	if .Flags.Has(0) {
		,  := .Bytes()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field nonce: %w", )
		}
		.Nonce = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field receipt: %w", )
		}
		.Receipt = 
	}
	if .Flags.Has(1) {
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field push_timeout: %w", )
		}
		.PushTimeout = 
	}
	{
		,  := .Int()
		if  != nil {
			return fmt.Errorf("unable to decode auth.sentCodeTypeFirebaseSms#e57b1432: field length: %w", )
		}
		.Length = 
	}
	return nil
}

// SetNonce sets value of Nonce conditional field.
func ( *AuthSentCodeTypeFirebaseSMS) ( []byte) {
	.Flags.Set(0)
	.Nonce = 
}

// GetNonce returns value of Nonce conditional field and
// boolean which is true if field was set.
func ( *AuthSentCodeTypeFirebaseSMS) () ( []byte,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(0) {
		return , false
	}
	return .Nonce, true
}

// SetReceipt sets value of Receipt conditional field.
func ( *AuthSentCodeTypeFirebaseSMS) ( string) {
	.Flags.Set(1)
	.Receipt = 
}

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

// SetPushTimeout sets value of PushTimeout conditional field.
func ( *AuthSentCodeTypeFirebaseSMS) ( int) {
	.Flags.Set(1)
	.PushTimeout = 
}

// GetPushTimeout returns value of PushTimeout conditional field and
// boolean which is true if field was set.
func ( *AuthSentCodeTypeFirebaseSMS) () ( int,  bool) {
	if  == nil {
		return
	}
	if !.Flags.Has(1) {
		return , false
	}
	return .PushTimeout, true
}

// GetLength returns value of Length field.
func ( *AuthSentCodeTypeFirebaseSMS) () ( int) {
	if  == nil {
		return
	}
	return .Length
}

// AuthSentCodeTypeClassName is schema name of AuthSentCodeTypeClass.
const AuthSentCodeTypeClassName = "auth.SentCodeType"

// AuthSentCodeTypeClass represents auth.SentCodeType generic type.
//
// See https://core.telegram.org/type/auth.SentCodeType for reference.
//
// Example:
//
//	g, err := tg.DecodeAuthSentCodeType(buf)
//	if err != nil {
//	    panic(err)
//	}
//	switch v := g.(type) {
//	case *tg.AuthSentCodeTypeApp: // auth.sentCodeTypeApp#3dbb5986
//	case *tg.AuthSentCodeTypeSMS: // auth.sentCodeTypeSms#c000bba2
//	case *tg.AuthSentCodeTypeCall: // auth.sentCodeTypeCall#5353e5a7
//	case *tg.AuthSentCodeTypeFlashCall: // auth.sentCodeTypeFlashCall#ab03c6d9
//	case *tg.AuthSentCodeTypeMissedCall: // auth.sentCodeTypeMissedCall#82006484
//	case *tg.AuthSentCodeTypeEmailCode: // auth.sentCodeTypeEmailCode#f450f59b
//	case *tg.AuthSentCodeTypeSetUpEmailRequired: // auth.sentCodeTypeSetUpEmailRequired#a5491dea
//	case *tg.AuthSentCodeTypeFragmentSMS: // auth.sentCodeTypeFragmentSms#d9565c39
//	case *tg.AuthSentCodeTypeFirebaseSMS: // auth.sentCodeTypeFirebaseSms#e57b1432
//	default: panic(v)
//	}
type AuthSentCodeTypeClass interface {
	bin.Encoder
	bin.Decoder
	bin.BareEncoder
	bin.BareDecoder
	construct() AuthSentCodeTypeClass

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

// DecodeAuthSentCodeType implements binary de-serialization for AuthSentCodeTypeClass.
func ( *bin.Buffer) (AuthSentCodeTypeClass, error) {
	,  := .PeekID()
	if  != nil {
		return nil, 
	}
	switch  {
	case AuthSentCodeTypeAppTypeID:
		// Decoding auth.sentCodeTypeApp#3dbb5986.
		 := AuthSentCodeTypeApp{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeSMSTypeID:
		// Decoding auth.sentCodeTypeSms#c000bba2.
		 := AuthSentCodeTypeSMS{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeCallTypeID:
		// Decoding auth.sentCodeTypeCall#5353e5a7.
		 := AuthSentCodeTypeCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeFlashCallTypeID:
		// Decoding auth.sentCodeTypeFlashCall#ab03c6d9.
		 := AuthSentCodeTypeFlashCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeMissedCallTypeID:
		// Decoding auth.sentCodeTypeMissedCall#82006484.
		 := AuthSentCodeTypeMissedCall{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeEmailCodeTypeID:
		// Decoding auth.sentCodeTypeEmailCode#f450f59b.
		 := AuthSentCodeTypeEmailCode{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeSetUpEmailRequiredTypeID:
		// Decoding auth.sentCodeTypeSetUpEmailRequired#a5491dea.
		 := AuthSentCodeTypeSetUpEmailRequired{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeFragmentSMSTypeID:
		// Decoding auth.sentCodeTypeFragmentSms#d9565c39.
		 := AuthSentCodeTypeFragmentSMS{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	case AuthSentCodeTypeFirebaseSMSTypeID:
		// Decoding auth.sentCodeTypeFirebaseSms#e57b1432.
		 := AuthSentCodeTypeFirebaseSMS{}
		if  := .Decode();  != nil {
			return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", )
		}
		return &, nil
	default:
		return nil, fmt.Errorf("unable to decode AuthSentCodeTypeClass: %w", bin.NewUnexpectedID())
	}
}

// AuthSentCodeType boxes the AuthSentCodeTypeClass providing a helper.
type AuthSentCodeTypeBox struct {
	SentCodeType AuthSentCodeTypeClass
}

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

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