Documentation ¶
Overview ¶
Package feie is the feie client.
Index ¶
- Variables
- type AsyncPrinterResultReq
- type AsyncPrinterResultResp
- type Client
- func (c *Client) AsyncPrinterResult(ctx context.Context, req *AsyncPrinterResultReq) (resp *AsyncPrinterResultResp, err error)
- func (c *Client) OpenDelPrinterSQS(ctx context.Context, req *DelPrinterSQSReq) (resp *DelPrinterSQSResp, err error)
- func (c *Client) OpenPrintLabelMsg(ctx context.Context, req *PrintLabelMsgReq) (resp *PrintLabelMsgResp, err error)
- func (c *Client) OpenPrintMsg(ctx context.Context, req *PrintMsgReq) (resp *PrintMsgResp, err error)
- func (c *Client) OpenPrinterAddList(ctx context.Context, req *PrinterAddReq) (resp *PrinterAddResp, err error)
- func (c *Client) OpenPrinterDelList(ctx context.Context, req *PrinterDelReq) (resp *PrinterDelResp, err error)
- func (c *Client) OpenPrinterEdit(ctx context.Context, req *PrinterEditReq) (resp *PrinterEditResp, err error)
- func (c *Client) OpenQueryOrderInfoByDate(ctx context.Context, req *QueryOrderInfoByDateReq) (resp *QueryOrderInfoByDateResp, err error)
- func (c *Client) OpenQueryOrderState(ctx context.Context, req *QueryOrderStateReq) (resp *QueryOrderStateResp, err error)
- func (c *Client) OpenQueryPrinterStatus(ctx context.Context, req *QueryPrinterStatusReq) (resp *QueryPrinterStatusResp, err error)
- func (c *Client) Reset()
- func (c *Client) Response() *protocol.Response
- func (c *Client) SetLogger(logger hlog.FullLogger)
- func (c *Client) SetRequest(request *protocol.Request)
- func (c *Client) SetUserKey(ukey string)
- type DelPrinterSQSReq
- type DelPrinterSQSResp
- type Level
- type Logger
- type Option
- func WithDataType(dataType gocrypto.Encode) Option
- func WithGateway(gateway string) Option
- func WithHashType(hashType gocrypto.Hash) Option
- func WithLevel(level Level) Option
- func WithLogPath(logPath string) Option
- func WithPublicKey(publicKey string) Option
- func WithTimeOut(timeout time.Duration) Option
- func WithUser(user string) Option
- func WithUserAgent(userAgent []byte) Option
- func WithUserKey(uKey string) Option
- type PrintLabelMsgReq
- type PrintLabelMsgResp
- type PrintMsgReq
- type PrintMsgResp
- type PrinterAddReq
- type PrinterAddResp
- type PrinterDelReq
- type PrinterDelResp
- type PrinterEditReq
- type PrinterEditResp
- type PrinterRespData
- type QueryOrderInfoByDateData
- type QueryOrderInfoByDateReq
- type QueryOrderInfoByDateResp
- type QueryOrderStateReq
- type QueryOrderStateResp
- type QueryPrinterStatusReq
- type QueryPrinterStatusResp
Constants ¶
This section is empty.
Variables ¶
var ( // UserField 飞鹅云后台注册用户名。 UserField = "user" // SysTimeField 当前UNIX时间戳,10位,精确到秒。 SysTimeField = "stime" // SigField 对参数 user+UKEY+stime拼接后(+号表示连接符)进行SHA1加密得到签名,加密后签名值为40位小写字符串。 SigField = "sig" // APINameField 请求的接口名称:Open_printMsg APINameField = "apiname" // ExpiredField 订单失效UNIX时间戳,10位,精确到秒,打印时超过该时间该订单将抛弃不打印,取值范围为:当前时间<订单失效时间≤24小时后。 ExpiredField = "expired" // BackURLField 必须先在管理后台设置,回调数据格式详见《订单状态回调》 BackURLField = "backurl" // DebugField debug=1返回非json格式的数据。仅测试时候使用。 DebugField = "debug" // SNListField 打印机编号,多台打印机请用减号“-”连接起来。 SNListField = "snlist" // PrinterContentField 打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100台。 PrinterContentField = "printerContent" // SNField 打印机编号 SNField = "sn" // ContentField 打印内容,不能超过5000字节 ContentField = "content" // TimesField 打印次数,默认为1。 TimesField = "times" // ImgField 图片二进制数据,需配合<IMG>标签使用,最佳效果为不大于224px的正方形(宽高都为8的倍数)黑白图,支持jpg、png、bmp,不能超过10K ImgField = "img" // NameField 打印机备注名称 NameField = "name" // PhoneNumField 打印机流量卡号码 PhoneNumField = "phoneNum" // OrderIDField 订单ID,由接口Open_printMsg返回。 OrderIDField = "orderid" // DateField 查询日期,格式为:2016-08-08 DateField = "date" )
Functions ¶
This section is empty.
Types ¶
type AsyncPrinterResultReq ¶
type AsyncPrinterResultReq struct { OrderID string `json:"orderId" description:"订单ID,由接口Open_printMsg返回。"` Sign string `json:"sign" description:"签名,详见签名算法。SHA256WithRSA验证签名值"` Status int `json:"status" description:"订单状态"` Stime int `json:"stime" description:"订单状态变更UNIX时间戳,10位,精确到秒。"` }
AsyncPrinterResultReq is the request body for querying the result of an asynchronous request.
type AsyncPrinterResultResp ¶
type AsyncPrinterResultResp struct { VerifySign bool `json:"verifySign" description:"验签结果"` OrderID string `json:"orderId" description:"订单ID,由接口Open_printMsg返回。"` Status int `json:"status" description:"订单状态"` Stime int `json:"stime" description:"订单状态变更UNIX时间戳,10位,精确到秒。"` }
AsyncPrinterResultResp is the response body for querying the result of an asynchronous request.
type Client ¶ added in v1.2.0
type Client struct {
// contains filtered or unexported fields
}
Client is the feie client.
func (*Client) AsyncPrinterResult ¶ added in v1.2.0
func (c *Client) AsyncPrinterResult(ctx context.Context, req *AsyncPrinterResultReq) (resp *AsyncPrinterResultResp, err error)
AsyncPrinterResult 异步打印结果 接口提供方式 回调接口统一使用https post方式,contentType 为“application/x-www-form-urlencoded”。 需要服务商在开发者后台配置回调地址白名单,并在提交打印订单时提交回调地址。 回调地址为服务商提供的接口地址,服务商需要在接口中处理打印结果。 回调参数:
| - orderId 订单ID,由接口Open_printMsg返回。 | - status 打印状态,1:打印成功,1:打印失败。 | - stime 订单状态变更UNIX时间戳,10位,精确到秒。 | - sign 数字签名
数字签名验证说明 2.1.1 获取待验证签名字符串 获取所有飞鹅云开放平台的 post 内容,不包括字节类型参数,如文件、字节流,剔除 sign 字段,剔除值为空的参数;按照第一个字符的键值 ASCII 码递增排序(字母升序排序),如果遇到相同字符则按照第二个字符的键值 ASCII 码递增排序,以此类推;将排序后的参数与其对应值,组合成 参数=参数值 的格式,并且把这些参数用 & 字符连接起来,此时生成的字符串为待验签字段为,如: orderId:816501678_20160919184316_1419533539 status:1 stime:1625194910 则待验签字段为:orderId=816501678_20160919184316_1419533539&status=1&stime=1625194910 2.1.2 取出签名值sign NW1BNm4oTxyyPBdXHPwuI5gjh2onvyHavrSLnrPAGCp4TnoX1IJTwwX+tXFybdi+bo+OM/1FoIeU4H70fPw0m/z/Fz6EYdDpsBbUZFbbUdj9OJrzY/sdnArkynnYoVkLGOwV0DM1WvCn3iqlskD5O1K6POFDc0006xMK+d3/SSNegSUPMuIvuXG6VKGiDN0rO9hOdXFjrp0b1Td14ofPXKibmGXV7XikC2suU45nWmCBC8lKzhazCiInS/tkRAF8WsS2AiACeMvmonyrT/LZWbsfrd9k6M+kATCOz7EjPEd9z+W8N8Rtbur1m3MZdjAshMfduqQEpRU+w7U6R4sxQA== 2.1.3 将签名参数(sign)使用 base64 解码为签名值字节码串 2.1.4 使用飞鹅云公钥、待验证签名字符串、签名值字节码串进行SHA256WithRSA验证签名值是否正确。 3 返回示例: 注:开发者接收后需立即返回SUCCESS,如5秒内不返回或返回数据格式错误,平台会重新推送。 `SUCCESS` see: http://help.feieyun.com/document.php
func (*Client) OpenDelPrinterSQS ¶ added in v1.2.0
func (c *Client) OpenDelPrinterSQS(ctx context.Context, req *DelPrinterSQSReq) (resp *DelPrinterSQSResp, err error)
OpenDelPrinterSQS 清空待打印队列 see: http://help.feieyun.com/document.php
func (*Client) OpenPrintLabelMsg ¶ added in v1.2.0
func (c *Client) OpenPrintLabelMsg(ctx context.Context, req *PrintLabelMsgReq) (resp *PrintLabelMsgResp, err error)
OpenPrintLabelMsg 标签机打印订单 发送用户需要打印的订单内容给飞鹅云标签打印机(该接口只能是标签机使用,其它型号打印机请勿使用该接口) see: http://help.feieyun.com/document.php
func (*Client) OpenPrintMsg ¶ added in v1.2.0
func (c *Client) OpenPrintMsg(ctx context.Context, req *PrintMsgReq) (resp *PrintMsgResp, err error)
OpenPrintMsg 打印订单 发送用户需要打印的订单内容给飞鹅云小票打印机 (该接口只能是小票机使用,如购买标签机请使用标签机专用接口) see: http://help.feieyun.com/document.php ----------接口返回值说明---------- 正确例子:{"msg":"ok","ret":0,"data":"xxxx_xxxx_xxxxxxxxx","serverExecutedTime":6} 错误:{"msg":"错误信息.","ret":非零错误码,"data":null,"serverExecutedTime":5}
func (*Client) OpenPrinterAddList ¶ added in v1.2.0
func (c *Client) OpenPrinterAddList(ctx context.Context, req *PrinterAddReq) (resp *PrinterAddResp, err error)
OpenPrinterAddList 批量添加打印机 批量添加打印机,请严格参照格式说明: 批量添加规则:
打印机编号SN(必填) # 打印机识别码KEY(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100行(台)。 每次最多添加100台。 提示:打印机编号(必填) # 打印机识别码(必填) # 备注名称(选填) # 流量卡号码(选填),多台打印机请换行(\n)添加新打印机信息,每次最多100行(台)。 snlist := "sn1#key1#remark1#carnum1\nsn2#key2#remark2#carnum2"
----------接口返回值说明---------- 正确例子:{"msg":"ok","ret":0,"data":{"ok":["sn#key#remark#carnum","316500011#abcdefgh#快餐前台"],"no":["316500012#abcdefgh#快餐前台#13688889999 (错误:识别码不正确)"]},"serverExecutedTime":3} 错误:{"msg":"参数错误 : 该帐号未注册.","ret":-2,"data":null,"serverExecutedTime":37}
func (*Client) OpenPrinterDelList ¶ added in v1.2.0
func (c *Client) OpenPrinterDelList(ctx context.Context, req *PrinterDelReq) (resp *PrinterDelResp, err error)
OpenPrinterDelList 删除批量打印机 content 打印机编号,多台打印机请用减号“-”连接起来。 see: http://help.feieyun.com/document.php
func (*Client) OpenPrinterEdit ¶ added in v1.2.0
func (c *Client) OpenPrinterEdit(ctx context.Context, req *PrinterEditReq) (resp *PrinterEditResp, err error)
OpenPrinterEdit 修改打印机信息 修改打印机信息 see: http://help.feieyun.com/document.php
func (*Client) OpenQueryOrderInfoByDate ¶ added in v1.2.0
func (c *Client) OpenQueryOrderInfoByDate(ctx context.Context, req *QueryOrderInfoByDateReq) (resp *QueryOrderInfoByDateResp, err error)
OpenQueryOrderInfoByDate 查询指定打印机某天的订单统计数 根据打印机编号和日期,查询该打印机某天的订单统计数,查询指定打印机某天的订单详情,返回已打印订单数和等待打印数。 see: http://help.feieyun.com/document.php
func (*Client) OpenQueryOrderState ¶ added in v1.2.0
func (c *Client) OpenQueryOrderState(ctx context.Context, req *QueryOrderStateReq) (resp *QueryOrderStateResp, err error)
OpenQueryOrderState 查询订单是否打印成功 根据订单ID,去查询订单是否打印成功,订单ID由接口Open_printMsg返回 see: http://help.feieyun.com/document.php
func (*Client) OpenQueryPrinterStatus ¶ added in v1.2.0
func (c *Client) OpenQueryPrinterStatus(ctx context.Context, req *QueryPrinterStatusReq) (resp *QueryPrinterStatusResp, err error)
OpenQueryPrinterStatus 查询打印机状态 根据打印机编号,查询打印机状态,返回打印机状态。 查询指定打印机状态,返回该打印机在线或离线,正常或异常的信息。 see: http://help.feieyun.com/document.php
func (*Client) SetLogger ¶ added in v1.2.0
func (c *Client) SetLogger(logger hlog.FullLogger)
SetLogger set feie logger
func (*Client) SetRequest ¶ added in v1.2.0
SetRequest sets the request.
func (*Client) SetUserKey ¶ added in v1.2.0
SetUserKey sets the user key.
type DelPrinterSQSReq ¶
type DelPrinterSQSReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_delPrinterSQS。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` SN string `json:"sn" description:"打印机编号。"` }
DelPrinterSQSReq is the request body for deleting a printer from SQS.
type DelPrinterSQSResp ¶
type DelPrinterSQSResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data bool `json:"data" description:"成功时返回的数据,正确返回true。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
DelPrinterSQSResp is the response body for deleting a printer from SQS.
type Option ¶
type Option func(o *options)
Option The option is a payment option.
func WithDataType ¶
WithDataType sets the data type.
func WithHashType ¶
WithHashType sets the hash type.
type PrintLabelMsgReq ¶
type PrintLabelMsgReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_printLabelMsg。"` Expired int64 `json:"expired,omitempty" description:"打印任务过期时间,单位秒。"` BackURL string `json:"backurl,omitempty" description:"打印任务回调地址。"` SN string `json:"sn" description:"打印机编号。"` Content string `json:"content" description:"打印内容。"` Times int `json:"times,omitempty" description:"打印联数,最大支持10联。"` Img string `json:"img" description:"图片base64编码。"` }
PrintLabelMsgReq is the request body for printing a label message.
type PrintLabelMsgResp ¶
type PrintLabelMsgResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data string `json:"data" description:"成功时返回的数据,正确返回订单ID。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
PrintLabelMsgResp is the response body for printing a label message.
type PrintMsgReq ¶
type PrintMsgReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_printMsg。"` Expired int64 `json:"expired,omitempty" description:"打印任务过期时间,单位秒。"` BackURL string `json:"backurl,omitempty" description:"打印任务回调地址。"` SN string `json:"sn" description:"打印机编号。"` Content string `json:"content" description:"打印内容。"` Times int `json:"times,omitempty" description:"打印联数,最大支持10联。"` }
PrintMsgReq is the request body for printing a message.
type PrintMsgResp ¶
type PrintMsgResp struct { Msg string `json:"msg" description:"错误信息。"` Data string `json:"data" description:"成功时返回的数据,正确返回订单ID。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` }
PrintMsgResp is the response body for printing a message.
type PrinterAddReq ¶
type PrinterAddReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_printerAddlist。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` PrinterContent string `` /* 220-byte string literal not displayed */ }
PrinterAddReq is the request body for adding a printer.
type PrinterAddResp ¶
type PrinterAddResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data *PrinterRespData `json:"data,omitempty" description:"成功时返回的数据。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
PrinterAddResp is the response body for adding a printer.
type PrinterDelReq ¶
type PrinterDelReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_printerDelList。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` SNList string `json:"snlist" description:"打印机编号,多台打印机请用减号“-”连接起来。"` }
PrinterDelReq is the request body for deleting a printer.
type PrinterDelResp ¶
type PrinterDelResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data *PrinterRespData `json:"data,omitempty" description:"成功时返回的数据。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
PrinterDelResp is the response body for deleting a printer.
type PrinterEditReq ¶
type PrinterEditReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_printerEdit。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` SN string `json:"sn" description:"打印机编号。"` Name string `json:"name" description:"打印机备注名称。"` PhoneNum string `json:"phonenum,omitempty" description:"打印机流量卡号码。"` }
PrinterEditReq is the request body for editing a printer.
type PrinterEditResp ¶
type PrinterEditResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data bool `json:"data" description:"成功时返回的数据。成功返回true,失败返回false。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
PrinterEditResp is the response body for editing a printer.
type PrinterRespData ¶
PrinterRespData is the data field of PrinterResp.
type QueryOrderInfoByDateData ¶
type QueryOrderInfoByDateData struct { Print int `json:"print" description:"打印份数。"` Waiting int `json:"waiting" description:"等待打印份数。"` }
QueryOrderInfoByDateData is the data of QueryOrderInfoByDateResp.
type QueryOrderInfoByDateReq ¶
type QueryOrderInfoByDateReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_queryOrderInfoByDate。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` SN string `json:"sn" description:"打印机编号。"` Date string `json:"date" description:"查询日期,格式YY-MM-DD,如:2016-09-20"` }
QueryOrderInfoByDateReq is the request body for querying the information of an order by date.
type QueryOrderInfoByDateResp ¶
type QueryOrderInfoByDateResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data *QueryOrderInfoByDateData `json:"data" description:"成功时返回的数据,订单信息。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
QueryOrderInfoByDateResp is the response body for querying the information of an order by date.
type QueryOrderStateReq ¶
type QueryOrderStateReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_queryOrderState。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` OrderID string `json:"orderid" description:"订单ID,由接口Open_printMsg返回。"` }
QueryOrderStateReq is the request body for querying the state of an order.
type QueryOrderStateResp ¶
type QueryOrderStateResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data bool `json:"data" description:"成功时返回的数据,已打印返回true,未打印返回false。"` ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
QueryOrderStateResp is the response body for querying the state of an order.
type QueryPrinterStatusReq ¶
type QueryPrinterStatusReq struct { User string `json:"user" description:"飞鹅云后台注册用户名。"` STime int64 `json:"stime,string" description:"当前UNIX时间戳,10位,精确到秒。"` Sig string `` /* 189-byte string literal not displayed */ APIName string `json:"apiname" description:"固定值Open_queryPrinterStatus。"` Debug int `json:"debug,string,omitempty" description:"debug=1返回非json格式的数据。仅测试时候使用。"` SN string `json:"sn" description:"打印机编号。"` }
QueryPrinterStatusReq is the request body for querying the status of a printer.
type QueryPrinterStatusResp ¶
type QueryPrinterStatusResp struct { Ret int `json:"ret" description:"错误码,0为成功,非0为错误。"` Msg string `json:"msg" description:"错误信息。"` Data string `` /* 292-byte string literal not displayed */ ServerExecutedTime int64 `json:"serverExecutedTime" description:"服务器执行时间,单位毫秒。"` }
QueryPrinterStatusResp is the response body for querying the status of a printer.