2024-06-15 12:37:11 +08:00
|
|
|
|
package t3_union
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
|
|
|
|
|
2024-07-29 23:52:23 +08:00
|
|
|
|
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
2024-06-15 12:37:11 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// AuthConfig api鉴权参数
|
|
|
|
|
|
type AuthConfig struct {
|
2024-06-15 21:01:51 +08:00
|
|
|
|
AppKey string // 应用key
|
|
|
|
|
|
AppSecret string // 应用秘钥
|
|
|
|
|
|
SupplierID string // 供应商ID(账号)
|
2024-06-15 12:37:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 连接第三方平台的client
|
|
|
|
|
|
type Client struct {
|
|
|
|
|
|
log logx.Logger
|
|
|
|
|
|
authConfig AuthConfig
|
|
|
|
|
|
client.HttpClient
|
|
|
|
|
|
headers map[string]string
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewApiClient(log logx.Logger, conf AuthConfig) T3UnionApi {
|
|
|
|
|
|
clt := newClient(log, conf)
|
|
|
|
|
|
return newT3UnionApiImpl(log, clt)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func newClient(log logx.Logger, conf AuthConfig) *Client {
|
|
|
|
|
|
return &Client{
|
|
|
|
|
|
log: log,
|
|
|
|
|
|
authConfig: conf,
|
|
|
|
|
|
HttpClient: client.NewHttpClient(log),
|
|
|
|
|
|
headers: map[string]string{
|
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|