Completed
Push — develop ( c8d2e9...9b1d71 )
by Adam
03:00
created

Api::postRawMethod()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace IBM\Watson\Common\stubs;
4
5
use IBM\Watson\Common\Api\AbstractApi;
6
7
/**
8
 * Stub Class, does nothing
9
 */
10
class Api extends AbstractApi
11
{
12
    /**
13
     * @return \Psr\Http\Message\ResponseInterface
14
     * @throws \Http\Client\Exception
15
     * @throws \IBM\Watson\Common\Exception\Domain\InsufficientPrivilegesException
16
     * @throws \IBM\Watson\Common\Exception\Domain\NotFoundException
17
     * @throws \IBM\Watson\Common\Exception\Domain\UnknownErrorException
18
     */
19
    public function getMethod()
20
    {
21
        $response = $this->get('/api', [
22
            'param' => 'value'
23
        ]);
24
25
        if ($response->getStatusCode() !== 200) {
26
            $this->handleErrors($response);
27
        }
28
29
        return $response;
30
    }
31
32
    /**
33
     * @return \Psr\Http\Message\ResponseInterface
34
     * @throws \Http\Client\Exception
35
     * @throws \IBM\Watson\Common\Exception\Domain\InsufficientPrivilegesException
36
     * @throws \IBM\Watson\Common\Exception\Domain\NotFoundException
37
     * @throws \IBM\Watson\Common\Exception\Domain\UnknownErrorException
38
     */
39
    public function postMethod()
40
    {
41
        $response = $this->post('/api');
42
43
        if ($response->getStatusCode() !== 200) {
44
            $this->handleErrors($response);
45
        }
46
47
        return $response;
48
    }
49
50
    /**
51
     * @return \Psr\Http\Message\ResponseInterface
52
     * @throws \Http\Client\Exception
53
     * @throws \IBM\Watson\Common\Exception\Domain\InsufficientPrivilegesException
54
     * @throws \IBM\Watson\Common\Exception\Domain\NotFoundException
55
     * @throws \IBM\Watson\Common\Exception\Domain\UnknownErrorException
56
     */
57
    public function postRawMethod()
58
    {
59
        $response = $this->postRaw('/api', 'body');
60
61
        if ($response->getStatusCode() !== 200) {
62
            $this->handleErrors($response);
63
        }
64
65
        return $response;
66
    }
67
68
    /**
69
     * @return \Psr\Http\Message\ResponseInterface
70
     * @throws \Http\Client\Exception
71
     * @throws \IBM\Watson\Common\Exception\Domain\InsufficientPrivilegesException
72
     * @throws \IBM\Watson\Common\Exception\Domain\NotFoundException
73
     * @throws \IBM\Watson\Common\Exception\Domain\UnknownErrorException
74
     */
75
    public function putMethod()
76
    {
77
        $response = $this->put('/api');
78
79
        if ($response->getStatusCode() !== 200) {
80
            $this->handleErrors($response);
81
        }
82
83
        return $response;
84
    }
85
86
    /**
87
     * @return \Psr\Http\Message\ResponseInterface
88
     * @throws \Http\Client\Exception
89
     * @throws \IBM\Watson\Common\Exception\Domain\InsufficientPrivilegesException
90
     * @throws \IBM\Watson\Common\Exception\Domain\NotFoundException
91
     * @throws \IBM\Watson\Common\Exception\Domain\UnknownErrorException
92
     */
93
    public function patchMethod()
94
    {
95
        $response = $this->patch('/api');
96
97
        if ($response->getStatusCode() !== 200) {
98
            $this->handleErrors($response);
99
        }
100
101
        return $response;
102
    }
103
104
    /**
105
     * @return \Psr\Http\Message\ResponseInterface
106
     * @throws \Http\Client\Exception
107
     * @throws \IBM\Watson\Common\Exception\Domain\InsufficientPrivilegesException
108
     * @throws \IBM\Watson\Common\Exception\Domain\NotFoundException
109
     * @throws \IBM\Watson\Common\Exception\Domain\UnknownErrorException
110
     */
111
    public function deleteMethod()
112
    {
113
        $response = $this->delete('/api');
114
115
        if ($response->getStatusCode() !== 200) {
116
            $this->handleErrors($response);
117
        }
118
119
        return $response;
120
    }
121
}
122