/** * @param Response $response * * @return array * * @throws BadRequestException * @throws RateLimitException */ protected function _handleResponse(Response $response) { $code = $response->getHttpCode(); $error = $response->getErrorMessage(); switch ($code) { case 0: case 200: return $response->getJson(); case 429: throw new RateLimitException($error, $code); default: throw new BadRequestException($error, $code); } }
/** * @param Response $request * * @return array * * @throws BitlyException */ protected function _checkStatusCode(Response $request) { $array = $request->getJson(); if ($array['status_code'] == 200) { return $array['data']; } throw new BitlyException($array['status_txt']); }