ConversationService::get()   A
last analyzed

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 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Aosmak\Laravel\Layer\Sdk\Services\Subservices;
4
5
use Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface;
6
use Aosmak\Laravel\Layer\Sdk\Services\Subservices\Interfaces\ConversationServiceInterface;
7
8
/**
9
 * Class ConversationService
10
 * @package namespace Aosmak\Laravel\Layer\Sdk\Services\Subservices
11
 */
12
class ConversationService extends BaseService implements ConversationServiceInterface
13
{
14
    /**
15
     * Create a conversation
16
     *
17
     * @param array $data conversation data
18
     *
19
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
20
     */
21 6
    public function create(array $data): ResponseInterface
22
    {
23
        //set default value
24 6
        if (!isset($data['distinct'])) {
25 6
            $data['distinct'] = true;
26
        }
27
28 6
        return $this->getRequestService()
29 6
            ->makePostRequest($this->getRouter()->getShortUrl('conversations'), $data);
30
    }
31
32
    /**
33
     * Update a conversation
34
     *
35
     * @param array $data conversation data
36
     * @param string $conversationId conversation ID
37
     *
38
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
39
     */
40 2
    public function update(array $data, string $conversationId): ResponseInterface
41
    {
42 2
        return $this->getRequestService()
43 2
            ->makePatchRequest($this->getRouter()->getShortUrl('conversations', $conversationId), $data);
44
    }
45
46
    /**
47
     * Get conversation details
48
     *
49
     * @param string $conversationId conversation ID
50
     *
51
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
52
     */
53 3
    public function get(string $conversationId): ResponseInterface
54
    {
55 3
        return $this->getRequestService()
56 3
            ->makeGetRequest($this->getRouter()->getShortUrl('conversations', $conversationId));
57
    }
58
59
    /**
60
     * Delete a conversation
61
     *
62
     * @param string $conversationId conversation ID
63
     *
64
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
65
     */
66 2
    public function delete(string $conversationId): ResponseInterface
67
    {
68 2
        return $this->getRequestService()
69 2
            ->makeDeleteRequest($this->getRouter()->getShortUrl('conversations', $conversationId));
70
    }
71
}
72