Completed
Push — comment-api ( 9d46a8 )
by Yuichi
09:33
created

Comment::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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 Comment
12
{
13
    /**
14
     * @var Client
15
     */
16
    private $client;
17
18 1
    public function __construct(Client $client)
19
    {
20 1
        $this->client = $client;
21 1
    }
22
23
    /**
24
     * Post record comment
25
     * https://cybozudev.zendesk.com/hc/ja/articles/209758903
26
     *
27
     * @param integer $appId
28
     * @param integer $record
29
     * @param string  $comment
30
     * @param array   $mentions
31
     * @param integer $guestSpaceId
32
     * @return array
33
     */
34 2
    public function post($appId, $record, $comment, $mentions = [], $guestSpaceId = null)
35
    {
36
        $options = ['json' => [
37 2
            'app' => $appId,
38 2
            'record' => $record,
39
            'comment' => [
40 2
                'text' => $comment,
41
                'mentions' => $mentions
42 2
            ]
43 2
        ]];
44
45 2
        return $this->client
46 2
            ->post(KintoneApi::generateUrl('record/comment.json', $guestSpaceId), $options)
47 2
            ->json();
48
    }
49
50
    /**
51
     * Delete record comment
52
     * https://cybozudev.zendesk.com/hc/ja/articles/209758703
53
     *
54
     * @param integer $appId
55
     * @param integer $recordId
56
     * @param integer $id
57
     * @param integer $guestSpaceId
58
     * @return array
59
     */
60 2
    public function delete($appId, $recordId, $id, $guestSpaceId = null)
61
    {
62
        $options = ['json' => [
63 2
            'app' => $appId,
64 2
            'record' => $recordId,
65
            'comment' => $id
66 2
        ]];
67
68 2
        return $this->client
69 2
            ->delete(KintoneApi::generateUrl('record/comment.json', $guestSpaceId), $options)
70 2
            ->json();
71
    }
72
}