-
Notifications
You must be signed in to change notification settings - Fork 3
/
apiReportGet.go
executable file
·79 lines (66 loc) · 2.48 KB
/
apiReportGet.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
package secret
import (
"github.com/XiBao/jos/api"
"github.com/XiBao/jos/sdk"
"github.com/XiBao/jos/sdk/request/secret"
)
type SecretApiReportGetRequest struct {
api.BaseRequest
AccessToken string `json:"access_token,omitempty" codec:"access_token,omitempty"`
CustomerUserId string `json:"customer_user_id,omitempty" codec:"customer_user_id,omitempty"`
BusinessId string `json:"businessId,omitempty" codec:"businessId,omitempty"`
Text string `json:"text,omitempty" codec:"text,omitempty"`
Attribute string `json:"attribute,omitempty" codec:"attribute,omitempty"`
ServerUrl string `json:"server_url,omitempty" codec:"server_url,omitempty"`
}
type SecretApiReportGetResponse struct {
ErrorResp *api.ErrorResponnse `json:"error_response,omitempty" codec:"error_response,omitempty"`
Response *SecretApiReportResponse `json:"jingdong_jos_secret_api_report_get_responce,omitempty" codec:"jingdong_jos_secret_api_report_get_responce,omitempty"`
}
func (r SecretApiReportGetResponse) IsError() bool {
return r.ErrorResp != nil || r.Response == nil || r.Response.IsError()
}
func (r SecretApiReportGetResponse) Error() string {
if r.ErrorResp != nil {
return r.ErrorResp.Error()
}
if r.Response != nil {
return r.Response.Error()
}
return "no result data"
}
type SecretApiReportResponse struct {
Result SecretApiReportResult `json:"response,omitempty" codec:"response,omitempty"`
}
func (r SecretApiReportResponse) IsError() bool {
return r.Result.IsError()
}
func (r SecretApiReportResponse) Error() string {
return r.Result.Error()
}
type SecretApiReportResult struct {
Code int `json:"errorCode,omitempty" codec:"errorCode,omitempty"`
ErrorDesc string `json:"errorMsg,omitempty" codec:"errorMsg,omitempty"`
}
func (r SecretApiReportResult) IsError() bool {
return r.Code != 0
}
func (r SecretApiReportResult) Error() string {
return sdk.ErrorString(r.Code, r.ErrorDesc)
}
// 对加解密等调用信息上报,不包含敏感信息,只负责统计系统性能
func SecretApiReportGet(req *SecretApiReportGetRequest) error {
client := sdk.NewClient(req.AnApiKey.Key, req.AnApiKey.Secret)
client.Debug = req.Debug
r := secret.NewSecretApiReportGetRequest()
r.SetAccessToken(req.AccessToken)
r.SetCustomerUserId(req.CustomerUserId)
r.SetText(req.Text)
r.SetAttribute(req.Attribute)
r.SetServerUrl(req.ServerUrl)
var response SecretApiReportGetResponse
if err := client.Execute(r.Request, req.Session, &response); err != nil {
return err
}
return nil
}