-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
180 lines (158 loc) · 3.29 KB
/
types.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
package superaipro
import (
"net/http"
"net/url"
"strconv"
)
type (
Request struct {
Params map[string]interface{}
}
Client struct {
BaseURL *url.URL
ApiKey string
DefaultTimeout int
RecaptchaTimeout int
PollingInterval int
httpClient *http.Client
}
Identify struct {
Type string
Images []string
}
GeeTest struct {
GT string
Challenge string
Url string
ApiServer string
}
HCaptcha struct {
SiteKey string
Url string
Type string
Timeout int
}
ReCaptcha struct {
SiteKey string
Url string
Invisible bool
Version string
Action string
Score float64
}
IdentifyData struct {
ProjectName string `json:"projectName" validate:"required"`
Image []string `json:"image"`
}
Result struct {
ID string `json:"id"`
Token string `json:"token"`
Success bool `json:"success"`
Status string `json:"status"`
Message string `json:"message"`
ExpireTime int64 `json:"expireTime"`
}
IdentifyResult struct {
Data string `json:"data"`
Success bool `json:"success"`
}
User struct {
Data struct {
Email string `json:"email"`
Wallet struct {
Balance int `json:"balance"`
NumberOfCall int `json:"numberOfCall"`
} `json:"wallet"`
} `json:"data"`
Success bool `json:"success"`
}
Wallet struct {
Data struct {
Balance int `json:"balance"`
NumberOfCall int `json:"numberOfCall"`
} `json:"data"`
Success bool `json:"success"`
}
)
func (req *Request) SetProxy(proxyType string, uri string) {
req.Params["proxytype"] = proxyType
req.Params["proxy"] = uri
}
func (req *Request) SetUserAgent(userAgent string) {
req.Params["userAgent"] = userAgent
}
func (req *Request) SetCookies(cookies string) {
req.Params["cookies"] = cookies
}
func (c *GeeTest) ToRequest() Request {
req := Request{
Params: map[string]interface{}{"projectName": "geetest"},
}
if c.GT != "" {
req.Params["gt"] = c.GT
}
if c.Challenge != "" {
req.Params["challenge"] = c.Challenge
}
if c.Url != "" {
req.Params["pageurl"] = c.Url
}
if c.ApiServer != "" {
req.Params["api_server"] = c.ApiServer
}
return req
}
func (c *HCaptcha) ToRequest() Request {
req := Request{
Params: map[string]interface{}{"projectName": "hcaptcha"},
}
if c.SiteKey != "" {
req.Params["siteKey"] = c.SiteKey
}
if c.Url != "" {
req.Params["pageUrl"] = c.Url
}
if c.Type != "" {
req.Params["type"] = c.Type
}
if c.Timeout != 0 {
req.Params["timeout"] = c.Timeout
}
return req
}
func (c *ReCaptcha) ToRequest() Request {
req := Request{
Params: map[string]interface{}{"projectName": "userrecaptcha"},
}
if c.SiteKey != "" {
req.Params["siteKey"] = c.SiteKey
}
if c.Url != "" {
req.Params["siteUrl"] = c.Url
}
if c.Invisible {
req.Params["invisible"] = "1"
}
if c.Version != "" {
req.Params["version"] = c.Version
}
if c.Action != "" {
req.Params["action"] = c.Action
}
if c.Score != 0 {
req.Params["min_score"] = strconv.FormatFloat(c.Score, 'f', -1, 64)
}
return req
}
func (c *Identify) ToRequest() Request {
req := Request{
Params: map[string]interface{}{"projectName": "userrecaptcha"},
}
if c.Type != "" {
req.Params["type"] = c.Type
}
if len(c.Images) > 0 {
req.Params["image"] = c.Images
}
return req
}