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\Calendar; |
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 calendar. |
25
|
|
|
* |
26
|
|
|
* @param array $calendar |
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 $calendar) |
34
|
|
|
{ |
35
|
|
|
return $this->httpPostJson('cgi-bin/oa/calendar/add', compact('calendar')); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Update the calendar. |
40
|
|
|
* |
41
|
|
|
* @param string $id |
42
|
|
|
* @param array $calendar |
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 $calendar) |
50
|
|
|
{ |
51
|
|
|
$calendar += ['cal_id' => $id]; |
52
|
|
|
|
53
|
|
|
return $this->httpPostJson('cgi-bin/oa/calendar/update', compact('calendar')); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get one or more calendars. |
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/calendar/get', ['cal_id_list' => (array) $ids]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Delete a calendar. |
73
|
|
|
* |
74
|
|
|
* @param string $id |
75
|
|
|
* |
76
|
|
|
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string |
77
|
|
|
* |
78
|
|
|
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException |
79
|
|
|
* @throws \GuzzleHttp\Exception\GuzzleException |
80
|
|
|
*/ |
81
|
|
|
public function delete(string $id) |
82
|
|
|
{ |
83
|
|
|
return $this->httpPostJson('cgi-bin/oa/calendar/del', ['cal_id' => $id]); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|