package models

import "time"

type User struct {
	BaseModel
	ID             uint       `gorm:"primaryKey"`
	Name           string     `gorm:"column:name"`
	Email          string     `gorm:"column:email"`
	Password       string     `gorm:"column:password"`
	ContactNo      string     `gorm:"column:contactNo"`
	CountryCode    string     `gorm:"column:countryCode"`
	BirthDate      string     `gorm:"column:birthDate"`
	BirthTime      string     `gorm:"column:birthTime"`
	BirthPlace     string     `gorm:"column:birthPlace"`
	AddressLine1   string     `gorm:"column:addressLine1"`
	Location       string     `gorm:"column:location"`
	Pincode        string     `gorm:"column:pincode"`
	Gender         string     `gorm:"column:gender"`
	MobileVerified bool       `gorm:"column:mobile_verified"`
	EmailVerified  bool       `gorm:"column:email_verified"`
	JwtToken       string     `gorm:"type:longtext"`
	RefreshToken   string     `gorm:"column:refresh_token"`
	// The handset's FCM registration token, written to all three columns the
	// schema carries for it. device_token is what this API has always used;
	// fcm_token and token existed but were never populated, and push
	// notifications need the token to be findable under whichever name the
	// reader expects. repositories.SaveDeviceToken keeps them in step.
	FcmToken       string     `gorm:"column:fcm_token"`
	Token          string     `gorm:"column:token"`
	// ANDROID, IPHONE or WEB. The column has always existed; nothing wrote it.
	DeviceType     string     `gorm:"column:device_type"`
	ReferralCode   string     `gorm:"column:referral_code"`
	DeviceToken    string     `gorm:"column:device_token"`
	LastLogin      *time.Time `gorm:"column:last_login"`
	IsActive       bool       `gorm:"column:isActive"`
	IsDelete       bool       `gorm:"column:isDelete"`
	IsSuspended    bool       `gorm:"column:is_suspended"`
	Profile        string     `gorm:"column:profile"`
	RoleID         uint
	Payments       []Payment
	Tickets        []Ticket

	UserWallet UserWallet `gorm:"foreignKey:UserID"`
}

func (User) TableName() string {
	return "users"
}
