Completed
Pull Request — master (#27)
by Yuichi
05:39 queued 04:15
created

Apps::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 7
crap 2
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 Apps
13
{
14
    const MAX_GET_APPS = 100;
15
16
    /**
17
     * @var Client
18
     */
19
    private $client;
20
21 1
    public function __construct(Client $client)
22
    {
23 1
        $this->client = $client;
24 1
    }
25
26
    /**
27
     * Get apps
28
     * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step2
29
     *
30
     * @param array $ids
31
     * @param array $codes
32
     * @param string $name
33
     * @param array $spaceIds
34
     * @param integer $limit
35
     * @param integer $offset
36
     * @param integer $guestSpaceId
37
     * @return array
38
     */
39
    public function get(array $ids = [], array $codes = [], $name = null, array $spaceIds = [], $limit = self::MAX_GET_APPS, $offset = 0, $guestSpaceId = null)
40
    {
41
        $options = ['json' => compact('ids', 'codes', 'name', 'spaceIds')];
42
        $options['json']['limit'] = $limit;
43
        $options['json']['offset'] = $offset;
44
45
        /** @var JsonStream $stream */
46
        $stream = $this->client
47
            ->get(KintoneApi::generateUrl('apps.json', $guestSpaceId), $options)
48
            ->getBody();
49
50
        return $stream->jsonSerialize();
51
    }
52
53
54
}