Passed
Pull Request — master (#75)
by
unknown
10:23
created

App   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 238
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 58
c 2
b 0
f 0
dl 0
loc 238
ccs 68
cts 68
cp 1
rs 10
wmc 12

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getLayout() 0 10 1
A getRecordAcl() 0 10 1
A getFields() 0 10 1
A getViews() 0 10 1
A get() 0 10 1
A getCustomize() 0 10 1
A getAcl() 0 10 1
A getSettings() 0 10 1
A getStatus() 0 10 1
A getFieldAcl() 0 10 1
A getForm() 0 10 1
1
<?php
2
3
namespace CybozuHttp\Api\Kintone;
4
5
use CybozuHttp\Client;
6
use CybozuHttp\Api\KintoneApi;
7
use CybozuHttp\Middleware\JsonStream;
8
9
/**
10
 * @author ochi51 <[email protected]>
11
 */
12
class App
13
{
14
    /**
15
     * @var Client
16
     */
17
    private $client;
18
19 1
    public function __construct(Client $client)
20
    {
21 1
        $this->client = $client;
22
    }
23
24
    /**
25
     * Get app
26
     * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1
27
     *
28
     * @param integer $id
29
     * @param integer $guestSpaceId
30
     * @return array
31
     */
32 2
    public function get($id, $guestSpaceId = null): array
33
    {
34 2
        $options = ['json' => ['id' => $id]];
35
36
        /** @var JsonStream $stream */
37 2
        $stream = $this->client
38 2
            ->get(KintoneApi::generateUrl('app.json', $guestSpaceId), $options)
39 2
            ->getBody();
40
41 2
        return $stream->jsonSerialize();
42
    }
43
44
    /**
45
     * Get app settings
46
     * https://cybozudev.zendesk.com/hc/ja/articles/204694170
47
     *
48
     * @param integer $id
49
     * @param integer $guestSpaceId
50
     * @param string $lang
51
     * @return array
52
     */
53 1
    public function getSettings($id, $guestSpaceId = null, $lang = 'default'): array
54
    {
55 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
56
57
        /** @var JsonStream $stream */
58 1
        $stream = $this->client
59 1
            ->get(KintoneApi::generateUrl('app/settings.json', $guestSpaceId), $options)
60 1
            ->getBody();
61
62 1
        return $stream->jsonSerialize();
63
    }
64
65
    /**
66
     * Get app forms
67
     * https://cybozudev.zendesk.com/hc/ja/articles/201941834#step1
68
     *
69
     * @param integer $id
70
     * @param integer $guestSpaceId
71
     * @return array
72
     */
73 1
    public function getForm($id, $guestSpaceId = null): array
74
    {
75 1
        $options = ['json' => ['app' => $id]];
76
77
        /** @var JsonStream $stream */
78 1
        $stream = $this->client
79 1
            ->get(KintoneApi::generateUrl('form.json', $guestSpaceId), $options)
80 1
            ->getBody();
81
82 1
        return $stream->jsonSerialize()['properties'];
83
    }
84
85
    /**
86
     * Get app form fields
87
     * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_fields
88
     *
89
     * @param integer $id
90
     * @param integer $guestSpaceId
91
     * @param string $lang
92
     * @return array
93
     */
94 1
    public function getFields($id, $guestSpaceId = null, $lang = 'default'): array
95
    {
96 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
97
98
        /** @var JsonStream $stream */
99 1
        $stream = $this->client
100 1
            ->get(KintoneApi::generateUrl('app/form/fields.json', $guestSpaceId), $options)
101 1
            ->getBody();
102
103 1
        return $stream->jsonSerialize();
104
    }
105
106
    /**
107
     * Get app form layout
108
     * https://cybozudev.zendesk.com/hc/ja/articles/204783170#anchor_getform_layout
109
     *
110
     * @param integer $id
111
     * @param integer $guestSpaceId
112
     * @param string $lang
113
     * @return array
114
     */
115 1
    public function getLayout($id, $guestSpaceId = null, $lang = 'default'): array
116
    {
117 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
118
119
        /** @var JsonStream $stream */
120 1
        $stream = $this->client
121 1
            ->get(KintoneApi::generateUrl('app/form/layout.json', $guestSpaceId), $options)
122 1
            ->getBody();
123
124 1
        return $stream->jsonSerialize();
125
    }
126
127
    /**
128
     * Get app views
129
     * https://cybozudev.zendesk.com/hc/ja/articles/204529784
130
     *
131
     * @param integer $id
132
     * @param integer $guestSpaceId
133
     * @param string $lang
134
     * @return array
135
     */
136 1
    public function getViews($id, $guestSpaceId = null, $lang = 'default'): array
137
    {
138 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
139
140
        /** @var JsonStream $stream */
141 1
        $stream = $this->client
142 1
            ->get(KintoneApi::generateUrl('app/views.json', $guestSpaceId), $options)
143 1
            ->getBody();
144
145 1
        return $stream->jsonSerialize();
146
    }
147
148
    /**
149
     * Get app acl
150
     * https://cybozudev.zendesk.com/hc/ja/articles/204529754
151
     *
152
     * @param integer $id
153
     * @param integer $guestSpaceId
154
     * @param string $lang
155
     * @return array
156
     */
157 1
    public function getAcl($id, $guestSpaceId = null, $lang = 'default'): array
158
    {
159 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
160
161
        /** @var JsonStream $stream */
162 1
        $stream = $this->client
163 1
            ->get(KintoneApi::generateUrl('app/acl.json', $guestSpaceId), $options)
164 1
            ->getBody();
165
166 1
        return $stream->jsonSerialize();
167
    }
168
169
    /**
170
     * Get record acl
171
     * https://cybozudev.zendesk.com/hc/ja/articles/204791510
172
     *
173
     * @param integer $id
174
     * @param integer $guestSpaceId
175
     * @param string $lang
176
     * @return array
177
     */
178 1
    public function getRecordAcl($id, $guestSpaceId = null, $lang = 'default'): array
179
    {
180 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
181
182
        /** @var JsonStream $stream */
183 1
        $stream = $this->client
184 1
            ->get(KintoneApi::generateUrl('record/acl.json', $guestSpaceId), $options)
185 1
            ->getBody();
186
187 1
        return $stream->jsonSerialize();
188
    }
189
190
    /**
191
     * Get field acl
192
     * https://cybozudev.zendesk.com/hc/ja/articles/204791520
193
     *
194
     * @param integer $id
195
     * @param integer $guestSpaceId
196
     * @param string $lang
197
     * @return array
198
     */
199 1
    public function getFieldAcl($id, $guestSpaceId = null, $lang = 'default'): array
200
    {
201 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
202
203
        /** @var JsonStream $stream */
204 1
        $stream = $this->client
205 1
            ->get(KintoneApi::generateUrl('field/acl.json', $guestSpaceId), $options)
206 1
            ->getBody();
207
208 1
        return $stream->jsonSerialize();
209
    }
210
211
    /**
212
     * Get app JavaScript and CSS customize
213
     * https://cybozudev.zendesk.com/hc/ja/articles/204529824
214
     *
215
     * @param integer $id
216
     * @param integer $guestSpaceId
217
     * @return array
218
     */
219 1
    public function getCustomize($id, $guestSpaceId = null): array
220
    {
221 1
        $options = ['json' => ['app' => $id]];
222
223
        /** @var JsonStream $stream */
224 1
        $stream = $this->client
225 1
            ->get(KintoneApi::generateUrl('app/customize.json', $guestSpaceId), $options)
226 1
            ->getBody();
227
228 1
        return $stream->jsonSerialize();
229
    }
230
231
    /**
232
     * Get app status list
233
     * https://cybozudev.zendesk.com/hc/ja/articles/216972946
234
     *
235
     * @param integer $id
236
     * @param string  $lang
237
     * @param integer $guestSpaceId
238
     * @return array
239
     */
240 1
    public function getStatus($id, $lang = 'ja', $guestSpaceId = null): array
241
    {
242 1
        $options = ['json' => ['app' => $id, 'lang' => $lang]];
243
244
        /** @var JsonStream $stream */
245 1
        $stream = $this->client
246 1
            ->get(KintoneApi::generateUrl('app/status.json', $guestSpaceId), $options)
247 1
            ->getBody();
248
249 1
        return $stream->jsonSerialize();
250
    }
251
}
252