work/oa/schedule.pm untested

filter: Statementstmt 0.0% 0 / 91 Branchbran 0.0% 0 / 28 Conditioncond 0.0% 0 / 42 MC/DCmcdc 0.0% 0 / 21 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 202 CC 15 SCAR 22.8
CC
15
Cov
0%
add
12.0
update
12.0
add_attendees
12.0
CRAP 9.8
1 package QQ::weixin::work::oa::schedule;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::weixin::work::oa::schedule
8
9 =head1 DESCRIPTION
10
11 日程
12
13 =cut
14
15 use strict;
16 use base qw(QQ::weixin::work::oa);
17 use Encode;
18 use LWP::UserAgent;
19 use JSON;
20 use utf8;
21
22 our $VERSION = '0.10';
23 our @EXPORT = qw/ add update add_attendees del_attendees
24 get_by_calendar get del /;
25
26 =head1 FUNCTION
27
28 =head2 add(access_token, hash);
29
30 创建日程
31 最后更新:2023/06/20
32
33 =head2 SYNOPSIS
34
35 L<https://developer.work.weixin.qq.com/document/path/93648>
36
37 =head3 请求说明:
38
39 该接口用于在日历中创建一个日程。
40
41 =head4 请求包结构体为:
42
43 {
44 "schedule": {
45 "admins":[
46 "admin1",
47 "admin2"
48 ],
49 "start_time": 1571274600,
50 "end_time": 1571320210,
51 "is_whole_day":1,
52 "attendees": [{
53 "userid": "userid2"
54 }],
55 "summary": "需求评审会议",
56 "description": "2.0版本需求初步评审",
57 "reminders": {
58 "is_remind": 1,
59 "remind_before_event_secs": 3600,
60 "remind_time_diffs":[0, 3600],
61 "is_repeat": 1,
62 "repeat_type": 7,
63 "repeat_until": 1606976813,
64 "is_custom_repeat": 1,
65 "repeat_interval": 1,
66 "repeat_day_of_week": [3, 7],
67 "repeat_day_of_month": [10, 21],
68 "timezone": 8
69 },
70 "location": "广州国际媒体港10楼1005会议室",
71 "cal_id": "wcjgewCwAAqeJcPI1d8Pwbjt7nttzAAA"
72 },
73 "agentid": 1000014
74 }
75
76 =head4 参数说明:
77
78 参数 必须 类型 说明
79 access_token 是 string 调用接口凭证
80 schedule 是 obj 日程信息
81 schedule.admins 否 string 日程的管理员userid列表,管理员必须在共享成员的列表中。最多指定3人
82 schedule.attendees 否 obj[] 日程参与者列表。最多支持1000人
83 schedule.attendees.userid 是 string 日程参与者ID
84 不多于64字节
85 schedule.summary 否 string 日程标题。0 ~ 128 字符。不填会默认显示为“新建事件”
86 schedule.description 否 string 日程描述
87 不多于1000个字符
88 schedule.reminders 否 obj 提醒相关信息
89 schedule.reminders.is_remind 否 int32 是否需要提醒。0-否;1-是
90 schedule.reminders.is_repeat 否 int32 是否重复日程。0-否;1-是
91 schedule.reminders.remind_before_event_secs 否 uint32 日程开始(start_time)前多少秒提醒,当is_remind为1时有效。
92 例如: 300表示日程开始前5分钟提醒。目前仅支持以下数值:
93 0 - 事件开始时
94 300 - 事件开始前5分钟
95 900 - 事件开始前15分钟
96 3600 - 事件开始前1小时
97 86400 - 事件开始前1天
98 schedule.reminders.remind_time_diffs 否 int32[] 提醒时间与日程开始时间(start_time)的差值,当is_remind为1时有效,可以指定多个提醒时间,目前仅支持以下数值:
99 0 - 事件开始时
100 -300 - 事件开始前5分钟
101 -900 - 事件开始前15分钟
102 -3600 - 事件开始前1小时
103 -86400 - 事件开始前1天
104 当is_whole_day=1时,还支持:
105 32400 - 事件开始当天(09:00)
106 -172800 - 事件开始前两天
107 -604800 - 事件开始前1周
108 该字段与remind_before_event_secs仅一个字段会生效,当该字段有传值且列表不为空时,优先以该字段为准
109 schedule.reminders.repeat_type 否 uint32 重复类型,当is_repeat为1时有效。目前支持如下类型:
110 0 - 每日
111 1 - 每周
112 2 - 每月
113 5 - 每年
114 7 - 工作日
115 schedule.reminders.repeat_until 否 uint32 重复结束时刻,Unix时间戳,当is_repeat为1时有效。不填或填0表示一直重复
116 schedule.reminders.is_custom_repeat 否 uint32 是否自定义重复。0-否;1-是。当is_repeat为1时有效。
117 schedule.reminders.repeat_interval 否 uint32 重复间隔
118 仅当指定为自定义重复时有效
119 该字段随repeat_type不同而含义不同
120 例如:
121 repeat_interval指定为3,repeat_type指定为每周重复,那么每3周重复一次;
122 repeat_interval指定为3,repeat_type指定为每月重复,那么每3个月重复一次
123 schedule.reminders.repeat_day_of_week 否 uint32[] 每周周几重复
124 仅当指定为自定义重复且重复类型为每周时有效
125 取值范围:1 ~ 7,分别表示周一至周日
126 schedule.reminders.repeat_day_of_month 否 uint32[] 每月哪几天重复
127 仅当指定为自定义重复且重复类型为每月时有效
128 取值范围:1 ~ 31,分别表示1~31号
129 schedule.reminders.timezone 否 uint32 时区。UTC偏移量表示(即偏离零时区的小时数),东区为正数,西区为负数。
130 例如:+8 表示北京时间东八区
131 默认为北京时间东八区
132 取值范围:-12 ~ +12
133 schedule.location 否 string 日程地址
134 不多于128个字符
135 schedule.start_time 是 uint32 日程开始时间,Unix时间戳
136 schedule.end_time 是 uint32 日程结束时间,Unix时间戳
137 schedule.cal_id 否 string 日程所属日历ID。该日历必须是access_token所对应应用所创建的日历。如果不填,那么插入到access_token所对应应用的默认日历上。
138 第三方应用必须指定cal_id
139 不多于64字节
140 schedule.is_whole_day 否 uint32 是否设置为全天日程。0-否;1-是
141 agentid 否 uint32 授权方安装的应用agentid。仅旧的第三方多应用套件需要填此参数
142
143
144 =head3 关于自定义重复的说明:
145
146 is_custom_repeat 如果为0,那么系统会根据 start_time 和 repeat_type 来自动计算下一次重复的时间,例如:
147
148 start_time 为本周周三8点整,repeat_type 为每周重复,那么每周三8点整重复;
149 start_time 为本月3号10点整,repeat_type 为每月重复,那么每月3号10点整重复;
150 如果 is_custom_repeat 指定为1,那么可以配合 repeat_day_of_week 或 repeat_day_of_month 特别指定周几或几号重复,且可以使用 repeat_interval 指定重复间隔
151
152 =head3 RETURN 返回结果
153
154 {
155 "errcode": 0,
156 "errmsg": "ok",
157 "schedule_id":"17c7d2bd9f20d652840f72f59e796AAA"
158 }
159
160 =head3 RETURN 参数说明
161
162 参数 类型 说明
163 errcode int32 返回码
164 errmsg string 错误码描述
165 schedule_id string 日程ID
166
167 =cut
168
169 sub add {
170 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
171 my $access_token = $_[0];
172 my $json = $_[1];
173 my $ua = LWP::UserAgent->new;
174 $ua->timeout(30);
175 $ua->env_proxy;
176
177 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/add?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
178 if ($response->is_success) {
179 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
180 }
181
182 }
183 return 0;
184 }
185
186 =head2 update(access_token, hash);
187
188 更新日程
189 最后更新:2023/08/28
190
191 =head2 SYNOPSIS
192
193 L<https://developer.work.weixin.qq.com/document/path/97720>
194
195 =head3 请求说明:
196
197 该接口用于在日历中更新指定的日程。
198
199 注意,更新操作是覆盖式,而不是增量式
200 如果需要增量式更新成员,可使用后面的“新增日程参与者”与“删除日程参与者”接口
201 不可更新创建者和日程所属日历ID
202 已预约会议室的日程无法通过此接口进行更新,应用可先取消会议室的预定,再更新日程
203
204 =head4 请求包体:
205
206 {
207 "skip_attendees ": 0,
208 "op_mode": 1,
209 "op_start_time": 1571274600,
210 "schedule": {
211 "admins":[
212 "admin1",
213 "admin2"
214 ],
215 "schedule_id": "17c7d2bd9f20d652840f72f59e796AAA",
216 "start_time": 1571274600,
217 "end_time": 1571320210,
218 "is_whole_day":1,
219 "attendees": [{
220 "userid": "userid2"
221 }],
222 "summary": "test_summary",
223 "description": "test_description",
224 "reminders": {
225 "is_remind": 1,
226 "remind_before_event_secs": 3600,
227 "remind_time_diffs":[0,3600],
228 "is_repeat": 1,
229 "repeat_type": 7,
230 "repeat_until": 1606976813,
231 "is_custom_repeat": 1,
232 "repeat_interval": 1,
233 "repeat_day_of_week": [3, 7],
234 "repeat_day_of_month": [10, 21],
235 "timezone": 8
236 },
237 "location": "test_place"
238 }
239 }
240
241 =head4 参数说明:
242
243 参数 必须 类型 说明
244 access_token 是 string 调用接口凭证
245 skip_attendees 否 uint32 是否不更新参与人。0-否;1-是。默认为0
246 op_mode 否 uint32 操作模式。是重复日程时有效。
247 0-默认全部修改;
248 1-仅修改此日程;
249 2-修改将来的所有日程
250 详见重复日程的不同操作模式
251 op_start_time 否 uint32 操作起始时间。仅当操作模式是1或2时有效。该时间必须是重复日程的某一次开始时间
252 例如:假如日程开始时间start_time为1661990950(2022-09-01 08:09:10),且重复类型是每周,那么op_start_time可以是:1661990950(2022-09-01 08:09:10)、1662595750(2022-09-08 08:09:10)、1663200550(2022-09-15 08:09:10)......
253 schedule 是 obj 日程信息
254 schedule.schedule_id 是 string 日程ID。创建日程时返回的ID
255 schedule.admins 否 string[] 日程的管理员userid列表,管理员必须在共享成员的列表中。最多指定3人
256 schedule.attendees 否 obj[] 日程参与者列表。最多支持1000人
257 schedule.attendees.userid 是 string 日程参与者ID
258 不多于64字节
259 schedule.summary 否 string 日程标题。0 ~ 128 字符。不填会默认显示为“新建事件”
260 schedule.description 否 string 日程描述
261 不多于1000个字符
262 schedule.reminders 否 obj 提醒相关信息
263 schedule.reminders.is_remind 否 int32 是否需要提醒。0-否;1-是
264 schedule.reminders.is_repeat 否 int32 是否重复日程。0-否;1-是
265 schedule.reminders.remind_before_event_secs 否 uint32 日程开始(start_time)前多少秒提醒,当is_remind为1时有效。
266 例如: 300表示日程开始前5分钟提醒。目前仅支持以下数值:
267 0 - 事件开始时
268 300 - 事件开始前5分钟
269 900 - 事件开始前15分钟
270 3600 - 事件开始前1小时
271 86400 - 事件开始前1天
272 schedule.reminders.remind_time_diffs 否 int32[] 提醒时间与日程开始时间(start_time)的差值,当is_remind为1时有效,可以指定多个提醒时间,目前仅支持以下数值:
273 0 - 事件开始时
274 -300 - 事件开始前5分钟
275 -900 - 事件开始前15分钟
276 -3600 - 事件开始前1小时
277 -86400 - 事件开始前1天
278 当is_whole_day=1时,还支持:
279 32400 - 事件开始当天(09:00)
280 -172800 - 事件开始前两天
281 -604800 - 事件开始前1周
282 该字段与remind_before_event_secs仅一个字段会生效,当该字段有传值且列表不为空时,优先以该字段为准
283 schedule.reminders.repeat_type 否 uint32 重复类型,当is_repeat为1时有效。目前支持如下类型:
284 0 - 每日
285 1 - 每周
286 2 - 每月
287 5 - 每年
288 7 - 工作日
289 schedule.reminders.repeat_until 否 uint32 重复结束时刻,Unix时间戳,当is_repeat为1时有效。不填或填0表示一直重复
290 schedule.reminders.is_custom_repeat 否 uint32 是否自定义重复。0-否;1-是。当is_repeat为1时有效。
291 schedule.reminders.repeat_interval 否 uint32 重复间隔
292 仅当指定为自定义重复时有效
293 该字段随repeat_type不同而含义不同
294 例如:
295 repeat_interval指定为2,repeat_type指定为每周重复,那么每2周重复一次;
296 repeat_interval指定为2,repeat_type指定为每月重复,那么每2月重复一次
297 schedule.reminders.repeat_day_of_week 否 uint32[] 每周周几重复
298 仅当指定为自定义重复且重复类型为每周时有效
299 取值范围:1 ~ 7,分别表示周一至周日
300 schedule.reminders.repeat_day_of_month 否 uint32[] 每月哪几天重复
301 仅当指定为自定义重复且重复类型为每月时有效
302 取值范围:1 ~ 31,分别表示1~31号
303 schedule.reminders.timezone 否 uint32 时区。UTC偏移量表示(即偏离零时区的小时数),东区为正数,西区为负数。
304 例如:+8 表示北京时间东八区
305 默认为北京时间东八区
306 取值范围:-12 ~ +12
307 schedule.location 否 string 日程地址
308 不多于128个字符
309 schedule.start_time 是 uint32 日程开始时间,Unix时间戳
310 注意,如果op_mode是1或2,start_time和end_time,必须是op_start_time当天或之后的时间
311 schedule.end_time 是 uint32 日程结束时间,Unix时间戳
312 schedule.is_whole_day 否 uint32 是否更新成全天日程,0-否;1-是
313
314 =head3 关于自定义重复的说明:
315
316 is_custom_repeat 如果为0,那么系统会根据 start_time 和 repeat_type 来自动计算下一次重复的时间,例如:
317
318 start_time 为本周周三8点整,repeat_type 为每周重复,那么每周三8点整重复;
319 start_time 为本月3号10点整,repeat_type 为每月重复,那么每月3号10点整重复;
320 如果 is_custom_repeat 指定为1,那么可以配合 repeat_day_of_week 或 repeat_day_of_month 特别指定周几或几号重复,且可以使用 repeat_interval 指定重复间隔
321
322 =head3 RETURN 返回结果
323
324 {
325 "errcode": 0,
326 "errmsg" : "ok",
327 "schedule_id":"17c7d2bd9f20d652840f72f59e796AAA"
328 }
329
330 =head3 RETURN 参数说明
331
332 参数 类型 说明
333 errcode int32 返回码
334 errmsg string 错误码描述
335 schedule_id string 修改重复日程新产生的日程ID。对于重复日程,如果不是修改全部周期,会修剪原重复日程,产生新的重复日程,此时会返回新日程的ID
336
337 =cut
338
339 sub update {
340 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
341 my $access_token = $_[0];
342 my $json = $_[1];
343 my $ua = LWP::UserAgent->new;
344 $ua->timeout(30);
345 $ua->env_proxy;
346
347 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/update?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
348 if ($response->is_success) {
349 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
350 }
351
352 }
353 return 0;
354 }
355
356 =head2 add_attendees(access_token, hash);
357
358 新增日程参与者
359 最后更新:2023/05/16
360
361 =head2 SYNOPSIS
362
363 L<https://developer.work.weixin.qq.com/document/path/97721>
364
365 =head3 请求说明:
366
367 该接口用于在日历中更新指定的日程参与者列表
368
369 注意,该接口是增量式
370
371 =head4 请求包结构体为:
372
373 {
374 "schedule_id": "17c7d2bd9f20d652840f72f59e796AAA",
375 "attendees": [{
376 "userid": "userid2"
377 }]
378 }
379
380 =head4 参数说明:
381
382 参数 必须 类型 说明
383 access_token 是 string 调用接口凭证
384 schedule_id 是 string 日程ID。创建日程时返回的ID
385 attendees 否 obj[] 日程参与者列表。累计最多支持1000人
386 attendees.userid 是 string 日程参与者ID
387 不多于64字节
388
389 =head3 权限说明
390
391 =head3 RETURN 返回结果
392
393 {
394 "errcode": 0,
395 "errmsg": "ok"
396 }
397
398 =head3 RETURN 参数说明
399
400 参数 类型 说明
401 errcode int32 返回码
402 errmsg string 错误码描述
403
404 =cut
405
406 sub add_attendees {
407 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
408 my $access_token = $_[0];
409 my $json = $_[1];
410 my $ua = LWP::UserAgent->new;
411 $ua->timeout(30);
412 $ua->env_proxy;
413
414 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/add_attendees?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
415 if ($response->is_success) {
416 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
417 }
418
419 }
420 return 0;
421 }
422
423 =head2 del_attendees(access_token, hash);
424
425 删除日程参与者
426 最后更新:2022/12/06
427
428 =head2 SYNOPSIS
429
430 L<https://developer.work.weixin.qq.com/document/path/97722>
431
432 =head3 请求说明:
433
434 该接口用于在日历中更新指定的日程参与者列表
435
436 注意,该接口是增量式
437
438 =head4 请求包结构体为:
439
440 {
441 "schedule_id": "17c7d2bd9f20d652840f72f59e796AAA",
442 "attendees": [{
443 "userid": "userid2"
444 }]
445 }
446
447 =head4 参数说明:
448
449 参数 必须 类型 说明
450 access_token 是 string 调用接口凭证
451 schedule_id 是 string 日程ID。创建日程时返回的ID
452 attendees 否 obj[] 日程参与者列表。最多支持300人
453 attendees.userid 是 string 日程参与者ID
454 不多于64字节
455
456 =head3 权限说明
457
458 =head3 RETURN 返回结果
459
460 {
461 "errcode": 0,
462 "errmsg": "ok"
463 }
464
465 =head3 RETURN 参数说明
466
467 参数 类型 说明
468 errcode int32 返回码
469 errmsg string 错误码描述
470
471 =cut
472
473 sub del_attendees {
474 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
475 my $access_token = $_[0];
476 my $json = $_[1];
477 my $ua = LWP::UserAgent->new;
478 $ua->timeout(30);
479 $ua->env_proxy;
480
481 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/del_attendees?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
482 if ($response->is_success) {
483 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
484 }
485
486 }
487 return 0;
488 }
489
490 =head2 get_by_calendar(access_token, hash);
491
492 获取日历下的日程列表
493 最后更新:2022/12/06
494
495 =head2 SYNOPSIS
496
497 L<https://developer.work.weixin.qq.com/document/path/97723>
498
499 =head3 请求说明:
500
501 该接口用于获取指定的日历下的日程列表。
502 仅可获取应用自己创建的日历下的日程。
503
504 =head4 请求包结构体为:
505
506 {
507 "cal_id": "wcjgewCwAAqeJcPI1d8Pwbjt7nttzAAA",
508 "offset" : 100,
509 "limit" : 1000
510 }
511
512 =head4 参数说明:
513
514 参数 是否必须 说明
515 access_token 是 调用接口凭证
516 cal_id 是 日历ID
517 offset 否 分页,偏移量, 默认为0
518 limit 否 分页,预期请求的数据量,默认为500,取值范围 1 ~ 1000
519
520 =head3 权限说明
521
522 当日程较多时,需要使用参数是offset及limit 分页获取,注意offset是以0为起点,
523 当获取到的 schedule_list 是空的时候,表示offset已经过大,此时应终止获取。若有新增日程,可在此基础上继续增量获取。
524
525 =head3 RETURN 返回结果
526
527 {
528 "errcode": 0,
529 "errmsg": "ok",
530 "schedule_list": [{
531 "schedule_id": "17c7d2bd9f20d652840f72f59e796AAA",
532 "sequence": 100,
533 "admins": [
534 "admin1",
535 "admin2"
536 ],
537 "attendees": [{
538 "userid": "userid1",
539 "response_status": 0
540 }],
541 "summary": "test_summary",
542 "description": "test_content",
543 "reminders": {
544 "is_remind": 1,
545 "is_repeat": 1,
546 "remind_before_event_secs": 3600,
547 "repeat_type": 7,
548 "repeat_until": 1606976813,
549 "is_custom_repeat": 1,
550 "repeat_interval": 1,
551 "repeat_day_of_week": [3, 7],
552 "repeat_day_of_month": [10, 21],
553 "timezone": 8
554 },
555 "location": "test_place",
556 "start_time": 1571274600,
557 "end_time": 1571320210,
558 "status": 1,
559 "cal_id": "wcjgewCwAAqeJcPI1d8Pwbjt7nttzAAA"
560 }]
561 }
562
563 =head3 RETURN 参数说明
564
565 参数 类型 说明
566 errcode int32 返回码
567 errmsg string 错误码描述
568 schedule_list obj[] 日程列表
569 schedule_list.schedule_id string 日程ID
570 schedule_list.admins string 管理员userid列表
571 schedule_list.attendees obj[] 日程参与者列表。最多支持300人
572 schedule_list.attendees.userid string 日程参与者ID
573 schedule_list.attendees.response_status uint32 日程参与者的接受状态。
574 0 - 未处理
575 1 - 待定
576 2 - 全部接受
577 3 - 仅接受一次
578 4 - 拒绝
579 schedule_list.summary string 日程标题
580 schedule_list.description string 日程描述
581 schedule_list.reminders obj 提醒相关信息
582 schedule_list.reminders.is_remind int32 是否需要提醒。0-否;1-是
583 schedule_list.reminders.is_repeat int32 是否重复日程。0-否;1-是
584 schedule_list.reminders.remind_before_event_secs uint32 日程开始(start_time)前多少秒提醒,当is_remind为1时有效。例如: 300表示日程开始前5分钟提醒。目前仅支持以下数值:
585 0 - 事件开始时
586 300 - 事件开始前5分钟
587 900 - 事件开始前15分钟
588 3600 - 事件开始前1小时
589 86400 - 事件开始前1天
590 schedule_list.reminders.repeat_type uint32 重复类型,当is_repeat为1时有效。目前支持如下类型:
591 0 - 每日
592 1 - 每周
593 2 - 每月
594 5 - 每年
595 7 - 工作日
596 schedule_list.reminders.repeat_until uint32 重复结束时刻,Unix时间戳。不填或填0表示一直重复
597 schedule_list.reminders.is_custom_repeat uint32 是否自定义重复。0-否;1-是
598 schedule_list.reminders.repeat_interval uint32 重复间隔
599 仅当指定为自定义重复时有效
600 该字段随repeat_type不同而含义不同
601 例如:
602 repeat_interval指定为2,repeat_type指定为每周重复,那么每2周重复一次;
603 repeat_interval指定为2,repeat_type指定为每月重复,那么每2月重复一次
604 schedule_list.reminders.repeat_day_of_week uint32[] 每周周几重复
605 仅当指定为自定义重复且重复类型为每周时有效
606 取值范围:1 ~ 7,分别表示周一至周日
607 schedule_list.reminders.repeat_day_of_month uint32[] 每月哪几天重复
608 仅当指定为自定义重复且重复类型为每月时有效
609 取值范围:1 ~ 31,分别表示1~31号
610 schedule_list.reminders.timezone uint32 时区。UTC偏移量表示(即偏离零时区的小时数),东区为正数,西区为负数。
611 例如:+8 表示北京时间东八区
612 默认为北京时间东八区
613 取值范围:-12 ~ +12
614 schedule_list.location string 日程地址
615 不多于128个字符
616 schedule_list.status uint32 日程状态。0-正常;1-已取消
617 schedule_list.start_time uint32 日程开始时间,Unix时间戳
618 schedule_list.end_time uint32 日程结束时间,Unix时间戳
619 schedule_list.sequence uint64 日程编号,是一个自增数字
620 schedule_list.cal_id string 日程所属日历ID。不多于64字节
621
622 注意,被取消的日程也可以拉取详情,调用者需要检查status
623
624 =cut
625
626 sub get_by_calendar {
627 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
628 my $access_token = $_[0];
629 my $json = $_[1];
630 my $ua = LWP::UserAgent->new;
631 $ua->timeout(30);
632 $ua->env_proxy;
633
634 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/get_by_calendar?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
635 if ($response->is_success) {
636 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
637 }
638
639 }
640 return 0;
641 }
642
643 =head2 get(access_token, hash);
644
645 获取日程详情
646 最后更新:2023/06/16
647
648 =head2 SYNOPSIS
649
650 L<https://developer.work.weixin.qq.com/document/path/97724>
651
652 =head3 请求说明:
653
654 该接口用于获取指定的日程详情。
655
656 =head4 请求包结构体为:
657
658 {
659 "schedule_id_list": [
660 "17c7d2bd9f20d652840f72f59e796AAA"
661 ]
662 }
663
664 =head4 参数说明:
665
666 参数 是否必须 说明
667 access_token 是 调用接口凭证
668 schedule_id_list 是 日程ID列表。一次最多拉取1000条
669
670 =head3 权限说明
671
672 =head3 RETURN 返回结果
673
674 {
675 "errcode": 0,
676 "errmsg": "ok",
677 "schedule_list": [{
678 "schedule_id": "17c7d2bd9f20d652840f72f59e796AAA",
679 "admins":[
680 "admin1",
681 "admin2"
682 ],
683 "attendees": [{
684 "userid": "userid2",
685 "response_status": 1
686 }],
687 "summary": "test_summary",
688 "description": "test_content",
689 "reminders": {
690 "is_remind": 1,
691 "is_repeat": 1,
692 "remind_before_event_secs": 3600,
693 "remind_time_diffs": [-3600],
694 "repeat_type": 7,
695 "repeat_until": 1606976813,
696 "is_custom_repeat": 1,
697 "repeat_interval": 1,
698 "repeat_day_of_week": [3, 7],
699 "repeat_day_of_month": [10, 21],
700 "timezone": 8,
701 "exclude_time_list": [{
702 "start_time": 1571361000
703 }]
704 },
705 "location": "test_place",
706 "cal_id": "wcjgewCwAAqeJcPI1d8Pwbjt7nttzAAA",
707 "start_time": 1571274600,
708 "end_time": 1571579410,
709 "status": 1,
710 "is_whole_day":1
711 }]
712 }
713
714 =head3 RETURN 参数说明
715
716 参数 类型 说明
717 errcode int32 返回码
718 errmsg string 错误码描述
719 schedule_list obj[] 日程列表
720 schedule_list.schedule_id string 日程ID
721 schedule_list.admins string 管理员userid列表
722 schedule_list.attendees obj[] 日程参与者列表。最多支持300人
723 schedule_list.attendees.userid string 日程参与者ID
724 schedule_list.attendees.response_status uint32 日程参与者的接受状态。
725 0 - 未处理
726 1 - 待定
727 2 - 全部接受
728 3 - 仅接受一次
729 4 - 拒绝
730 schedule_list.summary string 日程标题
731 schedule_list.description string 日程描述
732 schedule_list.reminders obj 提醒相关信息
733 schedule_list.reminders.is_remind int32 是否需要提醒。0-否;1-是
734 schedule_list.reminders.is_repeat int32 是否重复日程。0-否;1-是
735 schedule_list.reminders.remind_before_event_secs uint32 日程开始(start_time)前多少秒提醒,当is_remind为1时有效。例如: 300表示日程开始前5分钟提醒。目前仅支持以下数值:
736 0 - 事件开始时
737 300 - 事件开始前5分钟
738 900 - 事件开始前15分钟
739 3600 - 事件开始前1小时
740 86400 - 事件开始前1天
741 注意:建议使用 remind_time_diffs 字段,该字段后续将会废弃。
742 schedule_list.reminders.remind_time_diffs int32[] 提醒时间与日程开始时间(start_time)的差值,当is_remind为1时有效。例如:-300表示日程开始前5分钟提醒。
743 特殊情况:企业微信终端设置的“全天”类型的日程,由于start_time是0点时间戳,提醒如果设置了当天9点,则会出现正数32400。
744 取值范围:-604800 ~ 86399
745 schedule_list.reminders.repeat_type uint32 重复类型,当is_repeat为1时有效。目前支持如下类型:
746 0 - 每日
747 1 - 每周
748 2 - 每月
749 5 - 每年
750 7 - 工作日
751 schedule_list.reminders.repeat_until uint32 重复结束时刻,Unix时间戳。不填或填0表示一直重复
752 schedule_list.reminders.is_custom_repeat uint32 是否自定义重复。0-否;1-是
753 schedule_list.reminders.repeat_interval uint32 重复间隔
754 仅当指定为自定义重复时有效
755 该字段随repeat_type不同而含义不同
756 例如:
757 repeat_interval指定为2,repeat_type指定为每周重复,那么每2周重复一次;
758 repeat_interval指定为2,repeat_type指定为每月重复,那么每2月重复一次
759 schedule_list.reminders.repeat_day_of_week uint32[] 每周周几重复
760 仅当指定为自定义重复且重复类型为每周时有效
761 取值范围:1 ~ 7,分别表示周一至周日
762 schedule_list.reminders.repeat_day_of_month uint32[] 每月哪几天重复
763 仅当指定为自定义重复且重复类型为每月时有效
764 取值范围:1 ~ 31,分别表示1~31号
765 schedule_list.reminders.timezone uint32 时区。UTC偏移量表示(即偏离零时区的小时数),东区为正数,西区为负数。
766 例如:+8 表示北京时间东八区
767 默认为北京时间东八区
768 取值范围:-12 ~ +12
769 schedule_list.reminders.exclude_time_list obj[] 重复日程不包含的日期列表。对重复日程修改/删除特定一天或多天,则原来的日程将会排除对应的日期。
770 schedule_list.reminders.exclude_time_list.start_time uint32 不包含的日期时间戳。
771 schedule_list.location string 日程地址
772 不多于128个字符
773 schedule_list.status uint32 日程状态。0-正常;1-已取消
774 schedule_list.start_time uint32 日程开始时间,Unix时间戳
775 schedule_list.end_time uint32 日程结束时间,Unix时间戳
776 schedule_list.is_whole_day uint32 是否全天日程,0-否;1-是
777 schedule_list.cal_id string 日程所属日历ID。不多于64字节
778
779 注意,被取消的日程也可以拉取详情,调用者需要检查 status
780
781 =cut
782
783 sub get {
784 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
785 my $access_token = $_[0];
786 my $json = $_[1];
787 my $ua = LWP::UserAgent->new;
788 $ua->timeout(30);
789 $ua->env_proxy;
790
791 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/get?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
792 if ($response->is_success) {
793 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
794 }
795
796 }
797 return 0;
798 }
799
800 =head2 del(access_token, hash);
801
802 取消日程
803 最后更新:2022/12/01
804
805 =head2 SYNOPSIS
806
807 L<https://developer.work.weixin.qq.com/document/path/97725>
808
809 =head3 请求说明:
810
811 该接口用于取消指定的日程。
812
813 =head4 请求包结构体为:
814
815 {
816 "schedule_id": "17c7d2bd9f20d652840f72f59e796AAA",
817 "op_mode": 1,
818 "op_start_time": 1571274600
819 }
820
821 =head4 参数说明:
822
823 参数 是否必须 类型 说明
824 access_token 是 调用接口凭证
825 schedule_id 是 string 日程ID
826 op_mode 否 uint32 操作模式。是重复日程时有效。
827 0-默认删除所有日程;
828 1-仅删除此日程;
829 2-删除本次及后续日程
830 详见重复日程的不同操作模式
831 op_start_time 否 uint32 操作起始时间。仅当操作模式是1或2时有效。该时间必须是重复日程的某一次开始时间
832
833 =head3 权限说明
834
835 =head3 RETURN 返回结果
836
837 {
838 "errcode": 0,
839 "errmsg": "ok"
840 }
841
842 =head3 RETURN 参数说明
843
844 参数 说明
845 errcode 错误码
846 errmsg 错误码说明
847
848 =cut
849
850 sub del {
851 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
852 my $access_token = $_[0];
853 my $json = $_[1];
854 my $ua = LWP::UserAgent->new;
855 $ua->timeout(30);
856 $ua->env_proxy;
857
858 my $response = $ua->post("https://qyapi.weixin.qq.com/cgi-bin/oa/schedule/del?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
859 if ($response->is_success) {
860 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
861 }
862
863 }
864 return 0;
865 }
866
867
868 1;
869 __END__