易联云打印机添加GetOrderPagingList
This commit is contained in:
@@ -56,6 +56,15 @@ type TokenInfo struct {
|
|||||||
MachineCode string `json:"machine_code"`
|
MachineCode string `json:"machine_code"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PrinterOrderResult struct {
|
||||||
|
Content string `json:"content"`
|
||||||
|
ID string `json:"id"`
|
||||||
|
OriginID string `json:"origin_id"`
|
||||||
|
PrintTime string `json:"print_time"`
|
||||||
|
ReceivingTime string `json:"receiving_time"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
}
|
||||||
|
|
||||||
func New(clientID, clientSecret string, config ...*platformapi.APIConfig) *API {
|
func New(clientID, clientSecret string, config ...*platformapi.APIConfig) *API {
|
||||||
curConfig := platformapi.DefAPIConfig
|
curConfig := platformapi.DefAPIConfig
|
||||||
if len(config) > 0 {
|
if len(config) > 0 {
|
||||||
@@ -256,3 +265,16 @@ func (a *API) CancelAll(machineCode, token string) (err error) {
|
|||||||
func (a *API) PlayText(machineCode, orderID, text, token string) (err error) {
|
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)
|
return a.printMsg(machineCode, orderID, fmt.Sprintf("<audio>%s,9,0</audio>", strings.Replace(text, ",", ".", -1)), token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pageIndex从1开始,pageSize最大为100
|
||||||
|
func (a *API) GetOrderPagingList(machineCode, token string, pageIndex, pageSize int) (orderResultList []*PrinterOrderResult, err error) {
|
||||||
|
result, err := a.AccessAPI("printer/getorderpaginglist", map[string]interface{}{
|
||||||
|
"machine_code": machineCode,
|
||||||
|
"page_index": pageIndex,
|
||||||
|
"page_size": pageSize,
|
||||||
|
}, token)
|
||||||
|
if err != nil {
|
||||||
|
err = utils.Map2StructByJson(result, &orderResultList, false)
|
||||||
|
}
|
||||||
|
return orderResultList, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ func init() {
|
|||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
|
|
||||||
// 自有应用
|
// 自有应用
|
||||||
// api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
|
api = New("1039586024", "4885d07c2997b661102e4b6099c0bf3b")
|
||||||
// api.SetToken("7884617f9eeb4c28933569f94a95b5c3")
|
api.SetToken("3a38e3cec7974b459a6f0a381c9b0312")
|
||||||
|
|
||||||
// 开放应用
|
// 开放应用
|
||||||
api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
|
// api = New("1098307169", "d5eedb40c99e6691b1ca2ba82a363d6a")
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleError(t *testing.T, err error) {
|
func handleError(t *testing.T, err error) {
|
||||||
@@ -97,3 +97,9 @@ func TestRefreshToken(t *testing.T) {
|
|||||||
handleError(t, err)
|
handleError(t, err)
|
||||||
t.Log(utils.Format4Output(tokenInfo, true))
|
t.Log(utils.Format4Output(tokenInfo, true))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetOrderPagingList(t *testing.T) {
|
||||||
|
result, err := api.GetOrderPagingList("4004613792", "", 1, 50)
|
||||||
|
handleError(t, err)
|
||||||
|
t.Log(utils.Format4Output(result, true))
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user