代码拉取完成,页面将自动刷新
package api
import (
"fmt"
"strings"
)
import (
"gitee.com/changeden/jd-union-go-sdk/common"
)
type apiConfig struct {
appKey string
appSecret string
serverAddress string
}
func NewApiConfig(appKey, appSecret string) *apiConfig {
inst := &apiConfig{
serverAddress: common.DefaultServer,
}
return inst.SetAppKey(appKey).SetAppSecret(appSecret)
}
func checkAppInfo(req string, msg string) (res string, err error) {
res = strings.TrimSpace(req)
if len(res) == 0 {
err = fmt.Errorf(msg)
}
return res, err
}
func checkAppKey(appKey string) (res string, err error) {
return checkAppInfo(appKey, "AppKey不能为空")
}
func checkAppSecret(appSecret string) (res string, err error) {
return checkAppInfo(appSecret, "AppSecret不能为空")
}
func (c *apiConfig) SetAppKey(appKey string) *apiConfig {
appKey, _ = checkAppKey(appKey)
c.appKey = appKey
return c
}
func (c *apiConfig) SetAppSecret(appSecret string) *apiConfig {
appSecret, _ = checkAppKey(appSecret)
c.appSecret = appSecret
return c
}
func (c *apiConfig) Build() (inst *api, err error) {
_, err = checkAppKey(c.appKey)
if err != nil {
return
}
_, err = checkAppSecret(c.appSecret)
if err != nil {
return
}
inst = newApi(c)
return
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。