- page funcs PageGetSkuList, PageGetCustomSkuList and PageGetCustomCatList for ebai added.
This commit is contained in:
@@ -202,3 +202,56 @@ func (a *API) GetEleCommentList(fromTime, toTime time.Time, shopID, supplierID s
|
||||
func (a *API) GetCommentList(fromTime, toTime time.Time, shopID, supplierID string, replyStatus, level, nonEmpty int) (commentList []map[string]interface{}, err error) {
|
||||
return a.getCommentList(false, fromTime, toTime, shopID, supplierID, replyStatus, level, nonEmpty)
|
||||
}
|
||||
|
||||
func (a *API) PageGetSkuList(baiduShopID int64) (skuList []map[string]interface{}, err error) {
|
||||
pageSize := 200
|
||||
pageNo := 1
|
||||
urlTemplate := "commodity/getskulist?wid=%d&perpage=%d&upc_type=2&weight=2"
|
||||
params := []interface{}{
|
||||
baiduShopID,
|
||||
pageSize,
|
||||
}
|
||||
fixedURL := fmt.Sprintf(urlTemplate, params...)
|
||||
for {
|
||||
retVal, err2 := a.AccessStorePage(fixedURL + "&curpage=" + utils.Int2Str(pageNo))
|
||||
if err = err2; err == nil {
|
||||
for _, sku := range retVal["sku_list"].([]interface{}) {
|
||||
skuList = append(skuList, sku.(map[string]interface{}))
|
||||
}
|
||||
if len(skuList) >= int(utils.Str2Int64(utils.Interface2String(retVal["total"]))) {
|
||||
return skuList, nil
|
||||
}
|
||||
pageNo++
|
||||
} else {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) PageGetCustomSkuList(baiduShopID int64, customCatID int64) (skuList []map[string]interface{}, err error) {
|
||||
urlTemplate := "commodity/getCustomSkuList?wid=%d&custom_cat_id=%d"
|
||||
params := []interface{}{
|
||||
baiduShopID,
|
||||
customCatID,
|
||||
}
|
||||
fixedURL := fmt.Sprintf(urlTemplate, params...)
|
||||
retVal, err := a.AccessStorePage(fixedURL)
|
||||
if err == nil {
|
||||
return utils.Slice2MapSlice(retVal["sku_list"].([]interface{})), nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func (a *API) PageGetCustomCatList(baiduShopID int64) (catList []map[string]interface{}, err error) {
|
||||
urlTemplate := "commodity/GetCustomCatList?wid=%d"
|
||||
params := []interface{}{
|
||||
baiduShopID,
|
||||
}
|
||||
fixedURL := fmt.Sprintf(urlTemplate, params...)
|
||||
retVal, err := a.AccessStorePage(fixedURL)
|
||||
if err == nil {
|
||||
return utils.Slice2MapSlice(retVal["cat_list"].([]interface{})), nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -51,3 +51,33 @@ func TestGetEleCommentList(t *testing.T) {
|
||||
baseapi.SugarLogger.Debug(len(commentList))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPageGetSkuList(t *testing.T) {
|
||||
skuList, err := api.PageGetSkuList(2233065941)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if true {
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(skuList, false))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPageGetCustomSkuList(t *testing.T) {
|
||||
skuList, err := api.PageGetCustomSkuList(2267121521, 1552729500062)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if true {
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(skuList, false))
|
||||
}
|
||||
}
|
||||
|
||||
func TestPageGetCustomCatList(t *testing.T) {
|
||||
catList, err := api.PageGetCustomCatList(2233065941)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if true {
|
||||
baseapi.SugarLogger.Debug(utils.Format4Output(catList, false))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user