haiwai-common-sdk-go/services/sso/client.go

64 lines
1.4 KiB
Go

package sso
import (
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
)
const (
VERSION = "2020-08-07"
)
var HOST = requests.Host{
Default: "sso",
Func: func(s string, area string) string {
host := map[string]string{
requests.RELEASE: "sso.gaore.com.hk",
requests.PRE: "sso.gaore.com.hk",
requests.TEST: "sso.gaore.com.hk",
}
if s, ok := host[s]; ok {
return s
} else {
return "sso.gaore.com.hk"
}
},
}
type Client struct {
sdk.Client
ident string
}
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{}
client.ident = source
err = client.InitWithAccessKey(accesskey, secrect, source)
return
}