TasksRequest::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 TasksRequest extends AbstractRequest
6
{
7
8
    /**
9
     * Get all tasks.
10
     *
11
     * @see https://timechimp.docs.apiary.io/#reference/tasks/v1tasks/get-all-tasks
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', 'tasks');
22
    }
23
24
    /**
25
     * Update a project.
26
     *
27
     * @see https://timechimp.docs.apiary.io/#reference/tasks/v1tasks/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', 'tasks', $parameters);
46
    }
47
48
    /**
49
     * Create a project.
50
     *
51
     * @see https://timechimp.docs.apiary.io/#reference/tasks/v1tasks/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', 'tasks', $parameters);
70
    }
71
72
    /**
73
     * Delete a project.
74
     *
75
     * @see https://timechimp.docs.apiary.io/#reference/tasks/v1tasks/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', "tasks/{$id}");
88
    }
89
90
    /**
91
     * Get a project.
92
     *
93
     * @see https://timechimp.docs.apiary.io/#reference/tasks/v1tasksid/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', "tasks/{$id}");
106
    }
107
}
108