Completed
Push — master ( 32ec37...91cdda )
by Luca
8s
created

PostModel::pinPost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
/**
19
 * Class PostModel
20
 *
21
 * @package Gnello\Mattermost\Models
22
 */
23
class PostModel extends AbstractModel
24
{
25
    /**
26
     * @var string
27
     */
28
    public static $endpoint = '/posts';
29
30
    /**
31
     * @param array $requestOptions
32
     * @return \Psr\Http\Message\ResponseInterface
33
     */
34
    public function createPost(array $requestOptions)
35
    {
36
        return $this->client->post(self::$endpoint, $requestOptions);
37
    }
38
39
    /**
40
     * @param $postId
41
     * @return \Psr\Http\Message\ResponseInterface
42
     */
43
    public function getPost($postId)
44
    {
45
        return $this->client->get(self::$endpoint . '/' . $postId);
46
    }
47
48
    /**
49
     * @param $postId
50
     * @return \Psr\Http\Message\ResponseInterface
51
     */
52
    public function deletePost($postId)
53
    {
54
        return $this->client->delete(self::$endpoint . '/' . $postId);
55
    }
56
57
    /**
58
     * @param       $postId
59
     * @param array $requestOptions
60
     * @return \Psr\Http\Message\ResponseInterface
61
     */
62
    public function updatePost($postId, array $requestOptions)
63
    {
64
        return $this->client->put(self::$endpoint . '/' . $postId, $requestOptions);
65
    }
66
67
    /**
68
     * @param       $postId
69
     * @param array $requestOptions
70
     * @return \Psr\Http\Message\ResponseInterface
71
     */
72
    public function patchPost($postId, array $requestOptions)
73
    {
74
        return $this->client->put(self::$endpoint . '/' . $postId . '/patch', $requestOptions);
75
    }
76
77
    /**
78
     * @param $postId
79
     * @return \Psr\Http\Message\ResponseInterface
80
     */
81
    public function getThread($postId)
82
    {
83
        return $this->client->get(self::$endpoint . '/' . $postId . '/thread');
84
    }
85
86
    /**
87
     * @param       $userId
88
     * @param array $requestOptions
89
     * @return \Psr\Http\Message\ResponseInterface
90
     */
91
    public function getFlaggedPosts($userId, array $requestOptions)
92
    {
93
        return $this->client->get(UserModel::$endpoint . '/' . $userId . self::$endpoint . '/flagged', $requestOptions);
94
    }
95
96
    /**
97
     * @param       $postId
98
     * @return \Psr\Http\Message\ResponseInterface
99
     */
100
    public function getFileInfoForPost($postId)
101
    {
102
        return $this->client->get(self::$endpoint . '/' . $postId . '/files/info');
103
    }
104
105
    /**
106
     * @param       $channelId
107
     * @param array $requestOptions
108
     * @return \Psr\Http\Message\ResponseInterface
109
     */
110
    public function getPostsForChannel($channelId, array $requestOptions)
111
    {
112
        return $this->client->get(ChannelModel::$endpoint . '/' . $channelId . self::$endpoint, $requestOptions);
113
    }
114
115
    /**
116
     * @param       $teamId
117
     * @param array $requestOptions
118
     * @return \Psr\Http\Message\ResponseInterface
119
     */
120
    public function searchForTeamPosts($teamId, array $requestOptions)
121
    {
122
        return $this->client->post(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/search', $requestOptions);
123
    }
124
125
    /**
126
     * @param       $postId
127
     * @return \Psr\Http\Message\ResponseInterface
128
     */
129
    public function pinPost($postId)
130
    {
131
        return $this->client->post(self::$endpoint . '/' . $postId . '/pin');
132
    }
133
134
    /**
135
     * @param       $postId
136
     * @return \Psr\Http\Message\ResponseInterface
137
     */
138
    public function unpinPost($postId)
139
    {
140
        return $this->client->post(self::$endpoint . '/' . $postId . '/unpin');
141
    }
142
143
    /**
144
     * @param       $postId
145
     * @param       $actionId
146
     * @return \Psr\Http\Message\ResponseInterface
147
     */
148
    public function performPostAction($postId, $actionId)
149
    {
150
        return $this->client->post(self::$endpoint . '/' . $postId . '/actions/' . $actionId);
151
    }
152
153
    /**
154
     * @param $postId
155
     * @return \Psr\Http\Message\ResponseInterface
156
     */
157
    public function getReactions($postId)
158
    {
159
        return $this->client->get(self::$endpoint . '/' . $postId . '/reactions');
160
    }
161
}