Пример #1
0
 /**
  * {@inheritDoc}
  */
 public function request($path, $body, $httpMethod = 'GET', array $headers = array(), array $options = array())
 {
     if (!empty($this->options['debug'])) {
         $options['debug'] = $this->options['debug'];
     }
     if (count($headers) > 0) {
         $options['headers'] = $headers;
     }
     $options['body'] = $body;
     $request = $this->client->createRequest($httpMethod, $path, $options);
     try {
         $response = $this->client->send($request);
     } catch (\Exception $e) {
         $this->errorHandler->onException($e);
     }
     return $response;
 }
Пример #2
0
 /**
  * Get next results page.
  *
  * @return mixed
  */
 public function getNext()
 {
     $range = $this->getNextRange();
     $headers = array_merge($this->headers, array('range' => $this->buildRangeHeader($range['start'], $range['end'])));
     try {
         $response = $this->client->get($this->path, $this->parameters, $headers);
         $contentRange = $response->getContentRange();
         $this->count = $contentRange['count'];
         $this->limit = $contentRange['end'] - $contentRange['start'] + 1;
         $this->offset = $contentRange['end'] + 1;
         return $this->hydrate($response->getContent());
     } catch (UpholdClientException $e) {
         if (412 === $e->getHttpCode() || 416 === $e->getHttpCode()) {
             return $this->hydrate(array());
         }
         throw $e;
     }
 }