Example #1
0
 /**
  * Method returns the response for the requested resource
  * @param  string $pURI
  * @param  array  $pOptions
  * @return mixed
  */
 protected function requestResource($pURL, array $pOptions)
 {
     $options = array_replace_recursive($this->settings['defaults'], $pOptions);
     $format = $options['format'];
     $method = $options['method'];
     $this->setHeaders($options);
     $parameters['headers'] = $this->headers;
     if (isset($options['body'])) {
         $parameters['body'] = $this->formatBody($options);
     }
     $request = $this->client->createRequest($method, $pURL, $parameters);
     try {
         $response = $this->client->send($request);
         $this->event->fire('forrest.response', array($request, $response));
         return $this->responseFormat($response, $format);
     } catch (RequestException $e) {
         $this->assignExceptions($e);
     }
 }
 public function createRequest($method = RequestInterface::GET, $uri = null, $headers = null, $body = null)
 {
     $request = parent::createRequest($method, $uri, $headers, $body);
     $request->getQuery()->set('apikey', $this->getConfig()->get('apikey'));
     return $request;
 }