- yilianyun.getApiByToken
This commit is contained in:
@@ -102,7 +102,7 @@ func (c *PrinterHandler) GetVendorID() int {
|
||||
func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, machineCode, possibleToken, msgTitle, msgContent string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
globals.SugarLogger.Debugf("PrintMsg machineCode:%s", machineCode)
|
||||
if machineCode != "" {
|
||||
if err = api.YilianyunAPI.PrintMsgWithToken(machineCode, msgTitle, msgContent, possibleToken); err == nil {
|
||||
if err = getApiByToken(possibleToken).PrintMsgWithToken(machineCode, msgTitle, msgContent, possibleToken); err == nil {
|
||||
printerStatus, err = c.GetPrinterStatus(ctx, machineCode, possibleToken)
|
||||
}
|
||||
} else {
|
||||
@@ -114,7 +114,7 @@ func (c *PrinterHandler) PrintMsg(ctx *jxcontext.Context, machineCode, possibleT
|
||||
}
|
||||
|
||||
func (c *PrinterHandler) GetPrinterStatus(ctx *jxcontext.Context, machineCode, possibleToken string) (printerStatus *partner.PrinterStatus, err error) {
|
||||
status, err := api.YilianyunAPI.GetPrintStatusWithToken(machineCode, possibleToken)
|
||||
status, err := getApiByToken(possibleToken).GetPrintStatusWithToken(machineCode, possibleToken)
|
||||
if err == nil {
|
||||
printerStatus = &partner.PrinterStatus{
|
||||
PrintResult: partner.PrintResultSuccess,
|
||||
@@ -175,3 +175,10 @@ func yilianyunToken2BindResult(tokenInfo *yilianyunapi.TokenInfo) (bindResult *p
|
||||
ExpiresIn: tokenInfo.ExpiresIn,
|
||||
}
|
||||
}
|
||||
|
||||
func getApiByToken(possibleToken string) *yilianyunapi.API {
|
||||
if yilianyunapi.IsStrToken(possibleToken) {
|
||||
return api.YilianyunAPI2
|
||||
}
|
||||
return api.YilianyunAPI
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user