This commit is contained in:
邹宗楠
2024-01-16 16:24:32 +08:00
parent 2fd23aff1f
commit 2182c1ce93
7 changed files with 61 additions and 57 deletions

View File

@@ -237,12 +237,18 @@ func (a *API) GetPrintStatusWithToken(machineCode, token string) (state int, err
return a.getPrintStatus(machineCode, token)
}
func (a *API) GetPrinterToken(machineCode, qrKey string) (tokenInfo *TokenInfo, err error) {
result, err := a.AccessAPI(scanCodemodelApiPath, map[string]interface{}{
func (a *API) GetPrinterToken(machineCode, qrKey, msign string) (tokenInfo *TokenInfo, err error) {
parameter := map[string]interface{}{
"machine_code": machineCode,
"qr_key": qrKey,
"scope": "all",
}, "")
}
if qrKey != "" {
parameter["qr_key"] = qrKey
} else if msign != "" {
parameter["msign"] = msign
}
result, err := a.AccessAPI(scanCodemodelApiPath, parameter, "")
if err == nil {
err = utils.Map2StructByJson(result, &tokenInfo, false)
}

View File

@@ -1,7 +1,9 @@
package yilianyunapi
import (
"fmt"
"testing"
"time"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
@@ -20,11 +22,11 @@ func init() {
baseapi.Init(sugarLogger)
// 自有应用
api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
api.SetToken("07e5895c70114395a285ae20119d83b1")
//api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
//api.SetToken("283f27f7dfbe4379b2db9b8f11e61b9c")
// 开放应用
//api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
}
func handleError(t *testing.T, err error) {
@@ -54,13 +56,14 @@ func TestDeletePrinter(t *testing.T) {
func TestPrintMsg(t *testing.T) {
// 4004606481
err := api.PrintMsg("4004615546", utils.GetUUID(), "<FS2>饿百取货码</FS2>")
err := api.PrintMsg("4004797135", utils.GetUUID(), "<FS2>饿百取货码</FS2>")
handleError(t, err)
}
func TestPrintMsgWithToken(t *testing.T) {
// 4004606481
err := api.PrintMsgWithToken("4004600675", utils.GetUUID(), "<FS2>饿百取货码</FS2>", "b1a36aa8de5647d2b08af49db11a9c9d")
//err := api.PrintMsgWithToken("4004555254", utils.GetUUID(), "<FS2>饿百取货码</FS2>", "0a8255eeb42445f7b8db42b1fc60ce87")
err := api.PrintMsgWithToken("4004797135", utils.GetUUID(), "<FS2>饿百取货码</FS2>", "179770218366")
handleError(t, err)
}
@@ -77,7 +80,7 @@ func TestGetPrintStatusWithToken(t *testing.T) {
}
func TestGetPrinterToken(t *testing.T) {
TokenInfo, err := api.GetPrinterToken("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
TokenInfo, err := api.GetPrinterToken("4004797135", "179770218366", "")
handleError(t, err)
baseapi.SugarLogger.Debug(TokenInfo)
}
@@ -104,6 +107,10 @@ func TestGetOrderPagingList(t *testing.T) {
t.Log(utils.Format4Output(result, true))
}
func TestName(t *testing.T) {
fmt.Println(time.Now().Add(time.Duration(2592000) * time.Second).Unix())
}
func TestSetSound(t *testing.T) {
err := api.SetSound("4004617180", "2")
handleError(t, err)