Passed
Pull Request — master (#1714)
by
unknown
03:01
created

Client   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 165
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 38
dl 0
loc 165
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0
wmc 8

7 Methods

Rating   Name   Duplication   Size   Complexity  
A checkinRecords() 0 10 1
A checkinRules() 0 8 1
A approvalDetail() 0 7 1
A approvalTemplate() 0 7 1
A approvalRecords() 0 9 1
A createApproval() 0 13 1
A approvalNumbers() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[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 EasyWeChat\Work\OA;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author mingyoung <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * Get the checkin data.
25
     *
26
     * @param int   $startTime
27
     * @param int   $endTime
28
     * @param array $userList
29
     * @param int   $type
30
     *
31
     * @return mixed
32
     *
33
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
34
     * @throws \GuzzleHttp\Exception\GuzzleException
35
     */
36 1
    public function checkinRecords(int $startTime, int $endTime, array $userList, int $type = 3)
37
    {
38
        $params = [
39 1
            'opencheckindatatype' => $type,
40 1
            'starttime' => $startTime,
41 1
            'endtime' => $endTime,
42 1
            'useridlist' => $userList,
43
        ];
44
45 1
        return $this->httpPostJson('cgi-bin/checkin/getcheckindata', $params);
46
    }
47
48
    /**
49
     * Get the checkin rules.
50
     *
51
     * @param int   $datetime
52
     * @param array $userList
53
     *
54
     * @return mixed
55
     *
56
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
57
     * @throws \GuzzleHttp\Exception\GuzzleException
58
     */
59 1
    public function checkinRules(int $datetime, array $userList)
60
    {
61
        $params = [
62 1
            'datetime' => $datetime,
63 1
            'useridlist' => $userList,
64
        ];
65
66 1
        return $this->httpPostJson('cgi-bin/checkin/getcheckinoption', $params);
67
    }
68
69
    /**
70
     * Get approval template details.
71
     *
72
     * @param string $templateId
73
     *
74
     * @return mixed
75
     *
76
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
77
     * @throws \GuzzleHttp\Exception\GuzzleException
78
     */
79 1
    public function approvalTemplate(string $templateId)
80
    {
81
        $params = [
82 1
            'template_id' => $templateId,
83
        ];
84
85 1
        return $this->httpPostJson('cgi-bin/oa/gettemplatedetail', $params);
86
    }
87
88
    /**
89
     * Submit an application for approval.
90
     *
91
     * @param string $userId
92
     * @param string $templateId
93
     * @param array  $approver
94
     * @param array  $notifyer
95
     * @param int    $notifyType
96
     * @param array  $applyData
97
     * @param array  $summaryList
98
     *
99
     * @return mixed
100
     *
101
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
102
     * @throws \GuzzleHttp\Exception\GuzzleException
103
     */
104 1
    public function createApproval(string $userId, string $templateId, array $approver, array $notifyer = [], int $notifyType = 1, array $applyData, array $summaryList)
105
    {
106
        $params = [
107 1
            'creator_userid' => $userId,
108 1
            'template_id' => $templateId,
109 1
            'approver' => $approver,
110 1
            'notifyer' => $notifyer,
111 1
            'notify_type' => $notifyType,
112 1
            'apply_data' => $applyData,
113 1
            'summary_list' => $summaryList,
114
        ];
115
116 1
        return $this->httpPostJson('cgi-bin/oa/applyevent', $params);
117
    }
118
119
    /**
120
     * Get Approval number.
121
     *
122
     * @param int   $startTime
123
     * @param int   $endTime
124
     * @param int   $nextCursor
125
     * @param int   $size
126
     * @param array $filters
127
     *
128
     * @return mixed
129
     *
130
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
131
     * @throws \GuzzleHttp\Exception\GuzzleException
132
     */
133 1
    public function approvalNumbers(int $startTime, int $endTime, int $nextCursor = 0, int $size = 100, array $filters = [])
134
    {
135
        $params = [
136 1
            'starttime' => $startTime,
137 1
            'endtime' => $endTime,
138 1
            'cursor' => $nextCursor,
139 1
            'size' => $size > 100 ? 100 : $size,
140 1
            'filters' => $filters,
141
        ];
142
143 1
        return $this->httpPostJson('cgi-bin/oa/getapprovalinfo', $params);
144
    }
145
146
    /**
147
     * Get approval detail.
148
     *
149
     * @param int $number
150
     *
151
     * @return mixed
152
     *
153
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
154
     * @throws \GuzzleHttp\Exception\GuzzleException
155
     */
156 1
    public function approvalDetail(int $number)
157
    {
158
        $params = [
159 1
            'sp_no' => $number,
160
        ];
161
162 1
        return $this->httpPostJson('cgi-bin/oa/getapprovaldetail', $params);
163
    }
164
165
    /**
166
     * Get Approval Data.
167
     *
168
     * @param int $startTime
169
     * @param int $endTime
170
     * @param int $nextNumber
171
     *
172
     * @return mixed
173
     *
174
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
175
     * @throws \GuzzleHttp\Exception\GuzzleException
176
     */
177 1
    public function approvalRecords(int $startTime, int $endTime, int $nextNumber = null)
178
    {
179
        $params = [
180 1
            'starttime' => $startTime,
181 1
            'endtime' => $endTime,
182 1
            'next_spnum' => $nextNumber,
183
        ];
184
185 1
        return $this->httpPostJson('cgi-bin/corp/getapprovaldata', $params);
186
    }
187
}
188