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 |
||
25 | class Api |
||
26 | { |
||
27 | /** |
||
28 | * Api response codes. |
||
29 | */ |
||
30 | const HTTP_RESPONSE_OK = 200; |
||
31 | const HTTP_RESPONSE_CREATED = 201; |
||
32 | const HTTP_RESPONSE_NO_CONTENT = 204; |
||
33 | const HTTP_RESPONSE_BAD_REQUEST = 400; |
||
34 | const HTTP_RESPONSE_UNAUTHORIZED = 401; |
||
35 | const HTTP_RESPONSE_FORBIDDEN = 403; |
||
36 | const HTTP_RESPONSE_NOT_FOUND = 404; |
||
37 | |||
38 | /** |
||
39 | * @var ClientInterface |
||
40 | */ |
||
41 | protected $httpClient; |
||
42 | |||
43 | /** |
||
44 | * @param array $options |
||
45 | * @param ClientInterface $client |
||
46 | */ |
||
47 | public function __construct(array $options = array(), ClientInterface $client = null) |
||
54 | 289 | ||
55 | 289 | /** |
|
56 | 289 | * @access public |
|
57 | * @return ClientInterface |
||
58 | */ |
||
59 | public function getClient() |
||
63 | |||
64 | 119 | /** |
|
65 | * @access public |
||
66 | * @param ClientInterface $client |
||
67 | * @return $this |
||
68 | */ |
||
69 | public function setClient(ClientInterface $client) |
||
75 | |||
76 | 123 | /** |
|
77 | * Set API login credentials |
||
78 | * |
||
79 | * @param Authentication $authentication |
||
80 | * @return void |
||
81 | */ |
||
82 | public function setCredentials(Authentication $authentication) |
||
86 | 11 | ||
87 | public function addPlugin(Plugin $plugin) |
||
92 | |||
93 | /** |
||
94 | * Make an HTTP GET request to API |
||
95 | 11 | * |
|
96 | 11 | * @access public |
|
97 | * @param string $endpoint API endpoint |
||
98 | * @param string|array $params GET parameters |
||
99 | * @param array $headers HTTP headers |
||
100 | * @return MessageInterface |
||
101 | */ |
||
102 | public function requestGet($endpoint, $params = array(), $headers = array()) |
||
106 | |||
107 | 2 | /** |
|
108 | * Make an HTTP POST request to API |
||
109 | 2 | * |
|
110 | * @access public |
||
111 | * @param string $endpoint API endpoint |
||
112 | * @param string|array $params POST parameters |
||
113 | * @param array $headers HTTP headers |
||
114 | * @return MessageInterface |
||
115 | */ |
||
116 | public function requestPost($endpoint, $params = array(), $headers = array()) |
||
120 | |||
121 | 1 | /** |
|
122 | * Make an HTTP PUT request to API |
||
123 | 1 | * |
|
124 | * @access public |
||
125 | * @param string $endpoint API endpoint |
||
126 | * @param string|array $params POST parameters |
||
127 | * @param array $headers HTTP headers |
||
128 | * @return MessageInterface |
||
129 | */ |
||
130 | public function requestPut($endpoint, $params = array(), $headers = array()) |
||
134 | |||
135 | 1 | /** |
|
136 | * Make a HTTP DELETE request to API |
||
137 | 1 | * |
|
138 | * @access public |
||
139 | * @param string $endpoint API endpoint |
||
140 | * @param string|array $params DELETE parameters |
||
141 | * @param array $headers HTTP headers |
||
142 | * @return MessageInterface |
||
143 | */ |
||
144 | public function requestDelete($endpoint, $params = array(), $headers = array()) |
||
148 | |||
149 | 1 | /** |
|
150 | * Create HTTP request |
||
151 | 1 | * |
|
152 | * @access protected |
||
153 | * @param string $method HTTP method |
||
154 | * @param string $endpoint Api endpoint |
||
155 | * @param string|array $params Request parameter(s) |
||
156 | * @param array $headers HTTP headers |
||
157 | * @return MessageInterface |
||
158 | * |
||
159 | * @throws \RuntimeException |
||
160 | */ |
||
161 | protected function doRequest($method, $endpoint, $params, array $headers) |
||
165 | |||
166 | /** |
||
167 | * Set the preferred format for response |
||
168 | * |
||
169 | * @access public |
||
170 | * @param string $name Format name |
||
171 | * @return self |
||
172 | * |
||
173 | * @throws \InvalidArgumentException |
||
174 | */ |
||
175 | public function setFormat($name) |
||
181 | |||
182 | 2 | /** |
|
183 | * Get current format used for response |
||
184 | 2 | * |
|
185 | * @access public |
||
186 | * @return string |
||
187 | */ |
||
188 | public function getFormat() |
||
192 | |||
193 | 2 | /** |
|
194 | * @param string $name |
||
195 | 2 | * @return Api |
|
196 | * |
||
197 | * @throws \InvalidArgumentException |
||
198 | */ |
||
199 | public function api($name) |
||
221 | 7 | ||
222 | 7 | /** |
|
223 | * @access public |
||
224 | 7 | * @return void |
|
225 | 6 | */ |
|
226 | public function __clone() |
||
231 | |||
232 | /** |
||
233 | * Convert JSON to array with error check |
||
234 | * |
||
235 | 1 | * @access protected |
|
236 | * @param string $body JSON data |
||
237 | * @return array |
||
238 | 1 | * |
|
239 | 1 | * @throws \InvalidArgumentException |
|
240 | */ |
||
241 | protected function decodeJSON($body) |
||
251 | } |
||
252 |