1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CybozuHttp\Api\Kintone; |
4
|
|
|
|
5
|
|
|
use CybozuHttp\Client; |
6
|
|
|
use CybozuHttp\Api\KintoneApi; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @author ochi51 <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class PreviewApp |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var Client |
15
|
|
|
*/ |
16
|
|
|
private $client; |
17
|
|
|
|
18
|
|
|
public function __construct(Client $client) |
19
|
|
|
{ |
20
|
|
|
$this->client = $client; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Deploy app |
25
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
26
|
|
|
* |
27
|
|
|
* @param integer $id |
28
|
|
|
* @param integer $guestSpaceId |
29
|
|
|
* @param integer $revision |
30
|
|
|
* @param boolean $revert |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
public function deploy($id, $guestSpaceId = null, $revision = -1, $revert = false) |
34
|
|
|
{ |
35
|
|
|
return $this->deployApps([[ |
36
|
|
|
'app' => $id, |
37
|
|
|
'revision' => $revision |
38
|
|
|
]], $guestSpaceId, $revert); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Deploy apps |
43
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
44
|
|
|
* |
45
|
|
|
* @param array $apps |
46
|
|
|
* @param integer $guestSpaceId |
47
|
|
|
* @param boolean $revert |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
public function deployApps(array $apps, $guestSpaceId = null, $revert = false) |
51
|
|
|
{ |
52
|
|
|
$options = ['json' => [ |
53
|
|
|
'apps' => $apps, |
54
|
|
|
'revert' => $revert |
55
|
|
|
]]; |
56
|
|
|
|
57
|
|
|
return $this->client |
|
|
|
|
58
|
|
|
->post(KintoneApi::generateUrl('preview/app/deploy.json', $guestSpaceId), $options) |
59
|
|
|
->getBody()->jsonSerialize(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* get deploy status |
64
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
65
|
|
|
* |
66
|
|
|
* @param integer $id |
67
|
|
|
* @param integer $guestSpaceId |
68
|
|
|
* @return array |
69
|
|
|
*/ |
70
|
|
|
public function getDeployStatus($id, $guestSpaceId = null) |
71
|
|
|
{ |
72
|
|
|
return $this->getDeployStatuses([$id], $guestSpaceId)[0]; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* get deploy statuses |
77
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204699420 |
78
|
|
|
* |
79
|
|
|
* @param array $ids |
80
|
|
|
* @param integer $guestSpaceId |
81
|
|
|
* @return array |
82
|
|
|
*/ |
83
|
|
|
public function getDeployStatuses(array $ids, $guestSpaceId = null) |
84
|
|
|
{ |
85
|
|
|
$options = ['json' => ['apps' => $ids]]; |
86
|
|
|
|
87
|
|
|
return $this->client |
|
|
|
|
88
|
|
|
->get(KintoneApi::generateUrl('preview/app/deploy.json', $guestSpaceId), $options) |
89
|
|
|
->getBody()->jsonSerialize()['apps']; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Post preview app |
94
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1 |
95
|
|
|
* |
96
|
|
|
* @param string $name |
97
|
|
|
* @param integer $spaceId |
98
|
|
|
* @param integer $threadId |
99
|
|
|
* @param integer $guestSpaceId |
100
|
|
|
* @return array |
101
|
|
|
*/ |
102
|
|
|
public function post($name, $spaceId = null, $threadId = null, $guestSpaceId = null) |
103
|
|
|
{ |
104
|
|
|
$options = ['json' => ['name' => $name]]; |
105
|
|
|
if ($spaceId !== null) { |
106
|
|
|
$options['json']['space'] = $spaceId; |
107
|
|
|
$options['json']['thread'] = $threadId; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
return $this->client |
|
|
|
|
111
|
|
|
->post(KintoneApi::generateUrl('preview/app.json', $guestSpaceId), $options) |
112
|
|
|
->getBody()->jsonSerialize(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Get app settings |
117
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204694170 |
118
|
|
|
* |
119
|
|
|
* @param integer $id |
120
|
|
|
* @param integer $guestSpaceId |
121
|
|
|
* @param string $lang |
122
|
|
|
* @return array |
123
|
|
|
*/ |
124
|
|
|
public function getSettings($id, $guestSpaceId = null, $lang = 'default') |
125
|
|
|
{ |
126
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
127
|
|
|
|
128
|
|
|
return $this->client |
|
|
|
|
129
|
|
|
->get(KintoneApi::generateUrl('preview/app/settings.json', $guestSpaceId), $options) |
130
|
|
|
->getBody()->jsonSerialize(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** |
134
|
|
|
* Get app form fields |
135
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_fields |
136
|
|
|
* |
137
|
|
|
* @param integer $id |
138
|
|
|
* @param integer $guestSpaceId |
139
|
|
|
* @param string $lang |
140
|
|
|
* @return array |
141
|
|
|
*/ |
142
|
|
|
public function getFields($id, $guestSpaceId = null, $lang = 'default') |
143
|
|
|
{ |
144
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
145
|
|
|
|
146
|
|
|
return $this->client |
|
|
|
|
147
|
|
|
->get(KintoneApi::generateUrl('preview/app/form/fields.json', $guestSpaceId), $options) |
148
|
|
|
->getBody()->jsonSerialize(); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Get app form layout |
153
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_layout |
154
|
|
|
* |
155
|
|
|
* @param integer $id |
156
|
|
|
* @param integer $guestSpaceId |
157
|
|
|
* @param string $lang |
158
|
|
|
* @return array |
159
|
|
|
*/ |
160
|
|
|
public function getLayout($id, $guestSpaceId = null, $lang = 'default') |
161
|
|
|
{ |
162
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
163
|
|
|
|
164
|
|
|
return $this->client |
|
|
|
|
165
|
|
|
->get(KintoneApi::generateUrl('preview/app/form/layout.json', $guestSpaceId), $options) |
166
|
|
|
->getBody()->jsonSerialize(); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Get app views |
171
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529784 |
172
|
|
|
* |
173
|
|
|
* @param integer $id |
174
|
|
|
* @param integer $guestSpaceId |
175
|
|
|
* @param string $lang |
176
|
|
|
* @return array |
177
|
|
|
*/ |
178
|
|
|
public function getViews($id, $guestSpaceId = null, $lang = 'default') |
179
|
|
|
{ |
180
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
181
|
|
|
|
182
|
|
|
return $this->client |
|
|
|
|
183
|
|
|
->get(KintoneApi::generateUrl('preview/app/views.json', $guestSpaceId), $options) |
184
|
|
|
->getBody()->jsonSerialize(); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Get app acl |
189
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529754 |
190
|
|
|
* |
191
|
|
|
* @param integer $id |
192
|
|
|
* @param integer $guestSpaceId |
193
|
|
|
* @param string $lang |
194
|
|
|
* @return array |
195
|
|
|
*/ |
196
|
|
|
public function getAcl($id, $guestSpaceId = null, $lang = 'default') |
197
|
|
|
{ |
198
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
199
|
|
|
|
200
|
|
|
return $this->client |
|
|
|
|
201
|
|
|
->get(KintoneApi::generateUrl('preview/app/acl.json', $guestSpaceId), $options) |
202
|
|
|
->getBody()->jsonSerialize(); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
/** |
206
|
|
|
* Get record acl |
207
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204791510 |
208
|
|
|
* |
209
|
|
|
* @param integer $id |
210
|
|
|
* @param integer $guestSpaceId |
211
|
|
|
* @param string $lang |
212
|
|
|
* @return array |
213
|
|
|
*/ |
214
|
|
|
public function getRecordAcl($id, $guestSpaceId = null, $lang = 'default') |
215
|
|
|
{ |
216
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
217
|
|
|
|
218
|
|
|
return $this->client |
|
|
|
|
219
|
|
|
->get(KintoneApi::generateUrl('preview/record/acl.json', $guestSpaceId), $options) |
220
|
|
|
->getBody()->jsonSerialize(); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
/** |
224
|
|
|
* Get field acl |
225
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204791520 |
226
|
|
|
* |
227
|
|
|
* @param integer $id |
228
|
|
|
* @param integer $guestSpaceId |
229
|
|
|
* @param string $lang |
230
|
|
|
* @return array |
231
|
|
|
*/ |
232
|
|
|
public function getFieldAcl($id, $guestSpaceId = null, $lang = 'default') |
233
|
|
|
{ |
234
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
235
|
|
|
|
236
|
|
|
return $this->client |
|
|
|
|
237
|
|
|
->get(KintoneApi::generateUrl('preview/field/acl.json', $guestSpaceId), $options) |
238
|
|
|
->getBody()->jsonSerialize(); |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Get app JavaScript and CSS customize |
243
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529824 |
244
|
|
|
* |
245
|
|
|
* @param integer $id |
246
|
|
|
* @param integer $guestSpaceId |
247
|
|
|
* @return array |
248
|
|
|
*/ |
249
|
|
|
public function getCustomize($id, $guestSpaceId = null) |
250
|
|
|
{ |
251
|
|
|
$options = ['json' => ['app' => $id]]; |
252
|
|
|
|
253
|
|
|
return $this->client |
|
|
|
|
254
|
|
|
->get(KintoneApi::generateUrl('preview/app/customize.json', $guestSpaceId), $options) |
255
|
|
|
->getBody()->jsonSerialize(); |
256
|
|
|
} |
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Get app status list |
260
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/216972946 |
261
|
|
|
* |
262
|
|
|
* @param integer $id |
263
|
|
|
* @param string $lang |
264
|
|
|
* @param integer $guestSpaceId |
265
|
|
|
* @return array |
266
|
|
|
*/ |
267
|
|
|
public function getStatus($id, $lang = 'ja', $guestSpaceId = null) |
268
|
|
|
{ |
269
|
|
|
$options = ['json' => ['app' => $id, 'lang' => $lang]]; |
270
|
|
|
|
271
|
|
|
return $this->client |
|
|
|
|
272
|
|
|
->get(KintoneApi::generateUrl('preview/app/status.json', $guestSpaceId), $options) |
273
|
|
|
->getBody()->jsonSerialize(); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
/** |
277
|
|
|
* Put preview app settings |
278
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204730520 |
279
|
|
|
* |
280
|
|
|
* @param integer $id |
281
|
|
|
* @param string $name |
282
|
|
|
* @param string $description |
283
|
|
|
* @param array $icon |
284
|
|
|
* @param string $theme |
285
|
|
|
* @param integer $guestSpaceId |
286
|
|
|
* @param integer $revision |
287
|
|
|
* @return array |
288
|
|
|
*/ |
289
|
|
|
public function putSettings($id, $name, $description, array $icon, $theme, $guestSpaceId = null, $revision = -1) |
290
|
|
|
{ |
291
|
|
|
$options = ['json' => [ |
292
|
|
|
'app' => $id, |
293
|
|
|
'name' => $name, |
294
|
|
|
'description' => $description, |
295
|
|
|
'icon' => $icon, |
296
|
|
|
'theme' => $theme, |
297
|
|
|
'revision' => $revision |
298
|
|
|
]]; |
299
|
|
|
|
300
|
|
|
return $this->client |
|
|
|
|
301
|
|
|
->put(KintoneApi::generateUrl('preview/app/settings.json', $guestSpaceId), $options) |
302
|
|
|
->getBody()->jsonSerialize(); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Post form fields to preview app |
307
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_addfields |
308
|
|
|
* |
309
|
|
|
* @param integer $id |
310
|
|
|
* @param array $fields |
311
|
|
|
* @param integer $guestSpaceId |
312
|
|
|
* @param integer $revision |
313
|
|
|
* @return array |
314
|
|
|
*/ |
315
|
|
|
public function postFields($id, array $fields, $guestSpaceId = null, $revision = -1) |
316
|
|
|
{ |
317
|
|
|
$options = ['json' => [ |
318
|
|
|
'app' => $id, |
319
|
|
|
'properties' => $fields, |
320
|
|
|
'revision' => $revision |
321
|
|
|
]]; |
322
|
|
|
|
323
|
|
|
return $this->client |
|
|
|
|
324
|
|
|
->post(KintoneApi::generateUrl('preview/app/form/fields.json', $guestSpaceId), $options) |
325
|
|
|
->getBody()->jsonSerialize(); |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
/** |
329
|
|
|
* Put form fields to preview app |
330
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_changefields |
331
|
|
|
* |
332
|
|
|
* @param integer $id |
333
|
|
|
* @param array $fields |
334
|
|
|
* @param integer $guestSpaceId |
335
|
|
|
* @param integer $revision |
336
|
|
|
* @return array |
337
|
|
|
*/ |
338
|
|
|
public function putFields($id, array $fields, $guestSpaceId = null, $revision = -1) |
339
|
|
|
{ |
340
|
|
|
$options = ['json' => [ |
341
|
|
|
'app' => $id, |
342
|
|
|
'properties' => $fields, |
343
|
|
|
'revision' => $revision |
344
|
|
|
]]; |
345
|
|
|
|
346
|
|
|
return $this->client |
|
|
|
|
347
|
|
|
->put(KintoneApi::generateUrl('preview/app/form/fields.json', $guestSpaceId), $options) |
348
|
|
|
->getBody()->jsonSerialize(); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
/** |
352
|
|
|
* Delete form fields to preview app |
353
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_deletefields |
354
|
|
|
* |
355
|
|
|
* @param integer $id |
356
|
|
|
* @param array $fields |
357
|
|
|
* @param integer $guestSpaceId |
358
|
|
|
* @param integer $revision |
359
|
|
|
* @return array |
360
|
|
|
*/ |
361
|
|
|
public function deleteFields($id, array $fields, $guestSpaceId = null, $revision = -1) |
362
|
|
|
{ |
363
|
|
|
$options = ['json' => [ |
364
|
|
|
'app' => $id, |
365
|
|
|
'fields' => $fields, |
366
|
|
|
'revision' => $revision |
367
|
|
|
]]; |
368
|
|
|
|
369
|
|
|
return $this->client |
|
|
|
|
370
|
|
|
->delete(KintoneApi::generateUrl('preview/app/form/fields.json', $guestSpaceId), $options) |
371
|
|
|
->getBody()->jsonSerialize(); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* Put form layout to preview app |
376
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529724#anchor_changeform_changelayout |
377
|
|
|
* |
378
|
|
|
* @param integer $id |
379
|
|
|
* @param array $layout |
380
|
|
|
* @param integer $guestSpaceId |
381
|
|
|
* @param integer $revision |
382
|
|
|
* @return array |
383
|
|
|
*/ |
384
|
|
|
public function putLayout($id, array $layout, $guestSpaceId = null, $revision = -1) |
385
|
|
|
{ |
386
|
|
|
$options = ['json' => [ |
387
|
|
|
'app' => $id, |
388
|
|
|
'layout' => $layout, |
389
|
|
|
'revision' => $revision |
390
|
|
|
]]; |
391
|
|
|
|
392
|
|
|
return $this->client |
|
|
|
|
393
|
|
|
->put(KintoneApi::generateUrl('preview/app/form/layout.json', $guestSpaceId), $options) |
394
|
|
|
->getBody()->jsonSerialize(); |
395
|
|
|
} |
396
|
|
|
|
397
|
|
|
/** |
398
|
|
|
* Put views to preview app |
399
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529794 |
400
|
|
|
* |
401
|
|
|
* @param integer $id |
402
|
|
|
* @param array $views |
403
|
|
|
* @param integer $guestSpaceId |
404
|
|
|
* @param integer $revision |
405
|
|
|
* @return array |
406
|
|
|
*/ |
407
|
|
|
public function putViews($id, array $views, $guestSpaceId = null, $revision = -1) |
408
|
|
|
{ |
409
|
|
|
$options = ['json' => [ |
410
|
|
|
'app' => $id, |
411
|
|
|
'views' => $views, |
412
|
|
|
'revision' => $revision |
413
|
|
|
]]; |
414
|
|
|
|
415
|
|
|
return $this->client |
|
|
|
|
416
|
|
|
->put(KintoneApi::generateUrl('preview/app/views.json', $guestSpaceId), $options) |
417
|
|
|
->getBody()->jsonSerialize(); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Put app acl to preview app |
422
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/201941844 |
423
|
|
|
* |
424
|
|
|
* @param integer $id |
425
|
|
|
* @param array $rights |
426
|
|
|
* @param integer $guestSpaceId |
427
|
|
|
* @param integer $revision |
428
|
|
|
* @return array |
429
|
|
|
*/ |
430
|
|
|
public function putAcl($id, array $rights, $guestSpaceId = null, $revision = -1) |
431
|
|
|
{ |
432
|
|
|
$options = ['json' => [ |
433
|
|
|
'app' => $id, |
434
|
|
|
'rights' => $rights, |
435
|
|
|
'revision' => $revision |
436
|
|
|
]]; |
437
|
|
|
|
438
|
|
|
return $this->client |
|
|
|
|
439
|
|
|
->put(KintoneApi::generateUrl('preview/app/acl.json', $guestSpaceId), $options) |
440
|
|
|
->getBody()->jsonSerialize(); |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* Put record acl to preview app |
445
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/201941854 |
446
|
|
|
* |
447
|
|
|
* @param integer $id |
448
|
|
|
* @param array $rights |
449
|
|
|
* @param integer $guestSpaceId |
450
|
|
|
* @param integer $revision |
451
|
|
|
* @return array |
452
|
|
|
*/ |
453
|
|
|
public function putRecordAcl($id, array $rights, $guestSpaceId = null, $revision = -1) |
454
|
|
|
{ |
455
|
|
|
$options = ['json' => [ |
456
|
|
|
'id' => $id, |
457
|
|
|
'rights' => $rights, |
458
|
|
|
'revision' => $revision |
459
|
|
|
]]; |
460
|
|
|
|
461
|
|
|
return $this->client |
|
|
|
|
462
|
|
|
->put(KintoneApi::generateUrl('preview/record/acl.json', $guestSpaceId), $options) |
463
|
|
|
->getBody()->jsonSerialize(); |
464
|
|
|
} |
465
|
|
|
|
466
|
|
|
/** |
467
|
|
|
* Put field acl to preview app |
468
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/201941854 |
469
|
|
|
* |
470
|
|
|
* @param integer $id |
471
|
|
|
* @param array $rights |
472
|
|
|
* @param integer $guestSpaceId |
473
|
|
|
* @param integer $revision |
474
|
|
|
* @return array |
475
|
|
|
*/ |
476
|
|
|
public function putFieldAcl($id, array $rights, $guestSpaceId = null, $revision = -1) |
477
|
|
|
{ |
478
|
|
|
$options = ['json' => [ |
479
|
|
|
'id' => $id, |
480
|
|
|
'rights' => $rights, |
481
|
|
|
'revision' => $revision |
482
|
|
|
]]; |
483
|
|
|
|
484
|
|
|
return $this->client |
|
|
|
|
485
|
|
|
->put(KintoneApi::generateUrl('preview/field/acl.json', $guestSpaceId), $options) |
486
|
|
|
->getBody()->jsonSerialize(); |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Put app JavaScript & CSS customize to preview app |
491
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/204529834 |
492
|
|
|
* |
493
|
|
|
* @param integer $id |
494
|
|
|
* @param array $js |
495
|
|
|
* @param array $css |
496
|
|
|
* @param array $mobileJs |
497
|
|
|
* @param integer $guestSpaceId |
498
|
|
|
* @param string $scope |
499
|
|
|
* @param integer $revision |
500
|
|
|
* @return array |
501
|
|
|
*/ |
502
|
|
|
public function putCustomize($id, array $js = [], array $css = [], array $mobileJs = [], $guestSpaceId = null, $scope = 'ALL', $revision = -1) |
503
|
|
|
{ |
504
|
|
|
$options = ['json' => [ |
505
|
|
|
'app' => $id, |
506
|
|
|
'desktop' => [ |
507
|
|
|
'js' => $js, |
508
|
|
|
'css' => $css, |
509
|
|
|
], |
510
|
|
|
'mobile' => [ |
511
|
|
|
'js' => $mobileJs |
512
|
|
|
], |
513
|
|
|
'scope' => $scope, |
514
|
|
|
'revision' => $revision |
515
|
|
|
]]; |
516
|
|
|
|
517
|
|
|
return $this->client |
|
|
|
|
518
|
|
|
->put(KintoneApi::generateUrl('preview/app/customize.json', $guestSpaceId), $options) |
519
|
|
|
->getBody()->jsonSerialize(); |
520
|
|
|
} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* Put app status and action |
524
|
|
|
* https://cybozudev.zendesk.com/hc/ja/articles/217905503 |
525
|
|
|
* |
526
|
|
|
* @param integer $id |
527
|
|
|
* @param array $states |
528
|
|
|
* @param array $actions |
529
|
|
|
* @param boolean $enable |
530
|
|
|
* @param integer $guestSpaceId |
531
|
|
|
* @return array |
532
|
|
|
*/ |
533
|
|
|
public function putStatus($id, array $states, array $actions, $enable = true, $guestSpaceId = null) |
534
|
|
|
{ |
535
|
|
|
$options = [ |
536
|
|
|
'json' => [ |
537
|
|
|
'app' => $id, |
538
|
|
|
'enable' => $enable, |
539
|
|
|
'states' => $states, |
540
|
|
|
'actions' => $actions |
541
|
|
|
] |
542
|
|
|
]; |
543
|
|
|
|
544
|
|
|
return $this->client |
|
|
|
|
545
|
|
|
->put(KintoneApi::generateUrl('preview/app/status.json', $guestSpaceId), $options) |
546
|
|
|
->getBody()->jsonSerialize(); |
547
|
|
|
} |
548
|
|
|
} |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: