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

Comment   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 62
ccs 19
cts 19
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A post() 0 15 1
A delete() 0 12 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
}