/** * Prints out an error message plus service response when the service * request fails. * * @param Object $response * The full object response from the webservice. * * @param String $uri * The service URI which the service has been requested against. * * @return Bool * Whether or not the request was successful ( code 200 ). */ private function response_code($response, $uri) { $this->response_code = $code = $response->code; $body = $response->raw_body; switch ($code) { case '200': tools::print_green("Chamada para %uri foi bem sucedida.", array('%uri' => $uri)); return TRUE; break; case '404': tools::print_yellow("Chamada para %uri foi bem sucedida mas o item nao existe no webservice.", array('%uri' => $uri)); if (!empty($body)) { tools::print_yellow("O Webservice respondeu o seguinte:"); tools::print_blue($body); } return FALSE; break; default: $print = "A chamada ao Endpoint {$uri} FALHOU. Retornou o Codigo de Status HTTP {$code}." . PHP_EOL; if (!empty($body)) { $print .= "O Webservice respondeu o seguinte:" . PHP_EOL; $print .= $body; } $this->log($print, 'red'); return FALSE; break; } }