83 lines
1.9 KiB
Go
83 lines
1.9 KiB
Go
package mtwmapi
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"git.rosy.net.cn/baseapi"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
var (
|
|
api *API
|
|
sugarLogger *zap.SugaredLogger
|
|
)
|
|
|
|
func init() {
|
|
logger, _ := zap.NewDevelopment()
|
|
sugarLogger = logger.Sugar()
|
|
baseapi.Init(sugarLogger)
|
|
|
|
// 菜市
|
|
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
|
|
|
// 果园
|
|
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
|
|
|
//商超
|
|
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_qLqTxHqWzajT7ep19a1Duw") //token_n4TwqCntWWuvQwAawzxC0w
|
|
cookieStr := `
|
|
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
|
`
|
|
api.SetCookieWithStr(cookieStr)
|
|
}
|
|
|
|
func TestAccessAPI(t *testing.T) {
|
|
result, err := api.AccessAPI("poi/getids", true, nil)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestGetOAuthCode(t *testing.T) {
|
|
result, err := api.GetOAuthCode("17395411")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(utils.Format4Output(result, false))
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestPreparationMealComplete(t *testing.T) {
|
|
api.PreparationMealComplete(900658760944919842)
|
|
}
|
|
|
|
func TestGetAccessToken(t *testing.T) {
|
|
result, err := api.GetAccessToken("code_ra0oUBjsRwRf0f5m0wJB9g")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(utils.Format4Output(result, false))
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestGetAccessToken2(t *testing.T) {
|
|
result, err := api.GetAccessToken2("18048546") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(utils.Format4Output(result.AccessToken, false))
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|
|
|
|
func TestRefreshAccessToken(t *testing.T) {
|
|
result, err := api.RefreshAccessToken("refresh_token_jajfdTMzYvB28v-3q4RFgQ") //token_qbAyE3ajWYT8ecwoI-FMjw
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
fmt.Println(utils.Format4Output(result, false))
|
|
t.Log(utils.Format4Output(result, false))
|
|
}
|