1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the mingyoung/dingtalk. |
5
|
|
|
* |
6
|
|
|
* (c) mingyoung <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the MIT license that is bundled |
9
|
|
|
* with this source code in the file LICENSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace EasyDingTalk\Report; |
13
|
|
|
|
14
|
|
|
use EasyDingTalk\Application; |
15
|
|
|
use EasyDingTalk\Kernel\BaseClient; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Class Client. |
19
|
|
|
* |
20
|
|
|
* @author mingyoung <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class Client extends BaseClient |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* 查询企业员工发出的日志列表. |
26
|
|
|
* |
27
|
|
|
* @param int $startTime |
28
|
|
|
* @param int $endTime |
29
|
|
|
* @param int $cursor |
30
|
|
|
* @param int $size |
31
|
|
|
* @param string $templateName |
32
|
|
|
* @param string $userId |
33
|
|
|
* |
34
|
|
|
* @return array |
35
|
|
|
*/ |
36
|
|
|
public function list($startTime, $endTime, $cursor = 0, $size = 10, $templateName = null, $userId = null) |
37
|
|
|
{ |
38
|
|
|
$params = [ |
39
|
|
|
'start_time' => $startTime, |
40
|
|
|
'end_time' => $endTime, |
41
|
|
|
'cursor' => $cursor, |
42
|
|
|
'size' => $size, |
43
|
|
|
'template_name' => $templateName, |
44
|
|
|
'userid' => $userId, |
45
|
|
|
]; |
46
|
|
|
|
47
|
|
|
return Application::$useOApi |
|
|
|
|
48
|
|
|
? $this->httpPostJson('topapi/report/list', $params) |
49
|
|
|
: $this->httpGetMethod('dingtalk.corp.report.list', $params); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* 根据用户 ID 获取可见的日志模板列表. |
54
|
|
|
* |
55
|
|
|
* @param string $userId |
56
|
|
|
* @param int $offset |
57
|
|
|
* @param int $size |
58
|
|
|
* |
59
|
|
|
* @return array |
60
|
|
|
*/ |
61
|
|
|
public function templates($userId, $offset = null, $size = null) |
62
|
|
|
{ |
63
|
|
|
$params = [ |
64
|
|
|
'userid' => $userId, |
65
|
|
|
'offset' => $offset, |
66
|
|
|
'size' => $size, |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
return Application::$useOApi |
|
|
|
|
70
|
|
|
? $this->httpPostJson('topapi/report/template/listbyuserid', $params) |
71
|
|
|
: $this->httpGetMethod('dingtalk.oapi.report.template.listbyuserid', $params); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* 查询企业员工的日志未读数. |
76
|
|
|
* |
77
|
|
|
* @param string $userId |
78
|
|
|
* |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
public function getUnreadCount($userId = null) |
82
|
|
|
{ |
83
|
|
|
$params = [ |
84
|
|
|
'userid' => $userId, |
85
|
|
|
]; |
86
|
|
|
|
87
|
|
|
return Application::$useOApi |
|
|
|
|
88
|
|
|
? $this->httpPostJson('topapi/report/getunreadcount', $params) |
89
|
|
|
: $this->httpGetMethod('dingtalk.oapi.report.getunreadcount', $params); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* 获取日志统计数据 |
94
|
|
|
* |
95
|
|
|
* @param string $reportId |
96
|
|
|
* |
97
|
|
|
* @return array |
98
|
|
|
*/ |
99
|
|
|
public function statistics(string $reportId) |
100
|
|
|
{ |
101
|
|
|
$params = ['report_id' => $reportId]; |
102
|
|
|
|
103
|
|
|
return Application::$useOApi |
|
|
|
|
104
|
|
|
? $this->httpPostJson('topapi/report/statistics', $params) |
105
|
|
|
: $this->httpGetMethod('dingtalk.oapi.report.statistics', $params); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|