-
Notifications
You must be signed in to change notification settings - Fork 0
/
params.go
66 lines (56 loc) · 1.85 KB
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package oxpay
import (
"net/url"
)
//
// Public constants
//
type Params struct {
Header *Head `json:"header"`
Data any `json:"data"`
}
// Head is the request common comment.
type Head struct {
Version string `json:"version"` //OxPayAPI version
AppType string `json:"appType"` //app类型 I: iPhone; A: Android; W: Web
AppVersion string `json:"appVersion"` //For example: "AppName.01.20.0" or "WebName.0002.00012.1"
Status Status `json:"status"` //json字符串 只存在于response 的head中
McpTerminalId string `json:"mcpTerminalId"` // 登录后相应体中获取Mcp Terminal Id mandatory for sale, void, refund, reverse...
Signature string `json:"signature"` //签名 登录后获取 ,并且在每次发送请求时都需要带上
Uuid string `json:"uuid"` // 在pos机上需要设置
}
type Status struct {
ResponseCode string `json:"responseCode"`
Message string `json:"message"`
}
// ParamsContainer is a general interface for which all parameter structs
// should comply. They achieve this by embedding a Params struct and inheriting
// its implementation of this interface.
type ParamsContainer interface {
GetParams() any
}
// GetParams returns a Params struct (itself). It exists because any structs
// that embed Params will inherit it, and thus implement the ParamsContainer
// interface.
func (p *Params) GetParams() any {
return p
}
//
// Public types
//
// ExtraValues are extra parameters that are attached to an API request.
// They're implemented as a custom type so that they can have their own
// AppendTo implementation.
type ExtraValues struct {
url.Values `form:"-"` // See custom AppendTo implementation
}
func GetParams(params any, header *Head) any {
if header != nil {
return &Params{
Data: params,
Header: header,
}
} else {
return params
}
}