- ugc api of ebai

This commit is contained in:
gazebo
2019-02-18 16:39:03 +08:00
parent ba576e8202
commit fca8851475
2 changed files with 59 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
package ebaiapi
import (
"time"
"git.rosy.net.cn/baseapi/utils"
)
func (a *API) OrderRatesGet(shopID string, baiduShopID int64, startTime, endTime time.Time, replyStatus int) (commentList []map[string]interface{}, err error) {
params := a.genShopIDParams(shopID, baiduShopID)
if !utils.IsTimeZero(startTime) {
params["startTime"] = startTime
}
if !utils.IsTimeZero(endTime) {
params["endTime"] = endTime
}
if replyStatus >= 0 {
params["replyStatus"] = replyStatus
}
pageNo := 1
for {
params["page"] = pageNo
result, err := a.AccessAPI("ugc.orderrates.get", params)
if err != nil {
return nil, err
}
data := result.Data.(map[string]interface{})
commentList = append(commentList, utils.Slice2MapSlice(data["comment_list"].([]interface{}))...)
total := int(utils.MustInterface2Int64(data["total"]))
if len(commentList) >= total {
break
}
}
return commentList, err
}
func (a *API) OrderRatesReply(shopID string, baiduShopID int64, commentID, content string) (err error) {
params := a.genShopIDParams(shopID, baiduShopID)
params["comment_id"] = commentID
params["content"] = content
_, err = a.AccessAPI("ugc.reply", params)
return err
}

View File

@@ -0,0 +1,16 @@
package ebaiapi
import (
"testing"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
)
func TestOrderRatesGet(t *testing.T) {
commentList, err := api.OrderRatesGet("100119", 0, utils.DefaultTimeValue, utils.DefaultTimeValue, -1)
if err != nil {
t.Fatal(err)
}
baseapi.SugarLogger.Debug(utils.Format4Output(commentList, false))
}