39 lines
824 B
Go
39 lines
824 B
Go
|
|
package meituan
|
||
|
|
|
||
|
|
import (
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
|
||
|
|
"repository.lenntc.com/lenntc/third-platform-sdk/client"
|
||
|
|
)
|
||
|
|
|
||
|
|
// AuthConfig api鉴权参数
|
||
|
|
type AuthConfig struct {
|
||
|
|
AppKey string // 应用key
|
||
|
|
AppSecret string // 应用秘钥
|
||
|
|
}
|
||
|
|
|
||
|
|
// 连接第三方平台的client
|
||
|
|
type Client struct {
|
||
|
|
log logx.Logger
|
||
|
|
authConfig AuthConfig
|
||
|
|
client.HttpClient
|
||
|
|
headers map[string]string
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewApiClient(log logx.Logger, conf AuthConfig) MeituanApi {
|
||
|
|
clt := newClient(log, conf)
|
||
|
|
sign := newSign(conf.AppKey, conf.AppSecret)
|
||
|
|
return newMeituanApiImpl(log, clt, sign)
|
||
|
|
}
|
||
|
|
|
||
|
|
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",
|
||
|
|
},
|
||
|
|
}
|
||
|
|
}
|