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 | 286 | ||
| 55 | 286 | /** |
|
| 56 | 286 | * @access public |
|
| 57 | * @return ClientInterface |
||
| 58 | */ |
||
| 59 | public function getClient() |
||
| 63 | |||
| 64 | 109 | /** |
|
| 65 | * @access public |
||
| 66 | * @param ClientInterface $client |
||
| 67 | * @return $this |
||
| 68 | */ |
||
| 69 | public function setClient(ClientInterface $client) |
||
| 75 | |||
| 76 | 113 | /** |
|
| 77 | * Set API login credentials |
||
| 78 | * |
||
| 79 | * @access public |
||
| 80 | * @param Authentication $authentication |
||
| 81 | * @return void |
||
| 82 | */ |
||
| 83 | public function setCredentials(Authentication $authentication) |
||
| 87 | |||
| 88 | public function addPlugin(Plugin $plugin) |
||
| 93 | |||
| 94 | /** |
||
| 95 | 11 | * Make an HTTP GET request to API |
|
| 96 | 11 | * |
|
| 97 | * @access public |
||
| 98 | * @param string $endpoint API endpoint |
||
| 99 | * @param string|array $params GET parameters |
||
| 100 | * @param array $headers HTTP headers |
||
| 101 | * @return MessageInterface |
||
| 102 | */ |
||
| 103 | public function requestGet($endpoint, $params = array(), $headers = array()) |
||
| 107 | 2 | ||
| 108 | /** |
||
| 109 | 2 | * Make an HTTP POST request to API |
|
| 110 | * |
||
| 111 | * @access public |
||
| 112 | * @param string $endpoint API endpoint |
||
| 113 | * @param string|array $params POST parameters |
||
| 114 | * @param array $headers HTTP headers |
||
| 115 | * @return MessageInterface |
||
| 116 | */ |
||
| 117 | public function requestPost($endpoint, $params = array(), $headers = array()) |
||
| 121 | 1 | ||
| 122 | /** |
||
| 123 | 1 | * Make an HTTP PUT request to API |
|
| 124 | * |
||
| 125 | * @access public |
||
| 126 | * @param string $endpoint API endpoint |
||
| 127 | * @param string|array $params POST parameters |
||
| 128 | * @param array $headers HTTP headers |
||
| 129 | * @return MessageInterface |
||
| 130 | */ |
||
| 131 | public function requestPut($endpoint, $params = array(), $headers = array()) |
||
| 135 | 1 | ||
| 136 | /** |
||
| 137 | 1 | * Make a HTTP DELETE request to API |
|
| 138 | * |
||
| 139 | * @access public |
||
| 140 | * @param string $endpoint API endpoint |
||
| 141 | * @param string|array $params DELETE parameters |
||
| 142 | * @param array $headers HTTP headers |
||
| 143 | * @return MessageInterface |
||
| 144 | */ |
||
| 145 | public function requestDelete($endpoint, $params = array(), $headers = array()) |
||
| 149 | 1 | ||
| 150 | /** |
||
| 151 | 1 | * Create HTTP request |
|
| 152 | * |
||
| 153 | * @access protected |
||
| 154 | * @param string $method HTTP method |
||
| 155 | * @param string $endpoint Api endpoint |
||
| 156 | * @param string|array $params Request parameter(s) |
||
| 157 | * @param array $headers HTTP headers |
||
| 158 | * @return MessageInterface |
||
| 159 | * |
||
| 160 | * @throws \RuntimeException |
||
| 161 | */ |
||
| 162 | protected function doRequest($method, $endpoint, $params, array $headers) |
||
| 166 | |||
| 167 | /** |
||
| 168 | * Set the preferred format for response |
||
| 169 | * |
||
| 170 | * @access public |
||
| 171 | * @param string $name Format name |
||
| 172 | * @return self |
||
| 173 | * |
||
| 174 | * @throws \InvalidArgumentException |
||
| 175 | */ |
||
| 176 | public function setFormat($name) |
||
| 182 | 2 | ||
| 183 | /** |
||
| 184 | 2 | * Get current format used for response |
|
| 185 | * |
||
| 186 | * @access public |
||
| 187 | * @return string |
||
| 188 | */ |
||
| 189 | public function getFormat() |
||
| 193 | 2 | ||
| 194 | /** |
||
| 195 | 2 | * @param string $name |
|
| 196 | * @return Api |
||
| 197 | * |
||
| 198 | * @throws \InvalidArgumentException |
||
| 199 | */ |
||
| 200 | public function api($name) |
||
| 222 | 7 | ||
| 223 | /** |
||
| 224 | 7 | * @access public |
|
| 225 | 6 | * @return void |
|
| 226 | */ |
||
| 227 | public function __clone() |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Convert JSON to array with error check |
||
| 235 | 1 | * |
|
| 236 | * @access protected |
||
| 237 | * @param string $body JSON data |
||
| 238 | 1 | * @return array |
|
| 239 | 1 | * |
|
| 240 | * @throws \InvalidArgumentException |
||
| 241 | */ |
||
| 242 | protected function decodeJSON($body) |
||
| 252 | } |
||
| 253 |