Code Duplication    Length = 90-99 lines in 2 locations

src/Models/CommandModel.php 1 location

@@ 21-110 (lines=90) @@
18
 *
19
 * @package Gnello\MattermostRestApi\Models
20
 */
21
class CommandModel extends AbstractModel
22
{
23
    /**
24
     * @var string
25
     */
26
    private static $endpoint = '/commands';
27
28
    /**
29
     * @param array $requestOptions
30
     * @return ResponseInterface
31
     */
32
    public function createCommand(array $requestOptions)
33
    {
34
        return $this->client->post(self::$endpoint, $requestOptions);
35
    }
36
37
    /**
38
     * @param array $requestOptions
39
     * @return ResponseInterface
40
     */
41
    public function listCommandsForTeam(array $requestOptions)
42
    {
43
        return $this->client->get(self::$endpoint, $requestOptions);
44
    }
45
46
    /**
47
     * @param $teamId
48
     * @return ResponseInterface
49
     */
50
    public function listAutocompleteCommands($teamId)
51
    {
52
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . '/commands/autocomplete');
53
    }
54
55
    /**
56
     * @param       $commandId
57
     * @param array $requestOptions
58
     * @return ResponseInterface
59
     */
60
    public function updateCommand($commandId, array $requestOptions)
61
    {
62
        return $this->client->put(self::$endpoint . '/' . $commandId, $requestOptions);
63
    }
64
65
    /**
66
     * @param $commandId
67
     * @return ResponseInterface
68
     */
69
    public function deleteCommand($commandId)
70
    {
71
        return $this->client->delete(self::$endpoint . '/' . $commandId);
72
    }
73
74
    /**
75
     * @param $commandId
76
     * @return ResponseInterface
77
     */
78
    public function generateNewToken($commandId)
79
    {
80
        return $this->client->put(self::$endpoint . '/' . $commandId . '/regen_token');
81
    }
82
83
    /**
84
     * @param array $requestOptions
85
     * @return ResponseInterface
86
     */
87
    public function executeCommand(array $requestOptions)
88
    {
89
        return $this->client->post(self::$endpoint . '/execute', $requestOptions);
90
    }
91
92
    /**
93
     * @param       $commandId
94
     * @param array $requestOptions
95
     * @return ResponseInterface
96
     */
97
    public function moveCommand($commandId, array $requestOptions)
98
    {
99
        return $this->client->put(self::$endpoint . '/' . $commandId . '/move', $requestOptions);
100
    }
101
102
    /**
103
     * @param       $commandId
104
     * @return ResponseInterface
105
     */
106
    public function getCommand($commandId)
107
    {
108
        return $this->client->get(self::$endpoint . '/' . $commandId);
109
    }
110
}
111

src/Models/WebhookModel.php 1 location

@@ 21-119 (lines=99) @@
18
 *
19
 * @package Gnello\MattermostRestApi\Models
20
 */
21
class WebhookModel extends AbstractModel
22
{
23
    /**
24
     * @var string
25
     */
26
    private static $endpoint = '/hooks';
27
28
    /**
29
     * @param array $requestOptions
30
     * @return ResponseInterface
31
     */
32
    public function createIncomingWebhook(array $requestOptions)
33
    {
34
        return $this->client->post(self::$endpoint . '/incoming', $requestOptions);
35
    }
36
37
    /**
38
     * @param array $requestOptions
39
     * @return ResponseInterface
40
     */
41
    public function listIncomingWebhooks(array $requestOptions)
42
    {
43
        return $this->client->get(self::$endpoint . '/incoming', $requestOptions);
44
    }
45
46
    /**
47
     * @param       $hookId
48
     * @return ResponseInterface
49
     */
50
    public function getIncomingWebhook($hookId)
51
    {
52
        return $this->client->get(self::$endpoint . '/incoming/' . $hookId);
53
    }
54
55
    /**
56
     * @param       $hookId
57
     * @param array $requestOptions
58
     * @return ResponseInterface
59
     */
60
    public function updateIncomingWebhook($hookId, array $requestOptions)
61
    {
62
        return $this->client->put(self::$endpoint . '/incoming/' . $hookId, $requestOptions);
63
    }
64
65
    /**
66
     * @param array $requestOptions
67
     * @return ResponseInterface
68
     */
69
    public function createOutgoingWebhook(array $requestOptions)
70
    {
71
        return $this->client->post(self::$endpoint . '/outgoing', $requestOptions);
72
    }
73
74
    /**
75
     * @param array $requestOptions
76
     * @return ResponseInterface
77
     */
78
    public function listOutgoingWebhooks(array $requestOptions)
79
    {
80
        return $this->client->get(self::$endpoint . '/outgoing', $requestOptions);
81
    }
82
83
    /**
84
     * @param       $hookId
85
     * @return ResponseInterface
86
     */
87
    public function getOutgoingWebhook($hookId)
88
    {
89
        return $this->client->get(self::$endpoint . '/outgoing/' . $hookId);
90
    }
91
92
    /**
93
     * @param       $hookId
94
     * @return ResponseInterface
95
     */
96
    public function deleteOutgoingWebhook($hookId)
97
    {
98
        return $this->client->delete(self::$endpoint . '/outgoing/' . $hookId);
99
    }
100
101
    /**
102
     * @param       $hookId
103
     * @param array $requestOptions
104
     * @return ResponseInterface
105
     */
106
    public function updateOutgoingWebhook($hookId, array $requestOptions)
107
    {
108
        return $this->client->put(self::$endpoint . '/outgoing/' . $hookId, $requestOptions);
109
    }
110
111
    /**
112
     * @param       $hookId
113
     * @return ResponseInterface
114
     */
115
    public function regenerateTokenForOutgoingWebhook($hookId)
116
    {
117
        return $this->client->post(self::$endpoint . '/outgoing/' . $hookId . '/regen_token');
118
    }
119
}
120