package mtwmapi

import (
	"encoding/json"
	"fmt"
	"github.com/go-redis/redis"
	"testing"
	"time"
)

const (
	MTIMPushUrl = "wss://wpush.meituan.com/websocket"
	TestAppID   = "589_WMOPEN"
	TestToken   = "wo589i4VsZHFH2fh4uVsr6Dtc3k6vG8Xu0vxpreBQFy6QAvg"

	TestMTIM589  = "wss://wpush.meituan.com/websocket/589_WMOPEN/wo589i4VsZHFH2fh4uVsr6Dtc3k6vG8Xu0vxpreBQFy6QAvg"
	TestMTIM4123 = "wss://wpush.meituan.com/websocket/4123_WMOPEN/wo4123aAVXDUkZDYucMoTDAZgsMzjrR_porZcLGv2GmWRNOiw"
	TestWssUrl   = "wss://www.jxc4.com:443/v2/event/TestWebsocket"
	TestWssUrl1  = "wss://www-jxgy.jxc4.com:443/v2/im/StartWebSocket"
)

var rdb = redis.NewClient(&redis.Options{
	//Addr: "www.jxc4.com:6379",
	//Password: "",
	Addr:     "127.0.0.1:6379",
	Password: "123456",
	DB:       0,
})

func TestSendMsg(t *testing.T) {
	data := PushContentReq{
		AppID:      589,
		AppPoiCode: "8694203",
		MsgID:      20230615,
		MsgContent: "QYEyt4edHFiW0Fg0iKqeSKZ+Dab9zKJWSLwQuE38J+XL/1BUIwkqy3sf3E9lOK77",
		MsgSource:  1,
		MsgType:    1,
		Cts:        int(time.Now().Unix()),
		OpenUserID: 12248014636,
	}
	dataMar, err := json.Marshal(data)
	fmt.Println(string(dataMar))
	ret, err := api.MsgSend(string(dataMar))
	fmt.Println(ret, err)
}

func TestMashal(t *testing.T) {
	var pushContent = PushContentReq{}
	str := "{\"app_id\":589,\"app_poi_code\":\"8694203\",\"msg_id\":20230615,\"msg_content\":\"3/ SR3dQEf/G7nBfw1K3UN6UaYlCFaxKmbS76MPuJ9w=\",\"msg_source\":1,\"msg_type\":1,\"cts\":1686902500,\"open_user_id\":12248014636,\"order_id\":0,\"group_id\":0,\"app_spu_codes\":\"\"}"
	if err := json.Unmarshal([]byte(str), &pushContent); err == nil {
		fmt.Println(pushContent)
	}
}
