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

Guests   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 48
ccs 14
cts 14
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A post() 0 10 1
A delete() 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 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