2023-02-21 20:46:05 +08:00
|
|
|
package sso
|
|
|
|
|
|
|
|
import (
|
2023-02-21 20:58:53 +08:00
|
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
|
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
2023-02-21 20:46:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
VERSION = "2020-08-07"
|
|
|
|
)
|
|
|
|
|
|
|
|
var HOST = requests.Host{
|
|
|
|
Default: "sso",
|
2023-03-16 20:15:17 +08:00
|
|
|
Func: func(s string, area string) string {
|
2023-02-21 20:58:53 +08:00
|
|
|
host := map[string]string{
|
|
|
|
requests.RELEASE: "sso.gaore.com.hk",
|
2023-06-20 14:30:38 +08:00
|
|
|
requests.PRE: "sso.gaore.com.hk",
|
|
|
|
requests.TEST: "sso.gaore.com.hk",
|
2023-02-21 20:58:53 +08:00
|
|
|
}
|
|
|
|
if s, ok := host[s]; ok {
|
|
|
|
return s
|
|
|
|
} else {
|
|
|
|
return "sso.gaore.com.hk"
|
|
|
|
}
|
|
|
|
},
|
2023-02-21 20:46:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
type Client struct {
|
|
|
|
sdk.Client
|
2023-02-23 18:07:43 +08:00
|
|
|
ident string
|
2023-02-21 20:46:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) CodeAuth(req *CodeAuthRequest) (response *CodeAuthResponse, err error) {
|
|
|
|
response = CreateCodeAuthResponse()
|
|
|
|
err = c.DoAction(req, response)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) GetUserInfo(req *GetUserInfoRequest) (response *GetUserInfoResponse, err error) {
|
|
|
|
response = CreateGetUserInfoResponse()
|
|
|
|
err = c.DoAction(req, response)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) RefreshToken(req *RefreshTokenRequest) (response *RefreshTokenResponse, err error) {
|
|
|
|
response = CreateRefreshTokenResponse()
|
|
|
|
err = c.DoAction(req, response)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Client) SearchUser(req *SearchUserRequest) (response *SearchUserResponse, err error) {
|
|
|
|
response = CreateSearchUserResponse()
|
|
|
|
err = c.DoAction(req, response)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
|
|
|
client = &Client{}
|
2023-02-23 18:07:43 +08:00
|
|
|
client.ident = source
|
|
|
|
|
2023-02-21 20:46:05 +08:00
|
|
|
err = client.InitWithAccessKey(accesskey, secrect, source)
|
|
|
|
return
|
|
|
|
}
|