ProjectNotesRequest::update()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Guapa\TimeChimp;
4
5
class ProjectNotesRequest extends AbstractRequest
6
{
7
8
    /**
9
     * Get all project notes.
10
     *
11
     * @see https://timechimp.docs.apiary.io/#reference/projectnotes/v1projectnotes/get-all-project-notes
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', 'projectnotes');
22
    }
23
24
    /**
25
     * Update a project note.
26
     *
27
     * @see https://timechimp.docs.apiary.io/#reference/projectnotes/v1projectnotes/update-project-note
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', 'projectnotes', $parameters);
46
    }
47
48
    /**
49
     * Create a project note.
50
     *
51
     * @see https://timechimp.docs.apiary.io/#reference/projectnotes/v1projectnotes/create-new-project-notes
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', 'projectnotes', $parameters);
70
    }
71
72
    /**
73
     * Delete a project note.
74
     *
75
     * @see https://timechimp.docs.apiary.io/#reference/projectnotes/v1projectnotes/delete-project-note
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', "projectnotes/{$id}");
88
    }
89
90
    /**
91
     * Get a project note.
92
     *
93
     * @see https://timechimp.docs.apiary.io/#reference/projectnotes/v1projectnotesid/get-projectnsote
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', "projectnotes/{$id}");
106
    }
107
108
    /**
109
     * Get all project notes by project.
110
     *
111
     * @see https://timechimp.docs.apiary.io/#reference/projectnotes/v1projectnotesprojectprojectid/get-project-notes-by-project
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', "projectnotes/project/{$projectId}");
124
    }
125
}
126