1 | <?php |
||
15 | class Comments |
||
16 | { |
||
17 | /** |
||
18 | * @var Client |
||
19 | */ |
||
20 | private $client; |
||
21 | |||
22 | 1 | public function __construct(Client $client) |
|
23 | { |
||
24 | 1 | $this->client = $client; |
|
25 | 1 | } |
|
26 | |||
27 | /** |
||
28 | * Get record comments |
||
29 | * https://cybozudev.zendesk.com/hc/ja/articles/208242326 |
||
30 | * |
||
31 | * @param int $appId |
||
32 | * @param int $recordId |
||
33 | * @param string $order "asc" or "desc" |
||
34 | * @param int $offset |
||
35 | * @param int $limit Max = 10 |
||
36 | * @param int $guestSpaceId |
||
37 | * @return array |
||
38 | */ |
||
39 | 2 | public function get($appId, $recordId, $order = 'desc', $offset = 0, $limit = 10, $guestSpaceId = null) |
|
40 | { |
||
41 | $options = ['json' => [ |
||
42 | 2 | 'app' => $appId, |
|
43 | 2 | 'record' => $recordId, |
|
44 | 2 | 'order' => $order, |
|
45 | 2 | 'offset' => $offset, |
|
46 | 'limit' => $limit |
||
47 | 2 | ]]; |
|
48 | |||
49 | /** @var JsonStream $stream */ |
||
50 | 2 | $stream = $this->client |
|
51 | 2 | ->get(KintoneApi::generateUrl('record/comments.json', $guestSpaceId), $options) |
|
52 | 2 | ->getBody(); |
|
53 | |||
54 | 2 | return $stream->jsonSerialize()['comments']; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param int $appId |
||
59 | * @param array $recordIds |
||
60 | * @param int|null $guestSpaceId |
||
61 | * @return array [recordId => comments, ...] |
||
62 | */ |
||
63 | 1 | public function allByRecords($appId, array $recordIds, $guestSpaceId = null) |
|
83 | |||
84 | /** |
||
85 | * @param integer $appId |
||
86 | * @param array $recordIds |
||
87 | * @param integer $guestSpaceId |
||
88 | * @param int $offset |
||
89 | * @return \Closure |
||
90 | */ |
||
91 | 1 | private function createGetRequestsCallback($appId, $recordIds, $guestSpaceId = null, $offset = 0) |
|
110 | |||
111 | /** |
||
112 | * @param array $result |
||
113 | * @param array $tmpIds |
||
114 | * @param array $ids |
||
115 | * @return \Closure |
||
116 | */ |
||
117 | 1 | private function createMergeCommentsCallback(array &$result, array &$tmpIds, array $ids) |
|
137 | |||
138 | /** |
||
139 | * @param int $appId |
||
140 | * @param array $comments [recordId => [['text' => 'comment message', 'mentions' => []], ...], ...] |
||
141 | * @param int|null $guestSpaceId |
||
142 | * @return array |
||
143 | */ |
||
144 | 1 | public function postByRecords($appId, $comments, $guestSpaceId = null) |
|
161 | |||
162 | /** |
||
163 | * @param int $appId |
||
164 | * @param array $comments |
||
165 | * @param int|null $guestSpaceId |
||
166 | * @return \Closure |
||
167 | */ |
||
168 | 1 | private function createPostRequestsCallback($appId, array $comments, $guestSpaceId = null) |
|
189 | |||
190 | /** |
||
191 | * @param array $result |
||
192 | * @param array $comments |
||
193 | * @return \Closure |
||
194 | */ |
||
195 | 1 | private function createPostFinishedAtCallback(array &$result, array &$comments) |
|
215 | } |
||
216 |