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

// AuthRequestFirebaseSMSRequest represents TL type `auth.requestFirebaseSms#89464b50`.
// Request an SMS code via Firebase.
//
// See https://core.telegram.org/method/auth.requestFirebaseSms for reference.
type AuthRequestFirebaseSMSRequest struct {
	// Flags, see TL conditional fields¹
	//
	// Links:
	//  1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
	Flags bin.Fields
	// Phone number
	PhoneNumber string
	// Phone code hash returned by auth.sendCode¹
	//
	// Links:
	//  1) https://core.telegram.org/method/auth.sendCode
	PhoneCodeHash string
	// On Android, a JWS object obtained as described in the auth documentation »¹
	//
	// Links:
	//  1) https://core.telegram.org/api/auth
	//
	// Use SetSafetyNetToken and GetSafetyNetToken helpers.
	SafetyNetToken string
	// Secret token received via an apple push notification
	//
	// Use SetIosPushSecret and GetIosPushSecret helpers.
	IosPushSecret string
}

// AuthRequestFirebaseSMSRequestTypeID is TL type id of AuthRequestFirebaseSMSRequest.
const AuthRequestFirebaseSMSRequestTypeID = 0x89464b50

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

func ( *AuthRequestFirebaseSMSRequest) () bool {
	if  == nil {
		return true
	}
	if !(.Flags.Zero()) {
		return false
	}
	if !(.PhoneNumber == "") {
		return false
	}
	if !(.PhoneCodeHash == "") {
		return false
	}
	if !(.SafetyNetToken == "") {
		return false
	}
	if !(.IosPushSecret == "") {
		return false
	}

	return true
}

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

// FillFrom fills AuthRequestFirebaseSMSRequest from given interface.
func ( *AuthRequestFirebaseSMSRequest) ( interface {
	() ( string)
	() ( string)
	() ( string,  bool)
	() ( string,  bool)
}) {
	.PhoneNumber = .()
	.PhoneCodeHash = .()
	if ,  := .();  {
		.SafetyNetToken = 
	}

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

}

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

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

// TypeInfo returns info about TL type.
func ( *AuthRequestFirebaseSMSRequest) () tdp.Type {
	 := tdp.Type{
		Name: "auth.requestFirebaseSms",
		ID:   AuthRequestFirebaseSMSRequestTypeID,
	}
	if  == nil {
		.Null = true
		return 
	}
	.Fields = []tdp.Field{
		{
			Name:       "PhoneNumber",
			SchemaName: "phone_number",
		},
		{
			Name:       "PhoneCodeHash",
			SchemaName: "phone_code_hash",
		},
		{
			Name:       "SafetyNetToken",
			SchemaName: "safety_net_token",
			Null:       !.Flags.Has(0),
		},
		{
			Name:       "IosPushSecret",
			SchemaName: "ios_push_secret",
			Null:       !.Flags.Has(1),
		},
	}
	return 
}

// SetFlags sets flags for non-zero fields.
func ( *AuthRequestFirebaseSMSRequest) () {
	if !(.SafetyNetToken == "") {
		.Flags.Set(0)
	}
	if !(.IosPushSecret == "") {
		.Flags.Set(1)
	}
}

// Encode implements bin.Encoder.
func ( *AuthRequestFirebaseSMSRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.requestFirebaseSms#89464b50 as nil")
	}
	.PutID(AuthRequestFirebaseSMSRequestTypeID)
	return .EncodeBare()
}

// EncodeBare implements bin.BareEncoder.
func ( *AuthRequestFirebaseSMSRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't encode auth.requestFirebaseSms#89464b50 as nil")
	}
	.SetFlags()
	if  := .Flags.Encode();  != nil {
		return fmt.Errorf("unable to encode auth.requestFirebaseSms#89464b50: field flags: %w", )
	}
	.PutString(.PhoneNumber)
	.PutString(.PhoneCodeHash)
	if .Flags.Has(0) {
		.PutString(.SafetyNetToken)
	}
	if .Flags.Has(1) {
		.PutString(.IosPushSecret)
	}
	return nil
}

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

// DecodeBare implements bin.BareDecoder.
func ( *AuthRequestFirebaseSMSRequest) ( *bin.Buffer) error {
	if  == nil {
		return fmt.Errorf("can't decode auth.requestFirebaseSms#89464b50 to nil")
	}
	{
		if  := .Flags.Decode();  != nil {
			return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field flags: %w", )
		}
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field phone_number: %w", )
		}
		.PhoneNumber = 
	}
	{
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field phone_code_hash: %w", )
		}
		.PhoneCodeHash = 
	}
	if .Flags.Has(0) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field safety_net_token: %w", )
		}
		.SafetyNetToken = 
	}
	if .Flags.Has(1) {
		,  := .String()
		if  != nil {
			return fmt.Errorf("unable to decode auth.requestFirebaseSms#89464b50: field ios_push_secret: %w", )
		}
		.IosPushSecret = 
	}
	return nil
}

// GetPhoneNumber returns value of PhoneNumber field.
func ( *AuthRequestFirebaseSMSRequest) () ( string) {
	if  == nil {
		return
	}
	return .PhoneNumber
}

// GetPhoneCodeHash returns value of PhoneCodeHash field.
func ( *AuthRequestFirebaseSMSRequest) () ( string) {
	if  == nil {
		return
	}
	return .PhoneCodeHash
}

// SetSafetyNetToken sets value of SafetyNetToken conditional field.
func ( *AuthRequestFirebaseSMSRequest) ( string) {
	.Flags.Set(0)
	.SafetyNetToken = 
}

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

// SetIosPushSecret sets value of IosPushSecret conditional field.
func ( *AuthRequestFirebaseSMSRequest) ( string) {
	.Flags.Set(1)
	.IosPushSecret = 
}

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

// AuthRequestFirebaseSMS invokes method auth.requestFirebaseSms#89464b50 returning error if any.
// Request an SMS code via Firebase.
//
// Possible errors:
//
//	400 PHONE_NUMBER_INVALID: The phone number is invalid.
//
// See https://core.telegram.org/method/auth.requestFirebaseSms for reference.
func ( *Client) ( context.Context,  *AuthRequestFirebaseSMSRequest) (bool, error) {
	var  BoolBox

	if  := .rpc.Invoke(, , &);  != nil {
		return false, 
	}
	,  := .Bool.(*BoolTrue)
	return , nil
}