1 | <?php |
||
12 | class PreviewApp |
||
13 | { |
||
14 | /** |
||
15 | * @var Client |
||
16 | */ |
||
17 | private $client; |
||
18 | 2 | ||
19 | public function __construct(Client $client) |
||
20 | 2 | { |
|
21 | 2 | $this->client = $client; |
|
22 | } |
||
23 | |||
24 | /** |
||
25 | * Deploy app |
||
26 | * https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
||
27 | * |
||
28 | * @param integer $id |
||
29 | * @param integer $guestSpaceId |
||
30 | * @param integer $revision |
||
31 | * @param boolean $revert |
||
32 | * @return array |
||
33 | 19 | */ |
|
34 | public function deploy($id, $guestSpaceId = null, $revision = -1, $revert = false): array |
||
35 | 19 | { |
|
36 | 19 | return $this->deployApps([[ |
|
37 | 'app' => $id, |
||
38 | 19 | 'revision' => $revision |
|
39 | ]], $guestSpaceId, $revert); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Deploy apps |
||
44 | * https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
||
45 | * |
||
46 | * @param array $apps |
||
47 | * @param integer $guestSpaceId |
||
48 | * @param boolean $revert |
||
49 | * @return array |
||
50 | 19 | */ |
|
51 | public function deployApps(array $apps, $guestSpaceId = null, $revert = false): array |
||
52 | { |
||
53 | 19 | $options = ['json' => compact('apps', 'revert')]; |
|
54 | |||
55 | 19 | /** @var JsonStream $stream */ |
|
56 | $stream = $this->client |
||
57 | 19 | ->post(KintoneApi::generateUrl('preview/app/deploy.json', $guestSpaceId), $options) |
|
58 | 19 | ->getBody(); |
|
59 | 19 | ||
60 | return $stream->jsonSerialize(); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * get deploy status |
||
65 | * https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
||
66 | * |
||
67 | * @param integer $id |
||
68 | * @param integer $guestSpaceId |
||
69 | * @return array |
||
70 | 19 | */ |
|
71 | public function getDeployStatus($id, $guestSpaceId = null): array |
||
72 | 19 | { |
|
73 | return $this->getDeployStatuses([$id], $guestSpaceId)[0]; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * get deploy statuses |
||
78 | * https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
||
79 | * |
||
80 | * @param array $ids |
||
81 | * @param integer $guestSpaceId |
||
82 | * @return array |
||
83 | 19 | */ |
|
84 | public function getDeployStatuses(array $ids, $guestSpaceId = null): array |
||
85 | 19 | { |
|
86 | $options = ['json' => ['apps' => $ids]]; |
||
87 | 19 | ||
88 | 19 | /** @var JsonStream $stream */ |
|
89 | 19 | $stream = $this->client |
|
90 | ->get(KintoneApi::generateUrl('preview/app/deploy.json', $guestSpaceId), $options) |
||
91 | ->getBody(); |
||
92 | |||
93 | return $stream->jsonSerialize()['apps']; |
||
94 | } |
||
95 | |||
96 | /** |
||
97 | * Post preview app |
||
98 | * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1 |
||
99 | * |
||
100 | * @param string $name |
||
101 | * @param integer $spaceId |
||
102 | 28 | * @param integer $threadId |
|
103 | * @param integer $guestSpaceId |
||
104 | 28 | * @return array |
|
105 | 28 | */ |
|
106 | 28 | public function post($name, $spaceId = null, $threadId = null, $guestSpaceId = null): array |
|
107 | 28 | { |
|
108 | 28 | $options = ['json' => ['name' => $name]]; |
|
109 | if ($spaceId !== null) { |
||
110 | 28 | $options['json']['space'] = $spaceId; |
|
111 | 28 | $options['json']['thread'] = $threadId; |
|
112 | 28 | } |
|
113 | |||
114 | /** @var JsonStream $stream */ |
||
115 | $stream = $this->client |
||
116 | ->post(KintoneApi::generateUrl('preview/app.json', $guestSpaceId), $options) |
||
117 | ->getBody(); |
||
118 | |||
119 | return $stream->jsonSerialize(); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * Get app settings |
||
124 | 28 | * https://cybozudev.zendesk.com/hc/ja/articles/204694170 |
|
125 | 28 | * |
|
126 | 1 | * @param integer $id |
|
127 | * @param integer $guestSpaceId |
||
128 | 1 | * @param string $lang |
|
129 | 1 | * @return array |
|
130 | 1 | */ |
|
131 | public function getSettings($id, $guestSpaceId = null, $lang = 'default'): array |
||
132 | { |
||
133 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
||
134 | |||
135 | /** @var JsonStream $stream */ |
||
136 | $stream = $this->client |
||
137 | ->get(KintoneApi::generateUrl('preview/app/settings.json', $guestSpaceId), $options) |
||
138 | ->getBody(); |
||
139 | |||
140 | return $stream->jsonSerialize(); |
||
141 | } |
||
142 | 1 | ||
143 | /** |
||
144 | 1 | * Get app form fields |
|
145 | * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_fields |
||
146 | 1 | * |
|
147 | 1 | * @param integer $id |
|
148 | 1 | * @param integer $guestSpaceId |
|
149 | * @param string $lang |
||
150 | * @return array |
||
151 | */ |
||
152 | public function getFields($id, $guestSpaceId = null, $lang = 'default'): array |
||
153 | { |
||
154 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
||
155 | |||
156 | /** @var JsonStream $stream */ |
||
157 | $stream = $this->client |
||
158 | ->get(KintoneApi::generateUrl('preview/app/form/fields.json', $guestSpaceId), $options) |
||
159 | ->getBody(); |
||
160 | 1 | ||
161 | return $stream->jsonSerialize(); |
||
162 | 1 | } |
|
163 | |||
164 | 1 | /** |
|
165 | 1 | * Get app form layout |
|
166 | 1 | * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_layout |
|
167 | * |
||
168 | * @param integer $id |
||
169 | * @param integer $guestSpaceId |
||
170 | * @param string $lang |
||
171 | * @return array |
||
172 | */ |
||
173 | public function getLayout($id, $guestSpaceId = null, $lang = 'default'): array |
||
174 | { |
||
175 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
||
176 | |||
177 | /** @var JsonStream $stream */ |
||
178 | 1 | $stream = $this->client |
|
179 | ->get(KintoneApi::generateUrl('preview/app/form/layout.json', $guestSpaceId), $options) |
||
180 | 1 | ->getBody(); |
|
181 | |||
182 | 1 | return $stream->jsonSerialize(); |
|
183 | 1 | } |
|
184 | 1 | ||
185 | /** |
||
186 | * Get app views |
||
187 | * https://cybozudev.zendesk.com/hc/ja/articles/204529784 |
||
188 | * |
||
189 | * @param integer $id |
||
190 | * @param integer $guestSpaceId |
||
191 | * @param string $lang |
||
192 | * @return array |
||
193 | */ |
||
194 | public function getViews($id, $guestSpaceId = null, $lang = 'default'): array |
||
195 | { |
||
196 | 1 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
|
197 | |||
198 | 1 | /** @var JsonStream $stream */ |
|
199 | $stream = $this->client |
||
200 | 1 | ->get(KintoneApi::generateUrl('preview/app/views.json', $guestSpaceId), $options) |
|
201 | 1 | ->getBody(); |
|
202 | 1 | ||
203 | return $stream->jsonSerialize(); |
||
204 | } |
||
205 | |||
206 | /** |
||
207 | * Get app acl |
||
208 | * https://cybozudev.zendesk.com/hc/ja/articles/204529754 |
||
209 | * |
||
210 | * @param integer $id |
||
211 | * @param integer $guestSpaceId |
||
212 | * @param string $lang |
||
213 | * @return array |
||
214 | 1 | */ |
|
215 | public function getAcl($id, $guestSpaceId = null, $lang = 'default'): array |
||
216 | 1 | { |
|
217 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
||
218 | 1 | ||
219 | 1 | /** @var JsonStream $stream */ |
|
220 | 1 | $stream = $this->client |
|
221 | ->get(KintoneApi::generateUrl('preview/app/acl.json', $guestSpaceId), $options) |
||
222 | ->getBody(); |
||
223 | |||
224 | return $stream->jsonSerialize(); |
||
225 | } |
||
226 | |||
227 | /** |
||
228 | * Get record acl |
||
229 | * https://cybozudev.zendesk.com/hc/ja/articles/204791510 |
||
230 | * |
||
231 | * @param integer $id |
||
232 | 1 | * @param integer $guestSpaceId |
|
233 | * @param string $lang |
||
234 | 1 | * @return array |
|
235 | */ |
||
236 | 1 | public function getRecordAcl($id, $guestSpaceId = null, $lang = 'default'): array |
|
237 | 1 | { |
|
238 | 1 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
|
239 | |||
240 | /** @var JsonStream $stream */ |
||
241 | $stream = $this->client |
||
242 | ->get(KintoneApi::generateUrl('preview/record/acl.json', $guestSpaceId), $options) |
||
243 | ->getBody(); |
||
244 | |||
245 | return $stream->jsonSerialize(); |
||
246 | } |
||
247 | |||
248 | /** |
||
249 | 2 | * Get field acl |
|
250 | * https://cybozudev.zendesk.com/hc/ja/articles/204791520 |
||
251 | 2 | * |
|
252 | * @param integer $id |
||
253 | 2 | * @param integer $guestSpaceId |
|
254 | 2 | * @param string $lang |
|
255 | 2 | * @return array |
|
256 | */ |
||
257 | public function getFieldAcl($id, $guestSpaceId = null, $lang = 'default'): array |
||
258 | { |
||
259 | $options = ['json' => ['app' => $id, 'lang' => $lang]]; |
||
260 | |||
261 | /** @var JsonStream $stream */ |
||
262 | $stream = $this->client |
||
263 | ->get(KintoneApi::generateUrl('preview/field/acl.json', $guestSpaceId), $options) |
||
264 | ->getBody(); |
||
265 | |||
266 | return $stream->jsonSerialize(); |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * Get app JavaScript and CSS customize |
||
271 | 20 | * https://cybozudev.zendesk.com/hc/ja/articles/204529824 |
|
272 | * |
||
273 | * @param integer $id |
||
274 | 20 | * @param integer $guestSpaceId |
|
275 | 20 | * @return array |
|
276 | 20 | */ |
|
277 | 20 | public function getCustomize($id, $guestSpaceId = null): array |
|
288 | |||
289 | /** |
||
290 | * Get app status list |
||
291 | * https://cybozudev.zendesk.com/hc/ja/articles/216972946 |
||
292 | * |
||
293 | * @param integer $id |
||
294 | * @param string $lang |
||
295 | * @param integer $guestSpaceId |
||
296 | * @return array |
||
297 | 23 | */ |
|
298 | public function getStatus($id, $lang = 'ja', $guestSpaceId = null): array |
||
309 | |||
310 | /** |
||
311 | * Put preview app settings |
||
312 | * https://cybozudev.zendesk.com/hc/ja/articles/204730520 |
||
313 | * |
||
314 | * @param integer $id |
||
315 | * @param string $name |
||
316 | * @param string $description |
||
317 | * @param array $icon |
||
318 | * @param string $theme |
||
319 | * @param integer $guestSpaceId |
||
320 | 1 | * @param integer $revision |
|
321 | * @return array |
||
322 | */ |
||
323 | 1 | public function putSettings($id, $name, $description, array $icon, $theme, $guestSpaceId = null, $revision = -1): array |
|
341 | |||
342 | /** |
||
343 | 1 | * Post form fields to preview app |
|
344 | * https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_addfields |
||
345 | * |
||
346 | 1 | * @param integer $id |
|
347 | 1 | * @param array $fields |
|
348 | * @param integer $guestSpaceId |
||
349 | 1 | * @param integer $revision |
|
350 | * @return array |
||
351 | 1 | */ |
|
352 | 1 | public function postFields($id, array $fields, $guestSpaceId = null, $revision = -1): array |
|
367 | |||
368 | /** |
||
369 | 19 | * Put form fields to preview app |
|
370 | 19 | * https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_changefields |
|
371 | * |
||
372 | 19 | * @param integer $id |
|
373 | * @param array $fields |
||
374 | 19 | * @param integer $guestSpaceId |
|
375 | 19 | * @param integer $revision |
|
376 | 19 | * @return array |
|
377 | */ |
||
378 | public function putFields($id, array $fields, $guestSpaceId = null, $revision = -1): array |
||
393 | 20 | ||
394 | /** |
||
395 | 20 | * Delete form fields to preview app |
|
396 | * https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_deletefields |
||
397 | 20 | * |
|
398 | 20 | * @param integer $id |
|
399 | 20 | * @param array $fields |
|
400 | * @param integer $guestSpaceId |
||
401 | * @param integer $revision |
||
402 | * @return array |
||
403 | */ |
||
404 | public function deleteFields($id, array $fields, $guestSpaceId = null, $revision = -1): array |
||
419 | |||
420 | 1 | /** |
|
421 | 1 | * Put form layout to preview app |
|
422 | 1 | * https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_changelayout |
|
423 | * |
||
424 | * @param integer $id |
||
425 | * @param array $layout |
||
426 | * @param integer $guestSpaceId |
||
427 | * @param integer $revision |
||
428 | * @return array |
||
429 | */ |
||
430 | public function putLayout($id, array $layout, $guestSpaceId = null, $revision = -1): array |
||
445 | 1 | ||
446 | /** |
||
447 | * Put views to preview app |
||
448 | * https://cybozudev.zendesk.com/hc/ja/articles/204529794 |
||
449 | * |
||
450 | * @param integer $id |
||
451 | * @param array $views |
||
452 | * @param integer $guestSpaceId |
||
453 | * @param integer $revision |
||
454 | * @return array |
||
455 | */ |
||
456 | public function putViews($id, array $views, $guestSpaceId = null, $revision = -1): array |
||
471 | |||
472 | /** |
||
473 | * Put app acl to preview app |
||
474 | * https://cybozudev.zendesk.com/hc/ja/articles/201941844 |
||
475 | * |
||
476 | * @param integer $id |
||
477 | * @param array $rights |
||
478 | * @param integer $guestSpaceId |
||
479 | * @param integer $revision |
||
480 | * @return array |
||
481 | */ |
||
482 | public function putAcl($id, array $rights, $guestSpaceId = null, $revision = -1): array |
||
497 | 2 | ||
498 | /** |
||
499 | 2 | * Put record acl to preview app |
|
500 | 2 | * https://cybozudev.zendesk.com/hc/ja/articles/201941854 |
|
501 | 2 | * |
|
502 | * @param integer $id |
||
503 | * @param array $rights |
||
504 | * @param integer $guestSpaceId |
||
505 | * @param integer $revision |
||
506 | * @return array |
||
507 | */ |
||
508 | public function putRecordAcl($id, array $rights, $guestSpaceId = null, $revision = -1): array |
||
519 | |||
520 | /** |
||
521 | * Put field acl to preview app |
||
522 | * https://cybozudev.zendesk.com/hc/ja/articles/201941854 |
||
523 | * |
||
524 | * @param integer $id |
||
525 | * @param array $rights |
||
526 | * @param integer $guestSpaceId |
||
527 | * @param integer $revision |
||
528 | * @return array |
||
529 | */ |
||
530 | public function putFieldAcl($id, array $rights, $guestSpaceId = null, $revision = -1): array |
||
541 | |||
542 | /** |
||
543 | * Put app JavaScript & CSS customize to preview app |
||
544 | * https://cybozudev.zendesk.com/hc/ja/articles/204529834 |
||
545 | * |
||
546 | * @param integer $id |
||
547 | * @param array $js |
||
548 | * @param array $css |
||
549 | * @param array $mobileJs |
||
550 | * @param integer $guestSpaceId |
||
551 | * @param string $scope |
||
552 | * @param integer $revision |
||
553 | * @return array |
||
554 | */ |
||
555 | public function putCustomize($id, array $js = [], array $css = [], array $mobileJs = [], $guestSpaceId = null, $scope = 'ALL', $revision = -1): array |
||
574 | |||
575 | /** |
||
576 | * Put app status and action |
||
577 | * https://cybozudev.zendesk.com/hc/ja/articles/217905503 |
||
578 | * |
||
579 | * @param integer $id |
||
580 | * @param array $states |
||
581 | * @param array $actions |
||
582 | * @param boolean $enable |
||
583 | * @param integer $guestSpaceId |
||
584 | * @return array |
||
585 | */ |
||
586 | public function putStatus($id, array $states, array $actions, $enable = true, $guestSpaceId = null): array |
||
604 | } |
||
605 |