package dto

import "time"

// SocialLoginResponse is returned by the social login endpoints and by the OTP
// verification endpoints.
//
// A session is issued only once the account has BOTH a verified mobile number
// and a verified email address. Until then the response carries a
// VerificationToken and NextStep says what to do with it:
//
//	next_step = "mobile_otp"   call /social/send-mobile-otp then verify
//	next_step = "email_otp"    call /social/send-email-otp  then verify
//	next_step = ""             logged in; token and refresh_token are set
//
// Read NextStep rather than inferring the state. Mobile comes first when both
// are outstanding, but a Google login arrives with its email already verified,
// and a returning user may have only one step left — so the order is not fixed.
type SocialLoginResponse struct {
	Success bool `json:"success"`

	Message string `json:"message"`

	MobileVerificationRequired bool `json:"mobile_verification_required"`

	// EmailVerificationRequired is true whenever the account still lacks a
	// verified email, even while the mobile step is the one to do next.
	EmailVerificationRequired bool `json:"email_verification_required"`

	// NextStep is "mobile_otp", "email_otp", or empty when logged in.
	NextStep string `json:"next_step,omitempty"`

	VerificationToken string `json:"verification_token,omitempty"`

	Token string `json:"token,omitempty"`

	RefreshToken string `json:"refresh_token,omitempty"`

	IsNewUser bool `json:"is_new_user"`

	Provider string `json:"provider"`

	Platform string `json:"platform"`

	User *SocialUserResponse `json:"user"`
}

type SocialUserResponse struct {
	Id uint `json:"id"`

	Name string `json:"name"`

	Email string `json:"email"`

	ContactNo string `json:"contactNo"`

	CountryCode string `json:"countryCode"`

	ProfileImage string `json:"profileImage"`

	MobileVerified bool `json:"mobileVerified"`

	EmailVerified bool `json:"emailVerified"`

	ReferralCode string `json:"referralCode"`

	RoleID uint `json:"roleId"`

	LastLogin *time.Time `json:"lastLogin"`

	UserWallet *WalletResponse `json:"userWallet"`
}
