exmail/log.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%
mailstatus
12.0
mail
12.0
login
12.0
CRAP 9.1
1 package QQ::exmail::log;
2
3 =encoding utf8
4
5 =head1 Name
6
7 QQ::exmail::log
8
9 =head1 DESCRIPTION
10
11 系统日志
12
13 =cut
14
15 use strict;
16 use base qw(QQ::exmail);
17 use Encode;
18 use LWP::UserAgent;
19 use JSON;
20 use utf8;
21
22 our $VERSION = '1.10';
23 our @EXPORT = qw/ mailstatus mail login batchjob operation /;
24
25 =head1 FUNCTION
26
27 =head2 mailstatus(access_token, hash);
28
29 查询邮件概况
30
31 =head2 SYNOPSIS
32
33 L<https://exmail.qq.com/qy_mng_logic/doc#10027>
34
35 =head3 请求说明:
36
37 =head4 请求包结构体为:
38
39 {
40 "domain": "gzdev.com",
41 "begin_date": "2016-10-01",
42 "end_date": "2016-10-07"
43 }
44
45 =head4 参数说明:
46
47 参数 必须 说明
48 access_token 是 调用接口凭证
49 domain 是 域名
50 begin_date 是 开始日期。格式为2016-10-01
51 end_date 是 结束日期。格式为2016-10-07
52
53 =head3 RETURN 返回结果
54
55 {
56 "errcode": 0,
57 "errmsg": "ok",
58 "sendsum": 10,
59 "recvsum": 15
60 }
61
62 =head4 RETURN 参数说明
63
64 参数 说明
65 errcode 返回码
66 errmsg 对返回码的文本描述内容
67 sendsum 发信总量
68 recvsum 收信总量
69
70 =cut
71
72 sub mailstatus {
73 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
74 my $access_token = $_[0];
75 my $json = $_[1];
76 my $ua = LWP::UserAgent->new;
77 $ua->timeout(30);
78 $ua->env_proxy;
79
80 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/log/mailstatus?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
81 if ($response->is_success) {
82 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
83 }
84
85 }
86 return 0;
87 }
88
89 =head2 mail(access_token, hash);
90
91 查询邮件
92
93 =head2 SYNOPSIS
94
95 L<https://exmail.qq.com/qy_mng_logic/doc#10028>
96
97 =head3 请求说明:
98
99 =head4 请求包结构体为:
100
101 {
102 "begin_date": "2016-10-01",
103 "end_date": "2016-10-07",
104 "mailtype": 1,
105 "userid":"zhangsanp@gzdev.com",
106 "subject":"test"
107 }
108
109 =head4 参数说明:
110
111 参数 必须 说明
112 access_token 是 调用接口凭证
113 begin_date 是 开始日期。格式为2016-10-01
114 end_date 是 开始日期。格式为2016-10-07
115 mailtype 是 邮件类型。0:收信+发信 1:发信 2:收信
116 userid 否 筛选条件:指定成员帐号
117 subject 否 筛选条件:包含指定主题内容
118
119 =head3 RETURN 返回结果
120
121 {
122 "errcode": 0,
123 "errmsg": "ok",
124 "list": [
125 {
126 "mailtype":1,
127 "subject":"testLog",
128 "sender":"zhangsanp@gzdev.com",
129 "receiver":
130 "lisi@gzdev.com",
131 "time": 1475337600,
132 "status":3
133 }
134 ]
135 }
136
137 =head4 RETURN 参数说明
138
139 参数 说明
140 errcode 返回码
141 errmsg 对返回码的文本描述内容
142 list 列表数据
143 mailtype 邮件类型。1:发信 2:收信
144 sender 发信者
145 receiver 收信者
146 time 时间(时间戳格式)
147 status 邮件状态
148 0: 其他状态
149 1: 发信中
150 2: 被退信
151 3: 发信成功
152 4: 发信失败
153 11: 收信被拦截
154 12: 收信,邮件进入垃圾箱
155 13: 收信成功,邮件在收件箱
156 14: 收信成功,邮件在个人文件夹
157
158 =cut
159
160 sub mail {
161 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
162 my $access_token = $_[0];
163 my $json = $_[1];
164 my $ua = LWP::UserAgent->new;
165 $ua->timeout(30);
166 $ua->env_proxy;
167
168 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/log/mail?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
169 if ($response->is_success) {
170 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
171 }
172
173 }
174 return 0;
175 }
176
177 =head2 login(access_token, hash);
178
179 查询成员登录
180
181 =head2 SYNOPSIS
182
183 L<https://exmail.qq.com/qy_mng_logic/doc#10029>
184
185 =head3 请求说明:
186
187 =head4 请求包结构体为:
188
189 {
190 "begin_date": "2016-10-01",
191 "end_date": "2016-10-07",
192 "mailtype": 1,
193 "userid":"zhangsanp@gzdev.com",
194 "subject":"test"
195 }
196
197 =head4 参数说明:
198
199 参数 必须 说明
200 access_token 是 调用接口凭证
201 userid 是 成员UserID。企业邮帐号名,邮箱格式-10-01
202 begin_date 是 开始日期。格式为2016-10-01
203 end_date 是 结束日期。格式为2016-10-07
204
205 =head3 RETURN 返回结果
206
207 {
208 "errcode": 0,
209 "errmsg": "ok",
210 "list": [
211 { "time": 1475337600, "ip":"127.0.01", "type":1}
212 ]
213 }
214
215 =head4 RETURN 参数说明
216
217 参数 说明
218 errcode 返回码
219 errmsg 对返回码的文本描述内容
220 list 列表数据
221 time 时间(时间戳格式)
222 ip 登录ip
223 type 登录类型
224 1:网页登录
225 2:手机登录
226 3:QQ邮箱App登录
227 4:客户端登录:包括imap,pop,exchange
228 5:其他登录方式
229
230 =cut
231
232 sub login {
233 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
234 my $access_token = $_[0];
235 my $json = $_[1];
236 my $ua = LWP::UserAgent->new;
237 $ua->timeout(30);
238 $ua->env_proxy;
239
240 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/log/login?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
241 if ($response->is_success) {
242 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
243 }
244
245 }
246 return 0;
247 }
248
249 =head2 batchjob(access_token, hash);
250
251 查询批量任务
252
253 =head2 SYNOPSIS
254
255 L<https://exmail.qq.com/qy_mng_logic/doc#10030>
256
257 =head3 请求说明:
258
259 =head4 请求包结构体为:
260
261 {
262 "begin_date": "2016-10-01",
263 "end_date": "2016-10-07"
264 }
265
266 =head4 参数说明:
267
268 参数 必须 说明
269 access_token 是 调用接口凭证
270 begin_date 是 开始日期。格式为2016-10-01
271 end_date 是 结束日期。格式为2016-10-07
272
273 =head3 RETURN 返回结果
274
275 {
276 "errcode": 0,
277 "errmsg": "ok",
278 "list": [
279 {
280 "time": 1475337600,
281 "operator": "administrator",
282 "type": 1,
283 "status": 1
284 }
285 ]
286 }
287
288 =head4 RETURN 参数说明
289
290 参数 说明
291 errcode 返回码
292 errmsg 对返回码的文本描述内容
293 list 列表数据
294 time 时间(时间戳格式)
295 operator 操作人员
296 type 操作类型
297 1:群发邮件
298 2:批量导入成员
299 3:删除公告
300 4:批量添加别名
301 5:发布公告
302 6:RTX帐号关联
303 7:设置企业签名档
304 8:取消企业签名档
305 9:开通成员
306 0:其他
307
308 =cut
309
310 sub batchjob {
311 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
312 my $access_token = $_[0];
313 my $json = $_[1];
314 my $ua = LWP::UserAgent->new;
315 $ua->timeout(30);
316 $ua->env_proxy;
317
318 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/log/batchjob?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
319 if ($response->is_success) {
320 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
321 }
322
323 }
324 return 0;
325 }
326
327 =head2 operation(access_token, hash);
328
329 查询操作记录
330
331 =head2 SYNOPSIS
332
333 L<https://exmail.qq.com/qy_mng_logic/doc#10031>
334
335 =head3 请求说明:
336
337 =head4 请求包结构体为:
338
339 {
340 "type": 0,
341 "begin_date": "2016-10-01",
342 "end_date": "2016-10-07"
343 }
344
345 =head4 参数说明:
346
347 参数 必须 说明
348 access_token 是 调用接口凭证
349 type 是 类型
350 1:all
351 2:开放协议同步
352 3:编辑管理员帐号
353 4:设置分级管理员
354 5:编辑企业信息
355 6:收信黑名单设置
356 7:邮件转移设置
357 8:成员与群组管理
358 9:邮件备份管理
359 10:成员权限控制
360 begin_date 是 开始日期。格式为2016-10-01
361 end_date 是 结束日期。格式为2016-10-07
362
363 =head3 RETURN 返回结果
364
365 {
366 "errcode": 0,
367 "errmsg": "ok",
368 "list": [
369 {
370 "time": 1475337600,
371 "operator": "administrator",
372 "type": 19,
373 "operand": "zhangsanp@gzdev.com"
374 }
375 ]
376 }
377
378 =head4 RETURN 参数说明
379
380 参数 说明
381 errcode 返回码
382 errmsg 对返回码的文本描述内容
383 list 列表数据
384 time 时间(时间戳格式)
385 operator 操作人员
386 type 登录类型
387 1:登录
388 2:修改密码
389 3:添加域名
390 4:注销域名
391 5:设置LOGO
392 6:删除LOGO
393 7:修改密保邮箱
394 8:修改管理员邮箱
395 9:发表公告
396 10:群发邮件
397 11:新增黑名单
398 12:删除黑名单
399 13:清空黑名单
400 14:新增白名单
401 15:删除白名单
402 16:清空白名单
403 17:新增域白名单
404 18:删除域白名单
405 19:新增用户
406 20:删除用户
407 21:启用用户
408 22:禁用用户
409 23:编辑用户
410 24:编辑别名
411 25:批量导入用户
412 26:添加分级管理员
413 27:删除分级管理员
414 28:新增部门
415 29:删除部门
416 30:编辑部门
417 31:移动部门
418 32:新增邮件组
419 33:删除邮件组
420 34:编辑邮件组
421 35:设置邮件备份
422 36:邮件转移
423 37:IP登录权限
424 38:限制成员外发
425 39:开启接口
426 40:重新获取KEY
427 41:停用接口
428 operand 关联数据
429 remark 备注信息:
430 若type=20, remark=1表示帐号已还原
431
432 =cut
433
434 sub operation {
435 if ( @_ && $_[0] && ref $_[1] eq 'HASH' ) {
436 my $access_token = $_[0];
437 my $json = $_[1];
438 my $ua = LWP::UserAgent->new;
439 $ua->timeout(30);
440 $ua->env_proxy;
441
442 my $response = $ua->post("https://api.exmail.qq.com/cgi-bin/log/operation?access_token=$access_token",Content => to_json($json,{allow_nonref=>1}),Content_type =>'application/json');
443 if ($response->is_success) {
444 return from_json($response->decoded_content,{utf8 => 1, allow_nonref => 1});
445 }
446
447 }
448 return 0;
449 }
450
451
452 1;
453 __END__