1
+ <?php
2
+ /**
3
+ * This Driver is based entirely on official documentation of the Mattermost Web
4
+ * Services API and you can extend it by following the directives of the documentation.
5
+ *
6
+ * For the full copyright and license information, please read the LICENSE.txt
7
+ * file that was distributed with this source code. For the full list of
8
+ * contributors, visit https://github.com/gnello/php-mattermost-driver/contributors
9
+ *
10
+ * God bless this mess.
11
+ *
12
+ * @author Luca Agnello <[email protected] >
13
+ * @link https://api.mattermost.com/
14
+ */
15
+
16
+ namespace Gnello \Mattermost \Models ;
17
+
18
+ use Psr \Http \Message \ResponseInterface ;
19
+
20
+ /**
21
+ * Class ThreadsModel
22
+ *
23
+ * @package Gnello\Mattermost
24
+ */
25
+ class ThreadModel extends AbstractModel
26
+ {
27
+ /**
28
+ * @var string
29
+ */
30
+ public static $ endpoint = '/threads ' ;
31
+
32
+ /**
33
+ * @param $userId
34
+ * @param $teamId
35
+ * @param array $requestOptions
36
+ * @return ResponseInterface
37
+ */
38
+ public function getThreadsThatUserIsFollowing ($ userId , $ teamId , array $ requestOptions )
39
+ {
40
+ return $ this ->client ->get (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ ' . $ teamId
41
+ . '/ ' . self ::$ endpoint , $ requestOptions );
42
+ }
43
+
44
+ /**
45
+ * @param $userId
46
+ * @param $teamId
47
+ * @return ResponseInterface
48
+ */
49
+ public function getUnreadMentionCounts ($ userId , $ teamId )
50
+ {
51
+ return $ this ->client ->get (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ ' . $ teamId
52
+ . '/ ' . self ::$ endpoint . '/mention_counts ' );
53
+ }
54
+
55
+ /**
56
+ * @param $userId
57
+ * @param $teamId
58
+ * @return ResponseInterface
59
+ */
60
+ public function markThreadsAsRead ($ userId , $ teamId )
61
+ {
62
+ return $ this ->client ->put (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ ' . $ teamId
63
+ . '/ ' . self ::$ endpoint . '/read ' );
64
+ }
65
+
66
+ /**
67
+ * @param $userId
68
+ * @param $teamId
69
+ * @param $threadId
70
+ * @param $timestamp
71
+ * @return ResponseInterface
72
+ */
73
+ public function markThreadToTimestamp ($ userId , $ teamId , $ threadId , $ timestamp )
74
+ {
75
+ return $ this ->client ->put (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ ' . $ teamId
76
+ . '/ ' . self ::$ endpoint . '/ ' . $ threadId . '/read/ ' . $ timestamp );
77
+ }
78
+
79
+ /**
80
+ * @param $userId
81
+ * @param $teamId
82
+ * @param $threadId
83
+ * @return ResponseInterface
84
+ */
85
+ public function startFollowingThread ($ userId , $ teamId , $ threadId )
86
+ {
87
+ return $ this ->client ->put (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ ' . $ teamId
88
+ . '/ ' . self ::$ endpoint . '/ ' . $ threadId . '/following ' );
89
+ }
90
+
91
+ /**
92
+ * @param $userId
93
+ * @param $teamId
94
+ * @param $threadId
95
+ * @return ResponseInterface
96
+ */
97
+ public function stopFollowingThread ($ userId , $ teamId , $ threadId )
98
+ {
99
+ return $ this ->client ->delete (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ '
100
+ . $ teamId . '/ ' . self ::$ endpoint . '/ ' . $ threadId . '/following ' );
101
+ }
102
+
103
+ /**
104
+ * @param $userId
105
+ * @param $teamId
106
+ * @param $threadId
107
+ * @return ResponseInterface
108
+ */
109
+ public function getThreadFollowedByUser ($ userId , $ teamId , $ threadId )
110
+ {
111
+ return $ this ->client ->get (UserModel::$ endpoint . '/ ' . $ userId . '/ ' . TeamModel::$ endpoint . '/ ' . $ teamId
112
+ . '/ ' . self ::$ endpoint . '/ ' . $ threadId );
113
+ }
114
+ }
0 commit comments