- 添加几个打印机的清除队列与易联云的播放文本声音操作

This commit is contained in:
gazebo
2019-07-19 17:06:37 +08:00
parent 0ecc8b8727
commit 594ed19bf3
3 changed files with 26 additions and 6 deletions

View File

@@ -247,9 +247,13 @@ func IsStrToken(possibleToken string) bool {
return len(possibleToken) >= len("d65578a6fa414d738e0c44f85ac4b950")
}
func (a *API) CancelAll(machineCode string) (err error) {
func (a *API) CancelAll(machineCode, token string) (err error) {
_, err = a.AccessAPI("printer/cancelall", map[string]interface{}{
"machine_code": machineCode,
}, "")
}, token)
return err
}
func (a *API) PlayText(machineCode, orderID, text, token string) (err error) {
return a.printMsg(machineCode, orderID, fmt.Sprintf("<audio>%s,9,0</audio>", strings.Replace(text, ",", ".", -1)), token)
}

View File

@@ -21,7 +21,7 @@ func init() {
// 自有应用
api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
api.SetToken("b43201fe472c4672880890f73d97aab0")
api.SetToken("7884617f9eeb4c28933569f94a95b5c3")
// 开放应用
// api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
@@ -37,11 +37,11 @@ func handleError(t *testing.T, err error) {
func TestRetrieveToken(t *testing.T) {
token, err := api.RetrieveToken()
handleError(t, err)
baseapi.SugarLogger.Debug(utils.Format4Output(token, false))
baseapi.SugarLogger.Debug(utils.Format4Output(token, true))
}
func TestAddPrinter(t *testing.T) {
err := api.AddPrinter("4004611945", "57kywtiiyqce", "测试打印机1")
err := api.AddPrinter("4004617180", "381870509796", "测试打印机1")
handleError(t, err)
}
@@ -81,6 +81,11 @@ func TestGetPrinterToken(t *testing.T) {
}
func TestCancelAll(t *testing.T) {
err := api.CancelAll("4004617683")
err := api.CancelAll("4004617242", "03e4ec4d65264bca850c8ad87dd8fc21")
handleError(t, err)
}
func TestPlayText(t *testing.T) {
err := api.PlayText("4004617180", utils.GetUUID(), "大家好", "")
handleError(t, err)
}

View File

@@ -144,3 +144,14 @@ func (a *API) GetPrintStatus(deviceID, deviceSecret, dataID string) (isPrinted b
}
return false, err
}
func (a *API) EmptyPrintQueue(deviceID, deviceSecret string) (status int, err error) {
retData, err := a.AccessAPI("emptyprintqueue", map[string]interface{}{
"deviceid": deviceID,
"devicesecret": deviceSecret,
}, true)
if err == nil {
return int(utils.Str2Int64(utils.Interface2String(retData["status"]))), nil
}
return 0, err
}