2015-02-10 01:17:29 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Api;
|
|
|
|
|
2015-02-10 02:04:56 +01:00
|
|
|
use GuzzleHttp\Message\Response;
|
|
|
|
|
2015-02-10 01:17:29 +01:00
|
|
|
class ClientResponse
|
|
|
|
{
|
|
|
|
protected $response = null;
|
|
|
|
|
2015-02-10 02:04:56 +01:00
|
|
|
public function __construct(Response $response)
|
2015-02-10 01:17:29 +01:00
|
|
|
{
|
|
|
|
$this->response = $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasError()
|
|
|
|
{
|
|
|
|
return isset($this->response->json()['error']);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getErrorCode()
|
|
|
|
{
|
2015-02-10 02:04:56 +01:00
|
|
|
if (!$this->hasError()) {
|
2015-02-10 01:17:29 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->response->json()['code'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getErrorMessage()
|
|
|
|
{
|
2015-02-10 02:04:56 +01:00
|
|
|
if (!$this->hasError()) {
|
2015-02-10 01:17:29 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->response->json()['error'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getData()
|
|
|
|
{
|
|
|
|
return $this->response->json();
|
|
|
|
}
|
2015-02-10 03:36:06 +01:00
|
|
|
|
|
|
|
public function getBody()
|
|
|
|
{
|
|
|
|
return $this->response->getBody();
|
|
|
|
}
|
2015-02-10 01:17:29 +01:00
|
|
|
}
|