|
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\UserDataServiceInterface; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class UserDataService |
|
10
|
|
|
* @package namespace Aosmak\Laravel\Layer\Sdk\Services\Subservices |
|
11
|
|
|
*/ |
|
12
|
|
|
class UserDataService extends BaseService implements UserDataServiceInterface |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Get user conversations |
|
16
|
|
|
* |
|
17
|
|
|
* @param string $userId user ID |
|
18
|
|
|
* |
|
19
|
|
|
* @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface |
|
20
|
|
|
*/ |
|
21
|
2 |
|
public function getConversations(string $userId): ResponseInterface |
|
22
|
|
|
{ |
|
23
|
2 |
|
return $this->getRequestService() |
|
24
|
2 |
|
->makeGetRequest($this->getRouter()->getShortUrl('users', $userId, 'conversations')); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Send a message |
|
29
|
|
|
* |
|
30
|
|
|
* @param array $data request data |
|
31
|
|
|
* @param string $userId user ID |
|
32
|
|
|
* @param string $conversationId conversation ID |
|
33
|
|
|
* |
|
34
|
|
|
* @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface |
|
35
|
|
|
*/ |
|
36
|
2 |
|
public function sendMessage(array $data, string $userId, string $conversationId): ResponseInterface |
|
37
|
|
|
{ |
|
38
|
2 |
|
return $this->getRequestService() |
|
39
|
2 |
|
->makePostRequest($this->getRouter()->sendMessagesURL($userId, $conversationId), $data); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Send a receipt |
|
44
|
|
|
* |
|
45
|
|
|
* @param array $data request data |
|
46
|
|
|
* @param string $userId user ID |
|
47
|
|
|
* @param string $conversationId conversation ID |
|
48
|
|
|
* |
|
49
|
|
|
* @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface |
|
50
|
|
|
*/ |
|
51
|
2 |
|
public function sendReceipt(string $type, string $userId, string $messageId): ResponseInterface |
|
52
|
|
|
{ |
|
53
|
2 |
|
return $this->getRequestService() |
|
54
|
2 |
|
->makePostRequest( |
|
55
|
2 |
|
$this->getRouter()->getMessageReceiptsURL($userId, $messageId), |
|
56
|
2 |
|
['type' => $type] |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Delete a message |
|
62
|
|
|
* |
|
63
|
|
|
* @param string $userId user ID |
|
64
|
|
|
* @param string $messageId conversation ID |
|
65
|
|
|
* |
|
66
|
|
|
* @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface |
|
67
|
|
|
*/ |
|
68
|
2 |
|
public function deleteMessage(string $userId, string $messageId): ResponseInterface |
|
69
|
|
|
{ |
|
70
|
2 |
|
return $this->getRequestService() |
|
71
|
2 |
|
->makeDeleteRequest($this->getRouter()->deleteMessageURL($userId, $messageId)); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|