-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient_openapi.go
81 lines (72 loc) · 1.84 KB
/
client_openapi.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
package wgo
import "context"
// ClearQuota ...
func (c *Client) ClearQuota(ctx context.Context) error {
resp := struct{}{}
err := c.NewRequest().Post().
RequestURI("/cgi-bin/clear_quota").
Param("appid", c.config.appid).
Do(ctx).
Into(NewJSONValidator(&resp))
return err
}
// GetAPIQuotaResponse ...
type GetAPIQuotaResponse struct {
Quota GetAPIQuota `json:"quota"`
}
// GetAPIQuota ...
type GetAPIQuota struct {
DailyLimit int `json:"daily_limit"`
Used int `json:"used"`
Remain int `json:"remain"`
}
// GetAPIQuota ...
func (c *Client) GetAPIQuota(ctx context.Context, cgiPath string) (*GetAPIQuotaResponse, error) {
resp := GetAPIQuotaResponse{}
err := c.NewRequest().Post().
RequestURI("/cgi-bin/clear_quota").
Param("cgi_path", cgiPath).
Do(ctx).
Into(&resp)
if err != nil {
return nil, err
}
return &resp, err
}
// GetRidInfoResponse ...
type GetRidInfoResponse struct {
Request GetRidInfo `json:"request"`
}
// GetRidInfo ...
type GetRidInfo struct {
InvokeTime int `json:"invoke_time"`
CostInMs int `json:"cost_in_ms"`
RequestURL string `json:"request_url"`
RequestBody string `json:"request_body"`
ResponseBody string `json:"response_body"`
ClientIP string `json:"client_ip"`
}
// GetRidInfo ...
func (c *Client) GetRidInfo(ctx context.Context, rid string) (*GetRidInfoResponse, error) {
resp := GetRidInfoResponse{}
err := c.NewRequest().Post().
RequestURI("/cgi-bin/openapi/rid/get").
Param("rid", rid).
Do(ctx).
Into(&resp)
if err != nil {
return nil, err
}
return &resp, err
}
// ClearQuotaByAppSecret ...
func (c *Client) ClearQuotaByAppSecret(ctx context.Context) error {
resp := struct{}{}
err := c.NewRequest().Post().
RequestURI("/cgi-bin/clear_quota/v2").
Param("appid", c.config.appid).
//Param("appsecret", c.config.secret).
Do(ctx).
Into(&resp)
return err
}