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
|
|
|
|