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

55 lines
1.2 KiB
Go
Raw 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-05-01 14:05:18 +08:00
"gitee.com/chengdu-lenntc/third-platform-sdk/client"
"gitee.com/chengdu-lenntc/third-platform-sdk/util"
2024-04-30 17:57:27 +08:00
)
// AuthConfig api鉴权参数
type AuthConfig struct {
}
// todo:: 连接第三方平台的client
type Client struct {
client.ThirdClient
log logx.Logger
authConfig AuthConfig
}
func NewClient(log logx.Logger, conf AuthConfig) *Client {
// todo:: 请求第三方平台的配置参数
return &Client{
ThirdClient: client.NewThirdClient(log),
log: log,
authConfig: conf,
}
}
// todo:: DoHttp 发起http请求
func (c *Client) DoHttp(method string, url string, req *client.HttpRequest, resp *client.HttpResponse) error {
// todo:: api请求频率限制
c.apiRateLimit()
// 发起请求
err := c.ThirdClient.DoHttp(method, url, req, resp)
return err
}
// 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
}