work/corpgroup/rule.pm untested

filter: Statementstmt 0.0% 0 / 71 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 30 MC/DCmcdc 0.0% 0 / 15 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 152 CC 11 SCAR 22.1
CC
11
Cov
0%
list_ids
12.0
delete_rule
12.0
get_rule_info
12.0
CRAP 9.1
1 package QQ::weixin::work::corpgroup::rule;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::weixin::work::corpgroup::rule
8
9 =head1 DESCRIPTION
10
11 上下游规则
12
13 =cut
14
15 use strict;
16 use base qw(QQ::weixin::work::corpgroup);
17 use Encode;
18 use LWP::UserAgent;
19 use JSON;
20 use utf8;
21
22 our $VERSION = '0.10';
23 our @EXPORT = qw/ list_ids delete_rule get_rule_info add_rule modify_rule /;
24
25 =head1 FUNCTION
26
27 =head2 list_ids(access_token, hash);
28
29 获取对接规则id列表
30 最后更新:2023/11/30
31
32 =head2 SYNOPSIS
33
34 L<https://developer.work.weixin.qq.com/document/path/95631>
35
36 =head3 请求说明:
37
38 上下游系统应用可通过该接口获取企业上下游规则id列表
39
40 =head4 请求包结构体为:
41
42 {
43 "chain_id":"Chxxxxxx"
44 }
45
46 =head4 参数说明:
47
48 参数 必须 说明
49 access_token 是 调用接口凭证
50 chain_id 是 上下游id
51
52 =head4 权限说明:
53
54 调用的应用需要满足如下的权限,仅适用于上下游中创建空间的主企业调用。
55
56 应用类型 权限要求
57 自建应用 配置到「上下游- 可调用接口的应用」中
58 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
59
60 =head3 RETURN 返回结果:
61
62 {
63 "errcode": 0,
64 "errmsg": "ok",
65 "rule_ids": [1,2]
66 }
67
68 =head4 RETURN 参数说明:
69
70 参数 说明
71 errcode 出错返回码,为0表示成功,非0表示调用失败
72 errmsg 对返回码的文本描述内容
73 rule_ids 上下游关系规则的id
74
75 =cut
76
77 sub list_ids {
78 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
79 my $access_token = $_[0];
80 my $json = $_[1];
81 my $ua = LWP::UserAgent->new;
82 $ua->timeout(30);
83 $ua->env_proxy;
84
85 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/corpgroup/rule/list_ids?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
86 if ($response->is_success) {
87 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
88 }
89
90 }
91 return 0;
92 }
93
94 =head2 delete_rule(access_token, hash);
95
96 删除对接规则
97 最后更新:2023/11/30
98
99 =head2 SYNOPSIS
100
101 L<https://developer.work.weixin.qq.com/document/path/95632>
102
103 =head3 请求说明:
104
105 上下游系统应用可通过该接口删除企业上下游规则
106
107 =head4 请求包结构体为:
108
109 {
110 "chain_id":"Chxxxxxx",
111 "rule_id":1
112 }
113
114 =head4 参数说明:
115
116 参数 必须 说明
117 access_token 是 调用接口凭证
118 chain_id 是 上下游id
119 rule_id 是 上下游规则id
120
121 =head4 权限说明:
122
123 调用的应用需要满足如下的权限,仅适用于上下游中创建空间的主企业调用。操作的规则对应的企业成员和部门都需要在应用的可见范围内。
124
125 应用类型 权限要求
126 自建应用 配置到「上下游- 可调用接口的应用」中
127 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
128
129 =head3 RETURN 返回结果:
130
131 {
132 "errcode": 0,
133 "errmsg": "ok"
134 }
135
136 =head4 RETURN 参数说明:
137
138 参数 说明
139 errcode 返回码
140 errmsg 对返回码的文本描述内容
141
142 =cut
143
144 sub delete_rule {
145 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
146 my $access_token = $_[0];
147 my $json = $_[1];
148 my $ua = LWP::UserAgent->new;
149 $ua->timeout(30);
150 $ua->env_proxy;
151
152 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/corpgroup/rule/delete_rule?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
153 if ($response->is_success) {
154 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
155 }
156
157 }
158 return 0;
159 }
160
161 =head2 get_rule_info(access_token, hash);
162
163 获取对接规则详情
164 最后更新:2023/11/30
165
166 =head2 SYNOPSIS
167
168 L<https://developer.work.weixin.qq.com/document/path/95633>
169
170 =head3 请求说明:
171
172 上下游系统应用可通过该接口获取企业上下游规则详情
173
174 =head4 请求包结构体为:
175
176 {
177 "chain_id":"Chxxxxxx",
178 "rule_id":1
179 }
180
181 =head4 参数说明:
182
183 参数 必须 说明
184 access_token 是 调用接口凭证
185 chain_id 是 上下游id
186 rule_id 是 上下游规则id
187
188 =head4 权限说明:
189
190 调用的应用需要满足如下的权限,仅适用于上下游中创建空间的主企业调用。操作的规则对应的企业用户和部门都需要在应用的可见范围内。
191
192 应用类型 权限要求
193 自建应用 配置到「上下游- 可调用接口的应用」中
194 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
195
196 =head3 RETURN 返回结果:
197
198 {
199 "errcode": 0,
200 "errmsg": "ok",
201 "rule_info": {
202 "owner_corp_range": {
203 "departmentids": ["departmentid1", "departmentid2"],
204 "userids": ["userid1","userid2"]
205 },
206 "member_corp_range": {
207 "groupids": ["groupid1", "groupid2"],
208 "corpids": ["corpid1","corpid2"]
209 }
210 }
211 }
212
213 =head4 RETURN 参数说明:
214
215 参数 说明
216 errcode 返回码
217 errmsg 对返回码的文本描述内容
218 rule_info 上下游关系规则的详情
219 rule_info.owner_corp_range 上游企业的对接人规则(下游企业可以看到并联系的成员或部门)
220 rule_info.owner_corp_range.departmentids 部门id
221 rule_info.owner_corp_range.userids 用户id
222 rule_info.member_corp_range 下游企业规则范围
223 rule_info.member_corp_range.groupids 分组id
224 rule_info.member_corp_range.corpids 企业id
225
226 =cut
227
228 sub get_rule_info {
229 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
230 my $access_token = $_[0];
231 my $json = $_[1];
232 my $ua = LWP::UserAgent->new;
233 $ua->timeout(30);
234 $ua->env_proxy;
235
236 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/corpgroup/rule/get_rule_info?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
237 if ($response->is_success) {
238 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
239 }
240
241 }
242 return 0;
243 }
244
245 =head2 add_rule(access_token, hash);
246
247 新增对接规则
248 最后更新:2023/12/07
249
250 =head2 SYNOPSIS
251
252 L<https://developer.work.weixin.qq.com/document/path/95634>
253
254 =head3 请求说明:
255
256 上下游系统应用可通过该接口新增一条对接规则。
257 注意:新增和更新上下游对接规则的接口每天最多调用1000次
258
259 =head4 请求包结构体为:
260
261 {
262 "chain_id":"Chxxxxxx",
263 "rule_info": {
264 "owner_corp_range": {
265 "departmentids": ["departmentid1", "departmentid2"],
266 "userids": ["userid1","userid2"]
267 },
268 "member_corp_range": {
269 "groupids": ["groupid1", "groupid2"],
270 "corpids": ["corpid1","corpid2"]
271 }
272 }
273 }
274
275 =head4 参数说明:
276
277 参数 必须 说明
278 access_token 是 调用接口凭证
279 chain_id 是 上下游id
280 rule_info 是 上下游关系规则的详情
281 rule_info.owner_corp_range 是 上游企业的对接人规则(下游企业可以看到并联系的成员或部门)
282 rule_info.owner_corp_range.departmentids 否 部门id,部门id和用户id两个必选填一个
283 rule_info.owner_corp_range.userids 否 用户id,部门id和用户id两个必选填一个
284 rule_info.member_corp_range 是 下游企业规则范围
285 rule_info.member_corp_range.groupids 否 分组id,分组id和企业id两个必选填一个
286 rule_info.member_corp_range.corpids 否 企业id,分组id和企业id两个必选填一个
287
288 =head4 权限说明:
289
290 调用的应用需要满足如下的权限,仅适用于上下游中创建空间的主企业调用。操作的规则对应的企业用户和部门都需要在应用的可见范围内。
291
292 应用类型 权限要求
293 自建应用 配置到「上下游- 可调用接口的应用」中
294 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
295
296
297 =head3 RETURN 返回结果:
298
299 {
300 "errcode": 0,
301 "errmsg": "ok",
302 "rule_id": 1
303 }
304
305 =head4 RETURN 参数说明:
306
307 参数 说明
308 errcode 返回码
309 errmsg 对返回码的文本描述内容
310 rule_id 上下游规则id
311
312 =cut
313
314 sub add_rule {
315 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
316 my $access_token = $_[0];
317 my $json = $_[1];
318 my $ua = LWP::UserAgent->new;
319 $ua->timeout(30);
320 $ua->env_proxy;
321
322 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/corpgroup/rule/add_rule?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
323 if ($response->is_success) {
324 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
325 }
326
327 }
328 return 0;
329 }
330
331 =head2 modify_rule(access_token, hash);
332
333 更新对接规则
334 最后更新:2023/12/07
335
336 =head2 SYNOPSIS
337
338 L<https://developer.work.weixin.qq.com/document/path/95635>
339
340 =head3 请求说明:
341
342 上下游系统应用可通过该接口修改一条对接规则。
343 注意:新增和更新上下游对接规则的接口每天最多调用1000次
344
345 =head4 请求包结构体为:
346
347 {
348 "chain_id":"Chxxxxxx",
349 "rule_id": 1,
350 "rule_info": {
351 "owner_corp_range": {
352 "departmentids": ["departmentid1", "departmentid2"],
353 "userids": ["userid1","userid2"]
354 },
355 "member_corp_range": {
356 "groupids": ["groupid1", "groupid2"],
357 "corpids": ["corpid1","corpid2"]
358 }
359 }
360 }
361
362 =head4 参数说明:
363
364 参数 必须 说明
365 access_token 是 调用接口凭证
366 chain_id 是 上下游id
367 rule_id 是 上下游规则id
368 rule_info 是 上下游关系规则的详情
369 rule_info.owner_corp_range 是 上游企业的对接人规则(下游企业可以看到并联系的成员或部门)
370 rule_info.owner_corp_range.departmentids 否 部门id,部门id和用户id两个必选填一个
371 rule_info.owner_corp_range.userids 否 用户id,部门id和用户id两个必选填一个
372 rule_info.member_corp_range 是 下游企业规则范围
373 rule_info.member_corp_range.groupids 否 分组id,分组id和企业id两个必选填一个
374 rule_info.member_corp_range.corpids 否 企业id,分组id和企业id两个必选填一个
375
376 =head4 权限说明:
377
378 调用的应用需要满足如下的权限,仅适用于上下游中创建空间的主企业调用。操作的规则对应的企业成员和部门都需要在应用的可见范围内。
379
380 应用类型 权限要求
381 自建应用 配置到「上下游- 可调用接口的应用」中
382 注: 从2023年12月1日0点起,不再支持通过系统应用secret调用接口,存量企业暂不受影响 查看详情
383
384 =head3 RETURN 返回结果:
385
386 {
387 "errcode": 0,
388 "errmsg": "ok"
389 }
390
391 =head4 RETURN 参数说明:
392
393 参数 说明
394 errcode 返回码
395 errmsg 对返回码的文本描述内容
396
397 =cut
398
399 sub modify_rule {
400 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
401 my $access_token = $_[0];
402 my $json = $_[1];
403 my $ua = LWP::UserAgent->new;
404 $ua->timeout(30);
405 $ua->env_proxy;
406
407 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/corpgroup/rule/modify_rule?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
408 if ($response->is_success) {
409 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
410 }
411
412 }
413 return 0;
414 }
415
416 1;
417 __END__