1 | <?php |
||
2 | /** |
||
3 | * This file is part of the dingtalk. |
||
4 | * User: Ilham Tahir <[email protected]> |
||
5 | * This source file is subject to the MIT license that is bundled |
||
6 | * with this source code in the file LICENSE. |
||
7 | */ |
||
8 | |||
9 | namespace Aplisin\DingTalk\Department; |
||
10 | |||
11 | use Aplisin\DingTalk\Kernel\BaseClient; |
||
12 | |||
13 | class Client extends BaseClient |
||
14 | { |
||
15 | /** |
||
16 | * @param int $id |
||
17 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
18 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
19 | */ |
||
20 | public function listIds($id = 1) |
||
21 | { |
||
22 | return $this->httpGet('/department/list_ids', compact('id')); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
23 | } |
||
24 | |||
25 | /** |
||
26 | * @param int $id |
||
27 | * @param bool $fetchChild |
||
28 | * @param string $lang |
||
29 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
30 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
31 | */ |
||
32 | public function list($id = 1, $fetchChild = false, $lang = 'zh_CN') |
||
33 | { |
||
34 | $params = [ |
||
35 | 'id' => $id, |
||
36 | 'fetch_child' => $fetchChild, |
||
37 | 'lang' => $lang |
||
38 | ]; |
||
39 | return $this->httpGet('/department/list', $params); |
||
0 ignored issues
–
show
|
|||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param int $id |
||
44 | * @param string $lang |
||
45 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
46 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
47 | */ |
||
48 | public function get(int $id, $lang = 'zh_CN') |
||
49 | { |
||
50 | $params = [ |
||
51 | 'id' => $id, |
||
52 | 'lang' => $lang |
||
53 | ]; |
||
54 | return $this->httpGet('/department/get', $params); |
||
0 ignored issues
–
show
|
|||
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param array $data |
||
59 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
60 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
61 | */ |
||
62 | public function create(array $data) |
||
63 | { |
||
64 | return $this->httpPostJson('/department/create', $data); |
||
0 ignored issues
–
show
|
|||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @param int $id |
||
69 | * @param array $data |
||
70 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
71 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
72 | */ |
||
73 | public function update(int $id, array $data) |
||
74 | { |
||
75 | return $this->httpPostJson('/department/update', array_merge(compact('id'), $data)); |
||
0 ignored issues
–
show
|
|||
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param int $id |
||
80 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
81 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
82 | */ |
||
83 | public function delete(int $id) |
||
84 | { |
||
85 | return $this->httpGet('/department/delete', compact('id')); |
||
0 ignored issues
–
show
|
|||
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param int $id |
||
90 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
91 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
92 | */ |
||
93 | public function listPrentDeptsByDept(int $id) |
||
94 | { |
||
95 | return $this->httpGet('/department/list_parent_depts_by_dept', compact('id')); |
||
0 ignored issues
–
show
|
|||
96 | } |
||
97 | |||
98 | /** |
||
99 | * @param int $userId |
||
100 | * @return \Aplisin\DingTalk\Kernel\Http\Response |
||
101 | * @throws \GuzzleHttp\Exception\GuzzleException |
||
102 | */ |
||
103 | public function listPrentDepts(int $userId) |
||
104 | { |
||
105 | return $this->httpGet('/department/list_parent_depts', compact('userId')); |
||
0 ignored issues
–
show
|
|||
106 | } |
||
107 | } |
||
108 |