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\Schedule; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\BaseClient; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Client. |
18
|
|
|
* |
19
|
|
|
* @author her-cat <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class Client extends BaseClient |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Add a schedule. |
25
|
|
|
* |
26
|
|
|
* @param array $schedule |
27
|
|
|
* |
28
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
29
|
|
|
* |
30
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
31
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
32
|
|
|
*/ |
33
|
|
|
public function add(array $schedule) |
34
|
|
|
{ |
35
|
|
|
return $this->httpPostJson('cgi-bin/oa/schedule/add', compact('schedule')); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Update the schedule. |
40
|
|
|
* |
41
|
|
|
* @param string $id |
42
|
|
|
* @param array $schedule |
43
|
|
|
* |
44
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
45
|
|
|
* |
46
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
47
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
48
|
|
|
*/ |
49
|
|
|
public function update(string $id, array $schedule) |
50
|
|
|
{ |
51
|
|
|
$schedule += ['schedule_id' => $id]; |
52
|
|
|
|
53
|
|
|
return $this->httpPostJson('cgi-bin/oa/schedule/update', compact('schedule')); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get one or more schedules. |
58
|
|
|
* |
59
|
|
|
* @param string|array $ids |
60
|
|
|
* |
61
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
62
|
|
|
* |
63
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
64
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
65
|
|
|
*/ |
66
|
|
|
public function get($ids) |
67
|
|
|
{ |
68
|
|
|
return $this->httpPostJson('cgi-bin/oa/schedule/get', ['schedule_id_list' => (array) $ids]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Get the list of schedules under a calendar. |
73
|
|
|
* |
74
|
|
|
* @param string $calendarId |
75
|
|
|
* @param int $offset |
76
|
|
|
* @param int $limit |
77
|
|
|
* |
78
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
79
|
|
|
* |
80
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
81
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
82
|
|
|
*/ |
83
|
|
|
public function getByCalendar(string $calendarId, int $offset = 0, int $limit = 500) |
84
|
|
|
{ |
85
|
|
|
$data = compact('offset', 'limit') + ['cal_id' => $calendarId]; |
86
|
|
|
|
87
|
|
|
return $this->httpPostJson('cgi-bin/oa/schedule/get_by_calendar', $data); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Delete a schedule. |
92
|
|
|
* |
93
|
|
|
* @param string $id |
94
|
|
|
* |
95
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
96
|
|
|
* |
97
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
98
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
99
|
|
|
*/ |
100
|
|
|
public function delete(string $id) |
101
|
|
|
{ |
102
|
|
|
return $this->httpPostJson('cgi-bin/oa/schedule/del', ['schedule_id' => $id]); |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|