1
This commit is contained in:
@@ -27,21 +27,25 @@ type API struct {
|
||||
|
||||
func New(appKey, appSecret, accessToken string) *API {
|
||||
var access *doudian_sdk.AccessToken
|
||||
doudian_sdk.GlobalConfig.AppKey = appKey
|
||||
doudian_sdk.GlobalConfig.AppSecret = appSecret
|
||||
if accessToken != "" {
|
||||
if err := json.Unmarshal([]byte(accessToken), &access); err != nil {
|
||||
globals.SugarLogger.Debug("accessToken init err :", err)
|
||||
return nil
|
||||
}
|
||||
return &API{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
accessToken: access.AccessToken,
|
||||
refreshToken: access.RefreshToken,
|
||||
expiresIn: access.ExpiresIn,
|
||||
accessTokenObj: access,
|
||||
}
|
||||
}
|
||||
doudian_sdk.GlobalConfig.AppKey = appKey
|
||||
doudian_sdk.GlobalConfig.AppSecret = appSecret
|
||||
return &API{
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
accessToken: access.AccessToken,
|
||||
refreshToken: access.RefreshToken,
|
||||
expiresIn: access.ExpiresIn,
|
||||
accessTokenObj: access,
|
||||
appKey: appKey,
|
||||
appSecret: appSecret,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +139,11 @@ func (a *API) SetAccessToken(token string) {
|
||||
return
|
||||
}
|
||||
|
||||
a.accessTokenObj = access
|
||||
if access.ExpiresIn > time.Now().Unix() {
|
||||
a.accessTokenObj = access
|
||||
} else {
|
||||
a.RefreshToken()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
product_listV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/response"
|
||||
product_setOffline_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_setOffline/request"
|
||||
shop_getShopCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getShopCategory/request"
|
||||
shop_getStoreFreight_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getStoreFreight/request"
|
||||
sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request"
|
||||
sku_syncStockBatch_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStockBatch/request"
|
||||
)
|
||||
@@ -207,3 +208,17 @@ func (a *API) GetSkuDetailList(param *product_listV2_request.ProductListV2Param)
|
||||
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
// GetStoreFreight 获取运费模板
|
||||
func (a *API) GetStoreFreight(storeId int64) (int64, error) {
|
||||
request := shop_getStoreFreight_request.New()
|
||||
request.Param.StoreId = storeId
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
}
|
||||
return result.Data.StoreFreights[0].FreightId, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user