Completed
Push — master ( d0f8e4...6a2707 )
by Luca
01:22
created

JobModel::getJobs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 4
loc 4
rs 10
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
 * God bless this mess.
7
 *
8
 * @author Luca Agnello <[email protected]>
9
 * @link https://api.mattermost.com/
10
 */
11
12
namespace Gnello\Mattermost\Models;
13
14
use Gnello\Mattermost\Client;
15
16
/**
17
 * Class JobModel
18
 *
19
 * @package Gnello\Mattermost\Models
20
 */
21 View Code Duplication
class JobModel extends AbstractModel
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
{
23
    /**
24
     * @var string
25
     */
26
    private static $endpoint = '/jobs';
27
28
    /**
29
     * @param array $requestOptions
30
     * @return \Psr\Http\Message\ResponseInterface
31
     */
32
    public function getJobs(array $requestOptions = [])
33
    {
34
        return $this->client->get(self::$endpoint, $requestOptions, Client::TYPE_QUERY);
35
    }
36
37
    /**
38
     * @param array $requestOptions
39
     * @return \Psr\Http\Message\ResponseInterface
40
     */
41
    public function createJob(array $requestOptions)
42
    {
43
        return $this->client->post(self::$endpoint, $requestOptions);
44
    }
45
46
    /**
47
     * @param $jobId
48
     * @return \Psr\Http\Message\ResponseInterface
49
     */
50
    public function getJob($jobId)
51
    {
52
        return $this->client->get(self::$endpoint . '/' . $jobId);
53
    }
54
55
    /**
56
     * @param $jobId
57
     * @return \Psr\Http\Message\ResponseInterface
58
     */
59
    public function deleteJob($jobId)
60
    {
61
        return $this->client->post(self::$endpoint . '/' . $jobId . '/cancel');
62
    }
63
64
    /**
65
     * @param       $type
66
     * @param array $requestOptions
67
     * @return \Psr\Http\Message\ResponseInterface
68
     */
69
    public function getJobsOfType($type, array $requestOptions = [])
70
    {
71
        return $this->client->get(self::$endpoint . '/type/' . $type, $requestOptions);
72
    }
73
}
74