package protocol

const (
	LoginByPassword    = "signInPassword"
	LoginBySmsCode     = "signInCaptcha"
	LoginByCredentials = "signInCredentials"
)

const AuthCodeExpire = 60 * 15 //15分钟过期

const TokenExpire = 60 * 60 * 2               //两个小时过期
const RefreshTokenExipre = 3600 * 24 * 30 * 1 //刷新token 一个月过期

//const TokenExpire = 30
//const RefreshTokenExipre = 60 //刷新token

/*Login */
// TODO 判断grantTypePwd校验
type LoginRequest struct {
	Phone       string `json:"phone" valid:"Required;"`
	Password    string `json:"password"`
	Captcha     string `json:"captcha"`
	GrantType   string `json:"grantType" valid:"Required;"` // 登录类型 1:密码 2:验证码
	ClientId    string `json:"clientId"`
	Credentials string `json:"credentials"` //凭证登录
}
type LoginResponse struct {
	AuthCode string `json:"authCode"`
}

type LoginRequestV2 struct {
	Cid         int    `json:"cid"`
	IdType      int    `json:"idType"`      // 用户类型 1:合伙人 2:高管
	Credentials string `json:"credentials"` // 登录类型 1:密码 2:验证码
	ClientId    string `json:"clientId"`
}

//JWT用户信息
type JWTUserInfo struct {
	UserId   string `json:"id"`       //用户id
	PassWord string `json:"passWord"` //密码
}

/*SmsCode*/
type SmsCodeRequest struct {
	Phone    string `json:"phone" valid:"Required"`
	Content  string `json:"-"`
	SendType string `json:"send_type"` //sms_login_code  sms_change_mobile

}
type SmsCodeResponse struct {
	Code string `json:"-"`
}

/*UpdateDevice*/
type UpdateDeviceRequest struct {
	ClientId    string `json:"clientId" valid:"Required"`
	DeviceToken string `json:"deviceToken"`
}
type UpdateDeviceResponse struct {
}

/*AccessToken */
type AccessTokenRequest struct {
	//ClientId     string `json:"clientId" valid:"Required"`
	//ClientSecret string `json:"clientSecret" valid:"Required"`
	AuthCode string `json:"authCode" valid:"Required"`
}
type AccessTokenResponse struct {
	RefreshToken string `json:"refreshToken"`
	AccessToken  string `json:"accessToken"`
	ExpiresIn    int    `json:"expiresIn"`
}

/*RefreshToken */
type RefreshTokenRequest struct {
	ClientId     string `json:"clientId" valid:"Required"`
	ClientSecret string `json:"clientSecret" valid:"Required"`
	RefreshToken string `json:"refreshToken" valid:"Required"`

	//Uid       int64  `json:"-"`
	//LoginType string `json:"-"`
}
type RefreshTokenResponse struct {
	RefreshToken string `json:"refreshToken"`
	AccessToken  string `json:"accessToken"`
	ExpiresIn    int    `json:"expiresIn"`
}

/*Revoke */
type RevokeRequest struct {
}
type RevokeResponse struct {
}

/*AuthCheckSmsCode */
type AuthCheckSmsCodeRequest struct {
	Phone   string `json:"phone" valid:"Required;"`
	Captcha string `json:"captcha" valid:"Required;"`
}
type AuthCheckSmsCodeResponse struct {
	CaptchaCertificate string `json:"captchaCertificate"` //短信验证码通过凭证
}

/*CheckIm */
type CheckImRequest struct {
	UserId       int64
	ImId         string
	Uname        string
	Icon         string
	CustomerImId string
	IsCreated    bool
}
type CheckImResponse struct {
	ImToken   string //net im token
	CsAccount int64  //客服id
}