-
Notifications
You must be signed in to change notification settings - Fork 1
/
client_test.go
80 lines (70 loc) · 2.29 KB
/
client_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package ecopenapi
import (
"fmt"
"testing"
"github.com/yellbuy/go-ec-openapi/common"
)
func TestExecute(t *testing.T) {
// http:https://open.taobao.com/docs/api.htm?apiId=24515
client, err := NewClient(TB, &common.ClientParams{"23268761", "b17cc059ffba3f6cf0d9131359d0be2a", "62024115ddfe90c8c9cege1fefda96512336cddb9fe0f852523122485", ""})
if err != nil {
t.Fatal(err)
}
request := new(common.WaybillApplyNewRequest)
request.ShippingAddress = new(common.WaybillAddress)
// 订单数据,必填
request.TradeOrderInfoCols = make([]*common.TradeOrderInfo, 0)
res, _, err := client.GetWaybill(request)
fmt.Println(res)
if err != nil {
t.Fatal(err)
}
}
func TestDownloadProductExecute(t *testing.T) {
// 752代表走奇门委托
platId := fmt.Sprintf("%v", 2)
platformType := POLYAPI
client, err := NewClient(platformType, &common.ClientParams{"8e770a60b9684c558f40e4796a96710f", "c9cb1df531b441a8872c60ffb7f900a6", "f50d2f8b2cdf4ad8a5b6eb25bc58e4df", platId})
if err == nil {
res, _, body, err := client.DownloadProductList(0, 10, "JH_01")
if err != nil {
t.Error(err)
return
}
fmt.Println(string(body))
fmt.Println(res)
}
}
func TestDownloadOrderExecute(t *testing.T) {
platId := fmt.Sprintf("%v", 2)
platformType := POLYAPI
client, err := NewClient(platformType, &common.ClientParams{"8e770a60b9684c558f40e4796a96710f", "c9cb1df531b441a8872c60ffb7f900a6", "f50d2f8b2cdf4ad8a5b6eb25bc58e4df", platId})
if err == nil {
_, _, _, body, err := client.DownloadOrderList(0, 100, "2020-01-20 00:00:00", "2020-01-22 00:00:00", "JH_03", "JH_02", "")
if err != nil {
t.Error(err)
return
}
fmt.Println(string(body))
}
}
// func TestExecuteErrMsg(t *testing.T) {
// _, err := Execute("taobao.tbk.dg.material.optional", ecopenapi.Parameter{
// "q": "女装",
// "cat": "16,18",
// })
// if err != nil {
// t.Fatal(err)
// }
// }
// func TestExecuteCache(t *testing.T) {
// res, err := ExecuteCache("taobao.tbk.item.get", ecopenapi.Parameter{
// "fields": "num_iid,title,pict_url,small_images,reserve_price,zk_final_price,user_type,provcity,item_url,seller_id,volume,nick",
// "q": "女装",
// "cat": "16,18",
// })
// if err != nil {
// t.Fatal(err)
// }
// t.Logf("%+v\n", res)
// }