You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/service/taobao/client.go

53 lines
1.1 KiB

2 years ago
package taobao
import (
2 years ago
"github.com/dtapps/go-library/utils/golog"
"github.com/dtapps/go-library/utils/gorequest"
2 years ago
)
// ClientConfig 实例配置
type ClientConfig struct {
AppKey string // 应用Key
AppSecret string // 密钥
AdzoneId int64 // mm_xxx_xxx_xxx的第三位
2 years ago
}
// Client 实例
2 years ago
type Client struct {
requestClient *gorequest.App // 请求服务
config struct {
appKey string // 应用Key
appSecret string // 密钥
adzoneId int64 // mm_xxx_xxx_xxx的第三位
}
1 year ago
zap struct {
status bool // 状态
client *golog.ApiZapLog // 日志服务
}
2 years ago
}
// NewClient 创建实例化
func NewClient(config *ClientConfig) (*Client, error) {
2 years ago
c := &Client{}
2 years ago
c.config.appKey = config.AppKey
c.config.appSecret = config.AppSecret
c.config.adzoneId = config.AdzoneId
2 years ago
c.requestClient = gorequest.NewHttp()
c.requestClient.Uri = apiUrl
2 years ago
return c, nil
}
type ErrResp struct {
ErrorResponse struct {
Code int `json:"code"`
Msg string `json:"msg"`
SubCode string `json:"sub_code"`
SubMsg string `json:"sub_msg"`
RequestId string `json:"request_id"`
} `json:"error_response"`
}