Skip to content

Commit

Permalink
Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
jguittard committed Jun 26, 2015
1 parent 1c09c10 commit 710355e
Showing 1 changed file with 3 additions and 44 deletions.
47 changes: 3 additions & 44 deletions src/Service/Resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ class Resource implements InputFilterAwareInterface
*/
protected $errors = [];

/**
* @var Http\Client
*/
protected $httpClient;

/**
* @var mixed
*/
Expand Down Expand Up @@ -66,6 +61,9 @@ class Resource implements InputFilterAwareInterface
*/
protected $hydrator;

/**
* @return bool
*/
public function hasErrors()
{
return count($this->errors) > 0;
Expand Down Expand Up @@ -282,43 +280,4 @@ public function delete($id)
curl_exec($this->curl);
return true;
}

/**
* @param EntityInterface $entity
*/
protected function processData(EntityInterface $entity)
{
$data = $this->getHydrator()->extract($entity);
$this->getInputFilter()->setData($data);

if (!$this->getInputFilter()->isValid()) {
$this->errors = $this->getInputFilter()->getMessages();
throw new DomainException("Unprocessable entity", 422);
}

$this->httpClient->setRawBody(json_decode($data));
}

/**
* @return object
*/
protected function processRequest()
{
$response = $this->httpClient->send();

if ($response->isSuccess()) {
$result = $response->getBody();
$entityClass= $this->getEntityClass();
$entity = $this->getHydrator()->hydrate((array)$result, new $entityClass);
return $entity;
} elseif ($response->isClientError() || $response->isServerError()) {
throw new DomainException(
sprintf(
'An error occured while requesting Zoho API for %s',
__METHOD__
),
$response->getStatusCode()
);
}
}
}

0 comments on commit 710355e

Please sign in to comment.