MessageService   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 55
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A all() 0 4 1
A create() 0 4 1
A delete() 0 4 1
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\MessageServiceInterface;
7
8
/**
9
 * Class MessageService
10
 * @package namespace Aosmak\Laravel\Layer\Sdk\Services\Subservices
11
 */
12
class MessageService extends BaseService implements MessageServiceInterface
13
{
14
    /**
15
     * Send a message
16
     *
17
     * @param array $data conversation data
18
     * @param string $conversationId conversation ID
19
     *
20
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
21
     */
22 4
    public function create(array $data, string $conversationId): ResponseInterface
23
    {
24 4
        return $this->getRequestService()
25 4
            ->makePostRequest($this->getRouter()->getShortUrl('conversations', $conversationId, 'messages'), $data);
26
    }
27
28
    /**
29
     * Get all messages by a conversation ID
30
     *
31
     * @param string $conversationId conversation ID
32
     *
33
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
34
     */
35 2
    public function all(string $conversationId): ResponseInterface
36
    {
37 2
        return $this->getRequestService()
38 2
            ->makeGetRequest($this->getRouter()->getShortUrl('conversations', $conversationId, 'messages'));
39
    }
40
41
    /**
42
     * Get a message by ID
43
     *
44
     * @param string $messageId message ID
45
     * @param string $conversationId conversation ID
46
     *
47
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
48
     */
49 2
    public function get(string $messageId, string $conversationId): ResponseInterface
50
    {
51 2
        return $this->getRequestService()
52 2
            ->makeGetRequest($this->getRouter()->getMessageURL($messageId, $conversationId));
53
    }
54
55
    /**
56
     * Delete a message
57
     *
58
     * @param string $messageId message ID
59
     * @param string $conversationId conversation ID
60
     *
61
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
62
     */
63 2
    public function delete(string $messageId, string $conversationId): ResponseInterface
64
    {
65 2
        return $this->getRequestService()
66 2
            ->makeDeleteRequest($this->getRouter()->getMessageURL($messageId, $conversationId));
67
    }
68
}
69