Passed
Push — master ( d0634e...13c37e )
by Yuichi
10:21 queued 22s
created

Guests::post()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 1
rs 10
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 Guests
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
     * Post guest users
26
     * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1
27
     *
28
     * @param array $guests
29
     * @return array
30
     */
31 2
    public function post(array $guests): array
32
    {
33 2
        $options = ['json' => ['guests' => $guests]];
34
35
        /** @var JsonStream $stream */
36 2
        $stream = $this->client
37 2
            ->post(KintoneApi::generateUrl('guests.json'), $options)
38 2
            ->getBody();
39
40 2
        return $stream->jsonSerialize();
41
    }
42
43
    /**
44
     * Delete guest users
45
     * https://cybozudev.zendesk.com/hc/ja/articles/202931674#step1
46
     *
47
     * @param array $guests
48
     * @return array
49
     */
50 2
    public function delete(array $guests): array
51
    {
52 2
        $options = ['json' => ['guests' => $guests]];
53
54
        /** @var JsonStream $stream */
55 2
        $stream = $this->client
56 2
            ->delete(KintoneApi::generateUrl('guests.json'), $options)
57 2
            ->getBody();
58
59 1
        return $stream->jsonSerialize();
60
    }
61
62
}
63