ProjectsRequest::getAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Guapa\TimeChimp;
4
5
class ProjectsRequest extends AbstractRequest
6
{
7
8
    /**
9
     * Get all projects.
10
     *
11
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projects/get-all-projects
12
     *
13
     * @return \Psr\Http\Message\ResponseInterface
14
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
15
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
16
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
17
     * @throws \GuzzleHttp\Exception\GuzzleException
18
     */
19
    public function getAll(): \Psr\Http\Message\ResponseInterface
20
    {
21
        return $this->execute('get', 'projects');
22
    }
23
24
    /**
25
     * Update a project.
26
     *
27
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projects/update-project
28
     *
29
     * @param array $parameters
30
     *
31
     * @return \Psr\Http\Message\ResponseInterface
32
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
33
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
34
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
35
     * @throws \GuzzleHttp\Exception\GuzzleException
36
     */
37
    public function update(array $parameters): \Psr\Http\Message\ResponseInterface
38
    {
39
        if (! isset($parameters['json'])) {
40
            $parameters = [
41
                'json' => $parameters,
42
            ];
43
        }
44
45
        return $this->execute('put', 'projects', $parameters);
46
    }
47
48
    /**
49
     * Create a project.
50
     *
51
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projects/create-new-project
52
     *
53
     * @param array $parameters
54
     *
55
     * @return \Psr\Http\Message\ResponseInterface
56
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
57
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
58
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
59
     * @throws \GuzzleHttp\Exception\GuzzleException
60
     */
61
    public function create(array $parameters): \Psr\Http\Message\ResponseInterface
62
    {
63
        if (! isset($parameters['json'])) {
64
            $parameters = [
65
                'json' => $parameters,
66
            ];
67
        }
68
69
        return $this->execute('post', 'projects', $parameters);
70
    }
71
72
    /**
73
     * Delete a project.
74
     *
75
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projects/delete-project
76
     *
77
     * @param mixed $id
78
     *
79
     * @return \Psr\Http\Message\ResponseInterface
80
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
81
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
82
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
83
     * @throws \GuzzleHttp\Exception\GuzzleException
84
     */
85
    public function delete($id): \Psr\Http\Message\ResponseInterface
86
    {
87
        return $this->execute('delete', "projects/{$id}");
88
    }
89
90
    /**
91
     * Get a project.
92
     *
93
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projectsid/get-project
94
     *
95
     * @param mixed $id
96
     *
97
     * @return \Psr\Http\Message\ResponseInterface
98
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
99
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
100
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
101
     * @throws \GuzzleHttp\Exception\GuzzleException
102
     */
103
    public function get($id): \Psr\Http\Message\ResponseInterface
104
    {
105
        return $this->execute('get', "projects/{$id}");
106
    }
107
108
    /**
109
     * Get all projects by customer.
110
     *
111
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projectscustomercustomerid/get-projects-by-customer
112
     *
113
     * @param mixed $projectId
114
     *
115
     * @return \Psr\Http\Message\ResponseInterface
116
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
117
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
118
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
119
     * @throws \GuzzleHttp\Exception\GuzzleException
120
     */
121
    public function forProject($projectId): \Psr\Http\Message\ResponseInterface
122
    {
123
        return $this->execute('get', "projects/project/{$projectId}");
124
    }
125
126
    /**
127
     * Get insights for a project.
128
     *
129
     * @see https://timechimp.docs.apiary.io/#reference/projects/v1projectsinsightsid/get-project-insights
130
     *
131
     * @param mixed $projectId
132
     *
133
     * @return \Psr\Http\Message\ResponseInterface
134
     * @throws \Guapa\TimeChimp\Exceptions\ClientException
135
     * @throws \Guapa\TimeChimp\Exceptions\NotFoundException
136
     * @throws \Guapa\TimeChimp\Exceptions\UnauthorizedException
137
     * @throws \GuzzleHttp\Exception\GuzzleException
138
     */
139
    public function insights($projectId): \Psr\Http\Message\ResponseInterface
140
    {
141
        return $this->execute('get', "projects/insights/{$projectId}");
142
    }
143
}
144