+ 新增易联云CancelAll

This commit is contained in:
gazebo
2019-07-18 18:36:52 +08:00
parent 061e906d17
commit e2c3cb8a29
2 changed files with 18 additions and 6 deletions

View File

@@ -246,3 +246,10 @@ func (a *API) GetPrinterToken(machineCode, qrKey string) (tokenInfo *TokenInfo,
func IsStrToken(possibleToken string) bool {
return len(possibleToken) >= len("d65578a6fa414d738e0c44f85ac4b950")
}
func (a *API) CancelAll(machineCode string) (err error) {
_, err = a.AccessAPI("printer/cancelall", map[string]interface{}{
"machine_code": machineCode,
}, "")
return err
}

View File

@@ -20,11 +20,11 @@ func init() {
baseapi.Init(sugarLogger)
// 自有应用
// api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
// api.SetToken("968b52db8a0a40d184d67578aa4888f8")
api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
api.SetToken("b43201fe472c4672880890f73d97aab0")
// 开放应用
api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
// api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
}
func handleError(t *testing.T, err error) {
@@ -41,12 +41,12 @@ func TestRetrieveToken(t *testing.T) {
}
func TestAddPrinter(t *testing.T) {
err := api.AddPrinter("4004600675", "fem2ukwvduik", "测试打印机1")
err := api.AddPrinter("4004611945", "57kywtiiyqce", "测试打印机1")
handleError(t, err)
}
func TestDeletePrinter(t *testing.T) {
err := api.DeletePrinter("4004600675")
err := api.DeletePrinter("4004611945")
handleError(t, err)
}
@@ -63,7 +63,7 @@ func TestPrintMsgWithToken(t *testing.T) {
}
func TestGetPrintStatus(t *testing.T) {
state, err := api.GetPrintStatus("4004600675")
state, err := api.GetPrintStatus("4004617683")
handleError(t, err)
baseapi.SugarLogger.Debug(state)
}
@@ -79,3 +79,8 @@ func TestGetPrinterToken(t *testing.T) {
handleError(t, err)
baseapi.SugarLogger.Debug(TokenInfo)
}
func TestCancelAll(t *testing.T) {
err := api.CancelAll("4004617683")
handleError(t, err)
}