package dto

type RegisterRequest struct {
	Name         string `json:"name" binding:"required"`
	ContactNo    string `json:"contactNo" binding:"required"`
	Email        string `json:"email"`
	Password     string `json:"password" binding:"required"`
	BirthDate    string `json:"birthDate"`
	BirthTime    string `json:"birthTime"`
	BirthPlace   string `json:"birthPlace"`
	AddressLine1 string `json:"addressLine1"`
	Location     string `json:"location"`
	Pincode      string `json:"pincode"`
	Gender       string `json:"gender"`
	CountryCode  string `json:"countryCode"`

	// The handset's FCM registration token. Optional — a web client has
	// none — but without it this account cannot receive a push notification
	// until it logs in again or calls /device-token.
	DeviceToken string `json:"device_token"`

	// ANDROID, IPHONE or WEB. Stored alongside the token so a payload can be
	// shaped per platform later. When omitted, Platform is used instead.
	DeviceType string `json:"device_type"`

	// Session details, matching what /verify-login-otp already takes. These
	// go to login_histories, not to users — there are no such columns on the
	// user row — so registering is recorded as a session in the same place a
	// login is.
	DeviceName string `json:"device_name"`

	IPAddress string `json:"ip_address"`

	Platform string `json:"platform"`
}

// Device collects the handset fields into the shape the service layer takes.
func (r RegisterRequest) Device() DeviceContext {

	return DeviceContext{
		DeviceToken: r.DeviceToken,
		DeviceType:  r.DeviceType,
		DeviceName:  r.DeviceName,
		IPAddress:   r.IPAddress,
		Platform:    r.Platform,
	}
}