package dto

// SocialLoginRequest is the body of both /social/mobile-login and
// /social/web-login. IdToken is the Firebase ID token the client gets back from
// the Firebase SDK after Google/Apple/Facebook sign-in.
type SocialLoginRequest struct {
	// IdToken carries a Firebase ID token or a Google Sign-In token. Not
	// required outright any more, because a Facebook login sends AccessToken
	// instead; exactly one of the two must be present.
	IdToken string `json:"id_token"`

	// AccessToken carries a Facebook access token, which is an opaque bearer
	// string rather than a JWT.
	AccessToken string `json:"access_token"`

	DeviceToken string `json:"device_token"`

	DeviceName string `json:"device_name"`

	// Platform is optional and only affects what is recorded. The endpoint
	// already implies it — /social/web-login means web, /social/mobile-login
	// means mobile — so a mobile client sends "android" or "ios" here when it
	// wants the two told apart in login history. An unknown value falls back to
	// the endpoint's default.
	Platform string `json:"platform"`
}

// SocialSendMobileOTPRequest starts mobile verification for a social account.
// VerificationToken is the short-lived token returned by the social login call.
type SocialSendMobileOTPRequest struct {
	VerificationToken string `json:"verification_token" binding:"required"`

	CountryCode string `json:"countryCode"`

	Mobile string `json:"mobile" binding:"required"`
}

// SocialSendEmailOTPRequest starts email verification for a social account.
// Needed because Facebook releases an address only when the user granted the
// email permission and the account has one — an account registered with a phone
// number arrives with no email at all.
type SocialSendEmailOTPRequest struct {
	VerificationToken string `json:"verification_token" binding:"required"`

	Email string `json:"email" binding:"required"`
}

// SocialVerifyEmailOTPRequest completes email verification.
type SocialVerifyEmailOTPRequest struct {
	VerificationToken string `json:"verification_token" binding:"required"`

	Email string `json:"email"`

	OTP string `json:"otp" binding:"required"`

	DeviceName string `json:"device_name"`

	Platform string `json:"platform"`
}

// SocialVerifyMobileOTPRequest completes mobile verification and logs the user in.
type SocialVerifyMobileOTPRequest struct {
	VerificationToken string `json:"verification_token" binding:"required"`

	Mobile string `json:"mobile"`

	OTP string `json:"otp" binding:"required"`

	DeviceName string `json:"device_name"`

	// Platform is optional, as on the login calls. Left out, the platform
	// recorded on the social account is reused.
	Platform string `json:"platform"`
}
