-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmgnt.api.go
192 lines (164 loc) · 4.9 KB
/
mgnt.api.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
181
182
183
184
185
186
187
188
189
190
191
192
// Code generated by protoc-gen-go_api(github.com/dev-openapi/protoc-gen-go_api version=v1.0.3). DO NOT EDIT.
// source: wx-miniprogram/mgnt.proto
package wx_miniprogram
import (
context "context"
fmt "fmt"
io "io"
json "encoding/json"
bytes "bytes"
http "net/http"
strings "strings"
url "net/url"
multipart "mime/multipart"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = context.Background
var _ = http.NewRequest
var _ = io.Copy
var _ = bytes.Compare
var _ = json.Marshal
var _ = strings.Compare
var _ = fmt.Errorf
var _ = url.Parse
var _ = multipart.ErrMessageTooLarge
// Client API for Mgnt service
type MgntService interface {
// ClearQuota 重置 API 调用次数 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuota.html
ClearQuota(ctx context.Context, in *ClearQuotaReq, opts ...Option) (*ClearQuotaRes, error)
// GetApiQuota 查询API调用额度 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getApiQuota.html
GetApiQuota(ctx context.Context, in *GetApiQuotaReq, opts ...Option) (*GetApiQuotaRes, error)
// GetRidInfo 查询rid信息 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/getRidInfo.html
GetRidInfo(ctx context.Context, in *GetRidInfoReq, opts ...Option) (*GetRidInfoRes, error)
// ClearQuotaV2 使用AppSecret重置 API 调用次数 https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/openApi-mgnt/clearQuotaByAppSecret.html
ClearQuotaV2(ctx context.Context, in *ClearQuotaV2Req, opts ...Option) (*ClearQuotaV2Res, error)
}
type mgntService struct {
// opts
opts *Options
}
func NewMgntService(opts ...Option) MgntService {
opt := newOptions(opts...)
if len(opt.addr) <= 0 {
opt.addr = "https://api.weixin.qq.com"
}
return &mgntService {
opts: opt,
}
}
func (c *mgntService) ClearQuota(ctx context.Context, in *ClearQuotaReq, opts ...Option) (*ClearQuotaRes, error) {
var res ClearQuotaRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/cgi-bin/clear_quota?access_token=%v", opt.addr, in.GetAccessToken())
// body
bs, err := json.Marshal(in.GetBody())
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *mgntService) GetApiQuota(ctx context.Context, in *GetApiQuotaReq, opts ...Option) (*GetApiQuotaRes, error) {
var res GetApiQuotaRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/cgi-bin/openapi/quota/get?access_token=%v", opt.addr, in.GetAccessToken())
// body
bs, err := json.Marshal(in.GetBody())
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *mgntService) GetRidInfo(ctx context.Context, in *GetRidInfoReq, opts ...Option) (*GetRidInfoRes, error) {
var res GetRidInfoRes
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/cgi-bin/openapi/rid/get?access_token=%v", opt.addr, in.GetAccessToken())
// body
bs, err := json.Marshal(in.GetBody())
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}
func (c *mgntService) ClearQuotaV2(ctx context.Context, in *ClearQuotaV2Req, opts ...Option) (*ClearQuotaV2Res, error) {
var res ClearQuotaV2Res
// options
opt := buildOptions(c.opts, opts...)
headers := make(map[string]string)
// route
rawURL := fmt.Sprintf("%s/cgi-bin/clear_quota/v2", opt.addr)
// body
bs, err := json.Marshal(in)
if err != nil {
return nil, err
}
body := bytes.NewReader(bs)
headers["Content-Type"] = "application/json"
req, err := http.NewRequest("POST", rawURL, body)
if err != nil {
return nil, err
}
// header
for k, v := range headers {
req.Header.Set(k, v)
}
resp, err := opt.DoRequest(ctx, opt.client, req)
if err != nil {
return nil, err
}
err = opt.DoResponse(ctx, resp, &res)
return &res, err
}