We have detected an error in your notification set-up
(Event-ID dab39dc24f564ec7bd4628d1305fd03c).
Currently, we cannot inform you about inspection progress.
Please check that the user
557058:bca11929-8c2d-43f2-8a82-c5416880d395
still has access to your repository or
update the API account.
1 | <?php |
||
23 | class Api |
||
24 | { |
||
25 | /** |
||
26 | * Api response codes. |
||
27 | */ |
||
28 | const HTTP_RESPONSE_OK = 200; |
||
29 | const HTTP_RESPONSE_CREATED = 201; |
||
30 | const HTTP_RESPONSE_NO_CONTENT = 204; |
||
31 | const HTTP_RESPONSE_BAD_REQUEST = 400; |
||
32 | const HTTP_RESPONSE_UNAUTHORIZED = 401; |
||
33 | const HTTP_RESPONSE_FORBIDDEN = 403; |
||
34 | const HTTP_RESPONSE_NOT_FOUND = 404; |
||
35 | |||
36 | /** |
||
37 | * Transport object |
||
38 | * @var BuzzClientInterface |
||
39 | */ |
||
40 | protected $client; |
||
41 | |||
42 | /** |
||
43 | * @var ClientInterface |
||
44 | */ |
||
45 | protected $httpClient; |
||
46 | |||
47 | /** |
||
48 | * Authentication object |
||
49 | * @var Authentication\AuthenticationInterface |
||
50 | */ |
||
51 | protected $auth; |
||
52 | |||
53 | /** |
||
54 | * @param BuzzClientInterface $client |
||
55 | */ |
||
56 | 250 | public function __construct(BuzzClientInterface $client = null) |
|
64 | |||
65 | /** |
||
66 | * @access public |
||
67 | * @return ClientInterface |
||
68 | */ |
||
69 | 74 | public function getClient() |
|
73 | |||
74 | /** |
||
75 | * @access public |
||
76 | * @param ClientInterface $client |
||
77 | * @return $this |
||
78 | */ |
||
79 | 93 | public function setClient(ClientInterface $client) |
|
85 | |||
86 | /** |
||
87 | * Set API login credentials |
||
88 | * |
||
89 | * @access public |
||
90 | * @param Authentication\AuthenticationInterface $auth |
||
91 | * @return void |
||
92 | */ |
||
93 | 11 | public function setCredentials(Authentication\AuthenticationInterface $auth) |
|
104 | |||
105 | /** |
||
106 | * Make an HTTP GET request to API |
||
107 | * |
||
108 | * @access public |
||
109 | * @param string $endpoint API endpoint |
||
110 | * @param string|array $params GET parameters |
||
111 | * @param array $headers HTTP headers |
||
112 | * @return MessageInterface |
||
113 | */ |
||
114 | 2 | public function requestGet($endpoint, $params = array(), $headers = array()) |
|
118 | |||
119 | /** |
||
120 | * Make an HTTP POST request to API |
||
121 | * |
||
122 | * @access public |
||
123 | * @param string $endpoint API endpoint |
||
124 | * @param string|array $params POST parameters |
||
125 | * @param array $headers HTTP headers |
||
126 | * @return MessageInterface |
||
127 | */ |
||
128 | 1 | public function requestPost($endpoint, $params = array(), $headers = array()) |
|
132 | |||
133 | /** |
||
134 | * Make an HTTP PUT request to API |
||
135 | * |
||
136 | * @access public |
||
137 | * @param string $endpoint API endpoint |
||
138 | * @param string|array $params POST parameters |
||
139 | * @param array $headers HTTP headers |
||
140 | * @return MessageInterface |
||
141 | */ |
||
142 | 1 | public function requestPut($endpoint, $params = array(), $headers = array()) |
|
146 | |||
147 | /** |
||
148 | * Make a HTTP DELETE request to API |
||
149 | * |
||
150 | * @access public |
||
151 | * @param string $endpoint API endpoint |
||
152 | * @param string|array $params DELETE parameters |
||
153 | * @param array $headers HTTP headers |
||
154 | * @return MessageInterface |
||
155 | */ |
||
156 | 1 | public function requestDelete($endpoint, $params = array(), $headers = array()) |
|
160 | |||
161 | /** |
||
162 | * Create HTTP request |
||
163 | * |
||
164 | * @access protected |
||
165 | * @param string $method HTTP method |
||
166 | * @param string $endpoint Api endpoint |
||
167 | * @param string|array $params Request parameter(s) |
||
168 | * @param array $headers HTTP headers |
||
169 | * @return MessageInterface |
||
170 | * |
||
171 | * @throws \RuntimeException |
||
172 | */ |
||
173 | protected function doRequest($method, $endpoint, $params, array $headers) |
||
177 | |||
178 | /** |
||
179 | * Set the preferred format for response |
||
180 | * |
||
181 | * @access public |
||
182 | * @param string $name Format name |
||
183 | * @return self |
||
184 | * |
||
185 | * @throws \InvalidArgumentException |
||
186 | */ |
||
187 | 1 | public function setFormat($name) |
|
193 | |||
194 | /** |
||
195 | * Get current format used for response |
||
196 | * |
||
197 | * @access public |
||
198 | * @return string |
||
199 | */ |
||
200 | 1 | public function getFormat() |
|
204 | |||
205 | /** |
||
206 | * @param string $name |
||
207 | * @return Api |
||
208 | * |
||
209 | * @throws \InvalidArgumentException |
||
210 | */ |
||
211 | 12 | public function api($name) |
|
233 | |||
234 | /** |
||
235 | * Convert JSON to array with error check |
||
236 | * |
||
237 | * @access protected |
||
238 | * @param string $body JSON data |
||
239 | * @return array |
||
240 | * |
||
241 | * @throws \InvalidArgumentException |
||
242 | */ |
||
243 | 14 | protected function decodeJSON($body) |
|
253 | } |
||
254 |