|
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')); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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); |
|
|
|
|
|
|
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)); |
|
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|