third-platform-sdk/platform/eleme-union/client.go

56 lines
1.3 KiB
Go
Raw Permalink Normal View History

2024-04-30 17:57:27 +08:00
package eleme_union
import (
"net/http"
"github.com/zeromicro/go-zero/core/logx"
2024-07-29 23:52:23 +08:00
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk"
"repository.lenntc.com/lenntc/third-platform-sdk/sdk/topsdk/defaultability"
"repository.lenntc.com/lenntc/third-platform-sdk/util"
2024-04-30 17:57:27 +08:00
)
// AuthConfig api鉴权参数
type AuthConfig struct {
2024-05-04 16:57:40 +08:00
AppKey string // 应用key
AppSecret string // 应用秘钥
2024-04-30 17:57:27 +08:00
}
2024-05-04 16:57:40 +08:00
// 连接第三方平台的client
2024-04-30 17:57:27 +08:00
type Client struct {
2024-05-04 16:57:40 +08:00
topClient *topsdk.TopClient
abilityClient *defaultability.Defaultability
log logx.Logger
authConfig AuthConfig
2024-04-30 17:57:27 +08:00
}
2024-05-04 16:57:40 +08:00
func NewApiClient(log logx.Logger, conf AuthConfig) ElemeUnionApi {
clt := newClient(log, conf)
return newElemeUnionApiImpl(log, clt)
2024-04-30 17:57:27 +08:00
}
2024-05-04 16:57:40 +08:00
func newClient(log logx.Logger, conf AuthConfig) *Client {
tc := topsdk.NewDefaultTopClient(conf.AppKey, conf.AppSecret, "https://eco.taobao.com/router/rest", 20000, 20000)
2024-05-04 16:57:40 +08:00
return &Client{
topClient: &tc,
abilityClient: defaultability.NewDefaultability(&tc),
log: log,
authConfig: conf,
}
2024-04-30 17:57:27 +08:00
}
// todo:: 请求api的频率限制
func (c *Client) apiRateLimit() {
}
// todo:: 检查api请求频率限制
func (c *Client) checkRateLimit(header *http.Header) error {
return nil
}
// todo:: 检查http响应错误
func (c *Client) checkResponseError(r *util.Response) error {
return nil
}